Go to the documentation of this file.
70 #include <sys/ioctl.h>
73 #include <sys/param.h>
84 #ifndef _CRT_SECURE_NO_DEPRECATE
85 #define _CRT_SECURE_NO_DEPRECATE
87 #pragma warning(disable:4996)
275 while (remaining > 0)
280 read1 =
m_handle->read(buffer, 1, remaining);
287 wPos +=
m_handle->write(buffer, 1, read1);
320 if (needleLength == 0)
323 const char* needle = (
const char*) needleV.data();
335 while (readBytes > 0)
340 while (bufferPos < readBytes && needlePos < needleLength)
342 if (buffer[bufferPos] == needle[needlePos])
351 else if (buffer[bufferPos] == needle[0])
359 if (needlePos < needleLength)
387 if (_wstat(
m_filename.toStdWString().c_str(), &stats) == 0)
472 char* bufferRoot = (
char*) malloc((
XsSize)(bsize * 2));
475 char* buffer1 = bufferRoot;
476 char* buffer2 = bufferRoot + bsize;
482 if (
data.size() == 0)
485 if (remaining >= bsize)
486 read1 =
m_handle->read(buffer1, 1, bsize);
488 read1 =
m_handle->read(buffer1, 1, remaining);
493 while (remaining > 0)
502 if (remaining >= bsize)
503 read1 =
m_handle->read(buffer1, 1, bsize);
505 read1 =
m_handle->read(buffer1, 1, remaining);
512 wPos +=
m_handle->write(buffer2, 1, read2);
546 if (localResult !=
XRV_OK)
549 localResult =
m_handle->create(filename,
false);
553 localResult =
m_handle->open(filename,
false);
557 if (localResult !=
XRV_OK)
572 if (realpath(filename.c_str(), fullpath) == NULL)
667 bdata.setSize((
XsSize) maxLength);
668 char*
data = (
char*) bdata.data();
686 if ((
unsigned char) readChar == terminator)
842 auto rv =
m_handle->resize(minSize);
XsResultValue flushFileBuffers()
Flushes the buffers of a specified file and causes all buffered data to be written to a file.
XsResultValue setWritePosition(XsFilePos pos=-1)
Set the new absolute write position.
void gotoWrite()
Change from reading to writing mode.
XsResultValue open(const XsString &filename, bool createNew, bool readOnly)
Open a file.
A list of uint8_t values.
XsString getFileName() const
Return the filename that was last successfully opened.
bool isReadOnly() const
Return whether the file is read-only or not.
XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
XsResultValue flushData() override
Flush all data in the buffers to and from the device.
XsResultValue m_lastResult
The last result of an operation.
XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
XsFilePos m_writePos
The last write position in the file.
@ XRV_ENDOFFILE
270: End of file is reached
XsTimeStamp getFileDate() const
Return the creation date of the file.
XsResultValue insertData(XsFilePos start, const XsByteArray &data)
Insert the given data into the file.
@ XRV_ALREADYOPEN
269: An I/O device is already opened with this object
@ XRV_NOFILEOPEN
287: No file opened for reading/writing
XsResultValue deleteData(XsFilePos start, XsFilePos length)
Delete the given data from the file.
@ XRV_ERROR
256: A generic error occurred
void gotoRead()
Change from writing to reading mode.
XsFilePos getReadPosition() const
Return the current read position.
XsFile * m_handle
The file handle, also indicates if the file is open or not.
@ XRV_OK
0: Operation was performed successfully
XsFilePos m_readPos
The last read position in the file.
XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
XsResultValue
Xsens result values.
static const XsFilePos m_fileBlockSize
The default file block size.
@ XRV_OUTOFMEMORY
261: No internal memory available
XsFilePos getFileSize() const
Return the size of the file.
XsResultValue readDataBlocks(XsFilePos blockCount, XsByteArray &data)
This function will read blocks of data aligned to m_fileBlockSize.
XsResultValue reserve(XsFilePos minSize)
Make sure the file is at least minSize bytes big.
XsResultValue closeFile()
Close the file.
XsFilePos getWritePosition() const
Return the current write position.
size_t XsSize
XsSize must be unsigned number!
@ XRV_INPUTCANNOTBEOPENED
267: The specified i/o device can not be opened
bool m_readOnly
Indicates if the file was opened in read-only mode.
XsString m_filename
Contains the name of the file that was last successfully opened.
XsResultValue find(const XsByteArray &data, XsFilePos &pos)
Find a string of bytes in the file.
XsResultValue readTerminatedData(XsFilePos maxLength, unsigned char terminator, XsByteArray &bdata)
Read data from the file and put it into the data buffer.
XsResultValue getLastResult() const override
Return the result code of the last operation.
XsResultValue close() override
Close the file, overrides IoInterface::close().
@ XRV_READONLY
273: Tried to change a read-only value
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
XsResultValue writeData(const XsByteArray &data, XsFilePos *written=nullptr) override
Write the data contained in data to the device.
XsFilePos m_fileSize
Contains the size of the file.
bool isOpen() const override
Return whether the file is open or not.
bool m_reading
Indicates whether the last operation was a read or write operation.
XsResultValue readData(XsFilePos maxLength, XsByteArray &data) override
Read at most maxLength bytes from the device into data.
int64_t XsFilePos
The type that is used for positioning inside a file.
A 0-terminated managed string of characters.
struct XsTimeStamp XsTimeStamp
XsResultValue create(const XsString &filename)
Create an empty file.
This class contains method to set, retrieve and compare timestamps.
@ XRV_INSUFFICIENTSPACE
266: Insufficient buffer space available
#define XS_MAX_FILENAME_LENGTH
@ XRV_INVALIDPARAM
33: An invalid parameter is supplied
XsResultValue closeAndDelete()
Close the file and delete it.