Go to the documentation of this file.
70 #include <sys/ioctl.h>
73 #include <sys/param.h>
122 (void) _wunlink(filenameW);
124 unlink(filename->m_data);
255 return _wfopen(filenameW, modeW);
257 __except (EXCEPTION_EXECUTE_HANDLER)
262 return fopen(filename->m_data, mode->m_data);
283 thisPtr->
m_handle = freopen(filename->m_data, mode->m_data, thisPtr->
m_handle);
298 return (thisPtr->
m_handle != NULL) ? 0 : 1;
312 return _wstat(filenameW, &buffer);
315 return stat(filename->m_data, &buffer);
371 int rv = _chsize_s(_fileno(thisPtr->
m_handle), fileSize);
373 int rv = ftruncate(fileno(thisPtr->
m_handle), fileSize);
405 if (_wunlink(filenameW) != 0)
407 if (unlink(filename->m_data) != 0)
433 return (
XsFilePos) fread(destination, (
size_t) size, (
size_t) count, thisPtr->
m_handle);
445 return (
XsFilePos) fwrite(source, (
size_t) size, (
size_t) count, thisPtr->
m_handle);
475 return fgets(str, num, thisPtr->
m_handle);
523 return _ftelli64(thisPtr->
m_handle);
554 if (fullPath == NULL)
572 if (realpath(filename->m_data, fullpath) == NULL)
void XsString_destruct(XsString *thisPtr)
Clears and frees memory allocated by the XsArray.
XsSize XsString_copyToWCharArray(const XsString *thisPtr, wchar_t *dest, XsSize size)
This function copies the contents of the object to a unicode wchar_t array.
XsResultValue XsFile_flush(struct XsFile *thisPtr)
Writes unwritten data to the file.
@ XRV_NULLPTR
274: Tried to supply a NULL value where it is not allowed
int XsFile_getc(struct XsFile *thisPtr)
Gets and returns the next byte from a file.
XsResultValue XsFile_error(struct XsFile const *thisPtr)
XsResultValue XsFile_putc(struct XsFile *thisPtr, int character)
Writes a character to the file.
@ XRV_ENDOFFILE
270: End of file is reached
static FILE * openFile(const struct XsString *filename, const struct XsString *mode)
Helper for file opening.
XsResultValue XsFile_getline(struct XsFile *thisPtr, struct XsString *line)
Reads a full line from the file.
XsResultValue XsFile_seek_r(struct XsFile *thisPtr, XsFilePos offset)
Moves the current file position relative to the end of the file.
XsResultValue XsFile_resize(struct XsFile *thisPtr, XsFilePos fileSize)
Resizes the file to fileSize bytes.
int XsFile_exists(const struct XsString *filename)
Checks if the file exists (can be accessed)
@ XRV_NOTFOUND
262: The requested item was not found
@ XRV_ALREADYOPEN
269: An I/O device is already opened with this object
int XsFile_isOpen(const struct XsFile *thisPtr)
Checks if a file is open.
@ XRV_NOFILEOPEN
287: No file opened for reading/writing
@ XRV_ERROR
256: A generic error occurred
void XsFile_destruct(struct XsFile *thisPtr)
Frees the resources of this object by closing the file if it is open.
XsResultValue XsFile_truncate(struct XsFile *thisPtr, XsFilePos fileSize)
Reduces the file to a maximum size of fileSize bytes.
@ XRV_OK
0: Operation was performed successfully
XsResultValue
Xsens result values.
void XsString_assignWCharArray(XsString *thisPtr, const wchar_t *src)
This function determines the size of src and copies the contents to the object after converting it fr...
XsResultValue XsFile_puts(struct XsFile *thisPtr, const char *str)
Writes a null terminated c-string to the file.
@ XRV_ACCESSDENIED
51: Request for control of the device was denied
@ XRV_OUTOFMEMORY
261: No internal memory available
XsResultValue XsFile_reopen(struct XsFile *thisPtr, const struct XsString *filename, const struct XsString *mode)
Reopens a file.
void XsString_construct(XsString *thisPtr)
Initializes the XsString object as an empty string.
char * XsFile_gets(struct XsFile *thisPtr, char *str, int num)
Reads characters from this file and stores them into str until (num-1) characters have been read or e...
XsResultValue XsFile_open(struct XsFile *thisPtr, const struct XsString *filename, int readOnly)
Opens an existing binary file with name filename.
XsResultValue XsFile_create(struct XsFile *thisPtr, const struct XsString *filename, int writeOnly)
Creates a new binary file with name filename, contents of existing files will be discarded.
@ XRV_INPUTCANNOTBEOPENED
267: The specified i/o device can not be opened
XsResultValue XsFile_openText(struct XsFile *thisPtr, const struct XsString *filename, int readOnly)
Opens an existing binary file with name filename.
XsResultValue XsFile_close(struct XsFile *thisPtr)
Closes the file.
void XsArray_reserve(void *thisPtr, XsSize count)
Reserves space for count items.
void XsString_resize(XsString *thisPtr, XsSize count)
This function resizes the contained string to the desired size, while retaining its contents.
FILE * XsFile_handle(struct XsFile *thisPtr)
Encapsulates a file, providing a platform independent interface.
XsResultValue XsFile_seek(struct XsFile *thisPtr, XsFilePos offset)
Moves the current file position relative to the start of the file.
XsResultValue XsFile_erase(const struct XsString *filename)
Deletes a file with name filename.
XsResultValue XsFile_fullPath(const struct XsString *filename, struct XsString *fullPath)
Retrieves the full path for a filename.
@ XRV_OUTPUTCANNOTBEOPENED
268: The specified i/o device can not be opened
void XsString_push_back(XsString *thisPtr, char c)
Append character c to the string.
void XsString_assignCharArray(XsString *thisPtr, const char *src)
This function determines the size of src and copies the contents to the object.
@ XRV_READONLY
273: Tried to change a read-only value
XsFilePos XsFile_write(struct XsFile *thisPtr, const void *source, XsFilePos size, XsFilePos count)
Writes a number of elements to a file.
int XsFile_eof(struct XsFile const *thisPtr)
XsResultValue XsFile_createText(struct XsFile *thisPtr, const struct XsString *filename, int writeOnly)
Creates a new text file with name filename, contents of existing files will be discarded.
void XsString_assign(XsString *thisPtr, XsSize count, const char *src)
Reinitializes the XsArray with space for count items and copies them from src.
void XsString_erase(XsString *thisPtr, XsSize index, XsSize count)
Removes a count items from the list starting at index.
int64_t XsFilePos
The type that is used for positioning inside a file.
A 0-terminated managed string of characters.
XsFilePos XsFile_tell(struct XsFile const *thisPtr)
Returns the current position in the file.
@ XRV_BUSY
276: Busy processing, try again later
XsFilePos XsFile_read(struct XsFile *thisPtr, void *destination, XsFilePos size, XsFilePos count)
Reads a number of elements from a file.
#define XS_MAX_FILENAME_LENGTH
@ XRV_INVALIDPARAM
33: An invalid parameter is supplied