xsfile.c
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #include "xsfile.h"
66 #include "xsstring.h"
67 #include <errno.h>
68 #ifndef _WIN32
69  #include <unistd.h> // close
70  #include <sys/ioctl.h> // ioctl
71  #include <fcntl.h> // open, O_RDWR
72  #include <string.h> // strcpy
73  #include <sys/param.h>
74  #include <sys/stat.h>
75  #include <stdarg.h>
76  #include <stdlib.h>
77 #else
78  #include <winbase.h>
79  #include <sys/stat.h>
80  #include <io.h>
81 #endif
82 
83 // helper
84 static FILE* openFile(const struct XsString* filename, const struct XsString* mode);
85 
97 void XsFile_destruct(struct XsFile* thisPtr)
98 {
99  if (thisPtr->m_handle != NULL)
100  (void)XsFile_close(thisPtr);
101 }
102 
109 XsResultValue XsFile_create(struct XsFile* thisPtr, const struct XsString* filename, int writeOnly)
110 {
111  XsString mode;
112  XsString_construct(&mode);
113  XsString_resize(&mode, 16);
114 
115  if (thisPtr->m_handle != NULL)
116  return XRV_ALREADYOPEN;
117 
118 #ifdef _WIN32
119  wchar_t filenameW[XS_MAX_FILENAME_LENGTH];
120  // actively delete the file first to ensure that the file creation time is properly set
122  (void) _wunlink(filenameW); // don't care about return value
123 #else
124  unlink(filename->m_data);
125 #endif
126 
127  if (writeOnly)
128  {
129  XsString_assign(&mode, 3, "wb");
130  thisPtr->m_handle = openFile(filename, &mode);
131  }
132  else
133  {
134  XsString_assign(&mode, 4, "w+b");
135  thisPtr->m_handle = openFile(filename, &mode);
136  }
137 
138  XsString_destruct(&mode);
139  if (thisPtr->m_handle == NULL)
141  else
142  return XRV_OK;
143 }
144 
151 XsResultValue XsFile_createText(struct XsFile* thisPtr, const struct XsString* filename, int writeOnly)
152 {
153  XsString mode;
154  XsString_construct(&mode);
155  XsString_resize(&mode, 16);
156 
157  if (thisPtr->m_handle != NULL)
158  return XRV_ALREADYOPEN;
159 
160  if (writeOnly)
161  {
162  XsString_assign(&mode, 3, "wt");
163  thisPtr->m_handle = openFile(filename, &mode);
164  }
165  else
166  {
167  XsString_assign(&mode, 4, "w+t");
168  thisPtr->m_handle = openFile(filename, &mode);
169  }
170 
171  XsString_destruct(&mode);
172  if (thisPtr->m_handle == NULL)
174  else
175  return XRV_OK;
176 }
177 
184 XsResultValue XsFile_open(struct XsFile* thisPtr, const struct XsString* filename, int readOnly)
185 {
186  XsString mode;
187  XsString_construct(&mode);
188  XsString_resize(&mode, 16);
189 
190  if (thisPtr->m_handle != NULL)
191  return XRV_ALREADYOPEN;
192 
193  if (readOnly)
194  XsString_assign(&mode, 3, "rb");
195  else
196  XsString_assign(&mode, 4, "r+b");
197  thisPtr->m_handle = openFile(filename, &mode);
198 
199  XsString_destruct(&mode);
200  if (thisPtr->m_handle == NULL)
201  {
202  if (readOnly)
204  else
206  }
207  else
208  return XRV_OK;
209 }
210 
217 XsResultValue XsFile_openText(struct XsFile* thisPtr, const struct XsString* filename, int readOnly)
218 {
219  XsString mode;
220  XsString_construct(&mode);
221  XsString_resize(&mode, 16);
222 
223  if (thisPtr->m_handle != NULL)
224  return XRV_ALREADYOPEN;
225 
226  if (readOnly)
227  {
228  XsString_assign(&mode, 3, "rt");
229  thisPtr->m_handle = openFile(filename, &mode);
230  }
231  else
232  {
233  XsString_assign(&mode, 4, "r+t");
234  thisPtr->m_handle = openFile(filename, &mode);
235  }
236 
237  XsString_destruct(&mode);
238  if (thisPtr->m_handle == NULL)
240  else
241  return XRV_OK;
242 }
243 
245 static FILE* openFile(const struct XsString* filename, const struct XsString* mode)
246 {
247 #ifdef _WIN32
248  wchar_t filenameW[XS_MAX_FILENAME_LENGTH];
249  wchar_t modeW[16];
250  (void)XsString_copyToWCharArray(filename, filenameW, XS_MAX_FILENAME_LENGTH);
251  (void)XsString_copyToWCharArray(mode, modeW, 16);
252 
253  __try
254  {
255  return _wfopen(filenameW, modeW);
256  }
257  __except (EXCEPTION_EXECUTE_HANDLER)
258  {
259  return NULL;
260  }
261 #else
262  return fopen(filename->m_data, mode->m_data);
263 #endif
264 }
265 
272 XsResultValue XsFile_reopen(struct XsFile* thisPtr, const struct XsString* filename, const struct XsString* mode)
273 {
274 #ifdef _WIN32
275  wchar_t filenameW[XS_MAX_FILENAME_LENGTH];
276  wchar_t modeW[16];
277 
278  (void)XsString_copyToWCharArray(filename, filenameW, XS_MAX_FILENAME_LENGTH);
279  (void)XsString_copyToWCharArray(mode, modeW, 16);
280 
281  thisPtr->m_handle = _wfreopen(filenameW, modeW, thisPtr->m_handle);
282 #else
283  thisPtr->m_handle = freopen(filename->m_data, mode->m_data, thisPtr->m_handle);
284 #endif
285 
286  if (thisPtr->m_handle == NULL)
288  else
289  return XRV_OK;
290 }
291 
296 int XsFile_isOpen(const struct XsFile* thisPtr)
297 {
298  return (thisPtr->m_handle != NULL) ? 0 : 1;
299 }
300 
306 int XsFile_exists(const struct XsString* filename)
307 {
308 #ifdef _WIN32
309  wchar_t filenameW[XS_MAX_FILENAME_LENGTH];
310  struct _stat buffer;
311  (void)XsString_copyToWCharArray(filename, filenameW, XS_MAX_FILENAME_LENGTH);
312  return _wstat(filenameW, &buffer);
313 #else
314  struct stat buffer;
315  return stat(filename->m_data, &buffer);
316 #endif
317 }
318 
324 {
325  int rv;
326 
327  if (thisPtr->m_handle == NULL)
328  return XRV_NOFILEOPEN;
329 
330  fflush(thisPtr->m_handle); // always try to flush first, result is irrelevant
331  rv = fclose(thisPtr->m_handle);
332 
333  // Or keep the handle in case of failure?
334  thisPtr->m_handle = NULL;
335 
336  if (rv == EOF)
337  return XRV_ENDOFFILE;
338  else
339  return XRV_OK;
340 }
341 
342 
349 {
350  return fflush(thisPtr->m_handle) ? XRV_ERROR : XRV_OK;
351 }
352 
358 XsResultValue XsFile_truncate(struct XsFile* thisPtr, XsFilePos fileSize)
359 {
360  return XsFile_resize(thisPtr, fileSize);
361 }
362 
368 XsResultValue XsFile_resize(struct XsFile* thisPtr, XsFilePos fileSize)
369 {
370 #ifdef _WIN32
371  int rv = _chsize_s(_fileno(thisPtr->m_handle), fileSize);
372 #else
373  int rv = ftruncate(fileno(thisPtr->m_handle), fileSize);
374 #endif
375  if (rv != 0)
376  {
377  switch (errno)
378  {
379  case EACCES:
380  return XRV_BUSY;
381  case EBADF:
382  return XRV_ACCESSDENIED;
383  case ENOSPC:
384  return XRV_OUTOFMEMORY;
385  case EINVAL:
386  return XRV_INVALIDPARAM;
387  default:
388  return XRV_ERROR;
389  }
390  }
391  else
392  return XRV_OK;
393 }
394 
400 XsResultValue XsFile_erase(const struct XsString* filename)
401 {
402 #ifdef _WIN32
403  wchar_t filenameW[XS_MAX_FILENAME_LENGTH];
404  (void)XsString_copyToWCharArray(filename, filenameW, XS_MAX_FILENAME_LENGTH);
405  if (_wunlink(filenameW) != 0)
406 #else
407  if (unlink(filename->m_data) != 0)
408 #endif
409  {
410  switch (errno)
411  {
412  case EACCES:
413  return XRV_READONLY;
414  case ENOENT:
415  return XRV_NOTFOUND;
416  default:
417  return XRV_ERROR;
418  }
419  }
420  else
421  return XRV_OK;
422 }
423 
431 XsFilePos XsFile_read(struct XsFile* thisPtr, void* destination, XsFilePos size, XsFilePos count)
432 {
433  return (XsFilePos) fread(destination, (size_t) size, (size_t) count, thisPtr->m_handle);
434 }
435 
443 XsFilePos XsFile_write(struct XsFile* thisPtr, const void* source, XsFilePos size, XsFilePos count)
444 {
445  return (XsFilePos) fwrite(source, (size_t) size, (size_t) count, thisPtr->m_handle);
446 }
447 
452 int XsFile_getc(struct XsFile* thisPtr)
453 {
454  return fgetc(thisPtr->m_handle);
455 }
456 
462 XsResultValue XsFile_putc(struct XsFile* thisPtr, int character)
463 {
464  return fputc(character, thisPtr->m_handle) == EOF ? XRV_ERROR : XRV_OK;
465 }
466 
473 char* XsFile_gets(struct XsFile* thisPtr, char* str, int num)
474 {
475  return fgets(str, num, thisPtr->m_handle);
476 }
477 
483 XsResultValue XsFile_puts(struct XsFile* thisPtr, const char* str)
484 {
485  return fputs(str, thisPtr->m_handle) != EOF ? XRV_OK : XRV_ERROR;
486 }
487 
493 XsResultValue XsFile_seek(struct XsFile* thisPtr, XsFilePos offset)
494 {
495 #ifdef _WIN32
496  return _fseeki64(thisPtr->m_handle, offset, SEEK_SET) ? XRV_ERROR : XRV_OK;
497 #else
498  return fseeko(thisPtr->m_handle, offset, SEEK_SET) ? XRV_ERROR : XRV_OK;
499 #endif
500 }
501 
507 XsResultValue XsFile_seek_r(struct XsFile* thisPtr, XsFilePos offset)
508 {
509 #ifdef _WIN32
510  return _fseeki64(thisPtr->m_handle, offset, SEEK_END) ? XRV_ERROR : XRV_OK;
511 #else
512  return fseeko(thisPtr->m_handle, offset, SEEK_END) ? XRV_ERROR : XRV_OK;
513 #endif
514 }
515 
520 XsFilePos XsFile_tell(struct XsFile const* thisPtr)
521 {
522 #ifdef _WIN32
523  return _ftelli64(thisPtr->m_handle);
524 #else
525  return ftello(thisPtr->m_handle);
526 #endif
527 }
528 
532 int XsFile_eof(struct XsFile const* thisPtr)
533 {
534  return feof(thisPtr->m_handle);
535 }
536 
540 XsResultValue XsFile_error(struct XsFile const* thisPtr)
541 {
542  return ferror(thisPtr->m_handle) ? XRV_ERROR : XRV_OK;
543 }
544 
551 XsResultValue XsFile_fullPath(const struct XsString* filename, struct XsString* fullPath)
552 {
553  XsResultValue result = XRV_OK;
554  if (fullPath == NULL)
555  result = XRV_NULLPTR;
556  else
557  {
558 #ifdef _WIN32
559  wchar_t filenamew[XS_MAX_FILENAME_LENGTH];
560  wchar_t fullpath[XS_MAX_FILENAME_LENGTH];
561  (void)XsString_copyToWCharArray(filename, filenamew, XS_MAX_FILENAME_LENGTH);
562 
563  if (_wfullpath(fullpath, filenamew, XS_MAX_FILENAME_LENGTH) == NULL)
564  result = XRV_ERROR;
565  else
566  XsString_assignWCharArray(fullPath, fullpath);
567 #else
568  // based on the assumption that this doesn't concern the serial port, handle
569  // it the same way using realpath(). Apparently realpath() doesn't require a
570  // maximum length. One would possibly want to write a wrapper for it.
571  char fullpath[XS_MAX_FILENAME_LENGTH * 2];
572  if (realpath(filename->m_data, fullpath) == NULL)
573  result = XRV_ERROR;
574  else
575  XsString_assignCharArray(fullPath, fullpath);
576 #endif
577  }
578  return result;
579 }
580 
586 XsResultValue XsFile_getline(struct XsFile* thisPtr, struct XsString* line)
587 {
588  int b;
590 
591  XsString_erase(line, 0, line->m_size);
592  XsArray_reserve(line, 256);
593 
594  b = fgetc(thisPtr->m_handle);
595  if (b != -1)
596  ok = XRV_OK;
597 
598  while (b != -1)
599  {
600  XsString_push_back(line, (char)b);
601  if (b == '\n')
602  break;
603  b = fgetc(thisPtr->m_handle);
604  }
605  return ok;
606 }
607 
611 FILE* XsFile_handle(struct XsFile* thisPtr)
612 {
613  return thisPtr->m_handle;
614 }
615 
xsstring.h
XsString_destruct
void XsString_destruct(XsString *thisPtr)
Clears and frees memory allocated by the XsArray.
Definition: xsstring.c:134
XsString_copyToWCharArray
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.
Definition: xsstring.c:215
XsFile::m_handle
FILE * m_handle
Definition: xsfile.h:323
XsFile::XsFile_flush
XsResultValue XsFile_flush(struct XsFile *thisPtr)
Writes unwritten data to the file.
Definition: xsfile.c:348
XRV_NULLPTR
@ XRV_NULLPTR
274: Tried to supply a NULL value where it is not allowed
Definition: xsresultvalue.h:144
io.h
xsfile.h
XsFile::XsFile_getc
int XsFile_getc(struct XsFile *thisPtr)
Gets and returns the next byte from a file.
Definition: xsfile.c:452
XsFile::XsFile_error
XsResultValue XsFile_error(struct XsFile const *thisPtr)
Definition: xsfile.c:540
XsFile::XsFile_putc
XsResultValue XsFile_putc(struct XsFile *thisPtr, int character)
Writes a character to the file.
Definition: xsfile.c:462
XRV_ENDOFFILE
@ XRV_ENDOFFILE
270: End of file is reached
Definition: xsresultvalue.h:140
openFile
static FILE * openFile(const struct XsString *filename, const struct XsString *mode)
Helper for file opening.
Definition: xsfile.c:245
XsFile::XsFile_getline
XsResultValue XsFile_getline(struct XsFile *thisPtr, struct XsString *line)
Reads a full line from the file.
Definition: xsfile.c:586
XsFile::XsFile_seek_r
XsResultValue XsFile_seek_r(struct XsFile *thisPtr, XsFilePos offset)
Moves the current file position relative to the end of the file.
Definition: xsfile.c:507
XsFile::XsFile_resize
XsResultValue XsFile_resize(struct XsFile *thisPtr, XsFilePos fileSize)
Resizes the file to fileSize bytes.
Definition: xsfile.c:368
XsFile::XsFile_exists
int XsFile_exists(const struct XsString *filename)
Checks if the file exists (can be accessed)
Definition: xsfile.c:306
XRV_NOTFOUND
@ XRV_NOTFOUND
262: The requested item was not found
Definition: xsresultvalue.h:132
XRV_ALREADYOPEN
@ XRV_ALREADYOPEN
269: An I/O device is already opened with this object
Definition: xsresultvalue.h:139
XsFile::XsFile_isOpen
int XsFile_isOpen(const struct XsFile *thisPtr)
Checks if a file is open.
Definition: xsfile.c:296
XRV_NOFILEOPEN
@ XRV_NOFILEOPEN
287: No file opened for reading/writing
Definition: xsresultvalue.h:158
XRV_ERROR
@ XRV_ERROR
256: A generic error occurred
Definition: xsresultvalue.h:126
XsFile::XsFile_destruct
void XsFile_destruct(struct XsFile *thisPtr)
Frees the resources of this object by closing the file if it is open.
Definition: xsfile.c:97
ok
ROSCPP_DECL bool ok()
XsFile::XsFile_truncate
XsResultValue XsFile_truncate(struct XsFile *thisPtr, XsFilePos fileSize)
Reduces the file to a maximum size of fileSize bytes.
Definition: xsfile.c:358
XRV_OK
@ XRV_OK
0: Operation was performed successfully
Definition: xsresultvalue.h:85
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:82
XsString_assignWCharArray
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...
Definition: xsstring.c:181
XsFile::XsFile_puts
XsResultValue XsFile_puts(struct XsFile *thisPtr, const char *str)
Writes a null terminated c-string to the file.
Definition: xsfile.c:483
XRV_ACCESSDENIED
@ XRV_ACCESSDENIED
51: Request for control of the device was denied
Definition: xsresultvalue.h:120
XRV_OUTOFMEMORY
@ XRV_OUTOFMEMORY
261: No internal memory available
Definition: xsresultvalue.h:131
XsFile::XsFile_reopen
XsResultValue XsFile_reopen(struct XsFile *thisPtr, const struct XsString *filename, const struct XsString *mode)
Reopens a file.
Definition: xsfile.c:272
XsString_construct
void XsString_construct(XsString *thisPtr)
Initializes the XsString object as an empty string.
Definition: xsstring.c:126
XsFile::XsFile_gets
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...
Definition: xsfile.c:473
XsFile::XsFile_open
XsResultValue XsFile_open(struct XsFile *thisPtr, const struct XsString *filename, int readOnly)
Opens an existing binary file with name filename.
Definition: xsfile.c:184
XsFile::XsFile_create
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.
Definition: xsfile.c:109
XRV_INPUTCANNOTBEOPENED
@ XRV_INPUTCANNOTBEOPENED
267: The specified i/o device can not be opened
Definition: xsresultvalue.h:137
XsFile::XsFile_openText
XsResultValue XsFile_openText(struct XsFile *thisPtr, const struct XsString *filename, int readOnly)
Opens an existing binary file with name filename.
Definition: xsfile.c:217
XsFile::XsFile_close
XsResultValue XsFile_close(struct XsFile *thisPtr)
Closes the file.
Definition: xsfile.c:323
XsArray::XsArray_reserve
void XsArray_reserve(void *thisPtr, XsSize count)
Reserves space for count items.
Definition: xsarray.c:256
XsString_resize
void XsString_resize(XsString *thisPtr, XsSize count)
This function resizes the contained string to the desired size, while retaining its contents.
Definition: xsstring.c:243
XsFile::XsFile_handle
FILE * XsFile_handle(struct XsFile *thisPtr)
Definition: xsfile.c:611
XsFile
Encapsulates a file, providing a platform independent interface.
Definition: xsfile.h:131
XsFile::XsFile_seek
XsResultValue XsFile_seek(struct XsFile *thisPtr, XsFilePos offset)
Moves the current file position relative to the start of the file.
Definition: xsfile.c:493
XsFile::XsFile_erase
XsResultValue XsFile_erase(const struct XsString *filename)
Deletes a file with name filename.
Definition: xsfile.c:400
XsFile::XsFile_fullPath
XsResultValue XsFile_fullPath(const struct XsString *filename, struct XsString *fullPath)
Retrieves the full path for a filename.
Definition: xsfile.c:551
XRV_OUTPUTCANNOTBEOPENED
@ XRV_OUTPUTCANNOTBEOPENED
268: The specified i/o device can not be opened
Definition: xsresultvalue.h:138
XsString_push_back
void XsString_push_back(XsString *thisPtr, char c)
Append character c to the string.
Definition: xsstring.c:292
XsString_assignCharArray
void XsString_assignCharArray(XsString *thisPtr, const char *src)
This function determines the size of src and copies the contents to the object.
Definition: xsstring.c:172
XRV_READONLY
@ XRV_READONLY
273: Tried to change a read-only value
Definition: xsresultvalue.h:143
XsFile::XsFile_write
XsFilePos XsFile_write(struct XsFile *thisPtr, const void *source, XsFilePos size, XsFilePos count)
Writes a number of elements to a file.
Definition: xsfile.c:443
XsFile::XsFile_eof
int XsFile_eof(struct XsFile const *thisPtr)
Definition: xsfile.c:532
XsFile::XsFile_createText
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.
Definition: xsfile.c:151
XsString_assign
void XsString_assign(XsString *thisPtr, XsSize count, const char *src)
Reinitializes the XsArray with space for count items and copies them from src.
Definition: xsstring.c:142
XsString_erase
void XsString_erase(XsString *thisPtr, XsSize index, XsSize count)
Removes a count items from the list starting at index.
Definition: xsstring.c:276
XsFilePos
int64_t XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:102
XsString
A 0-terminated managed string of characters.
XsFile::XsFile_tell
XsFilePos XsFile_tell(struct XsFile const *thisPtr)
Returns the current position in the file.
Definition: xsfile.c:520
XRV_BUSY
@ XRV_BUSY
276: Busy processing, try again later
Definition: xsresultvalue.h:146
XsFile::XsFile_read
XsFilePos XsFile_read(struct XsFile *thisPtr, void *destination, XsFilePos size, XsFilePos count)
Reads a number of elements from a file.
Definition: xsfile.c:431
XS_MAX_FILENAME_LENGTH
#define XS_MAX_FILENAME_LENGTH
Definition: xsfile.h:78
XRV_INVALIDPARAM
@ XRV_INVALIDPARAM
33: An invalid parameter is supplied
Definition: xsresultvalue.h:105


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20