![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform various File system stdio operations. More...
#define | NULL 0 |
#define | M2MB_SEEK_SET 0 |
#define | M2MB_SEEK_CUR 1 |
#define | M2MB_SEEK_END 2 |
typedef struct M2MB_FILE_TAG | M2MB_FILE_T |
M2MB_FILE_T * | m2mb_fs_fopen (const CHAR *path, const CHAR *mode) |
Opens file as stream. More... | |
SIZE_T | m2mb_fs_fread (void *ptr, SIZE_T size, SIZE_T nitems, M2MB_FILE_T *stream) |
Read file as stream. More... | |
SIZE_T | m2mb_fs_fwrite (void *ptr, SIZE_T size, SIZE_T nitems, M2MB_FILE_T *stream) |
Write file as stream. More... | |
INT32 | m2mb_fs_fclose (M2MB_FILE_T *stream) |
Close file as stream. More... | |
INT32 | m2mb_fs_fseek (M2MB_FILE_T *stream, INT32 offset, INT32 whence) |
Move file position indicator. More... | |
INT32 | m2mb_fs_ftell (M2MB_FILE_T *stream) |
Get file position indicator. More... | |
INT32 | m2mb_fs_fgetc (M2MB_FILE_T *stream) |
Read char from file as stream. More... | |
CHAR * | m2mb_fs_fgets (CHAR *s, INT32 size, M2MB_FILE_T *stream) |
Read line string from file as stream. More... | |
INT32 | m2mb_fs_fputc (INT32 c, M2MB_FILE_T *stream) |
Write char to file as stream. More... | |
INT32 | m2mb_fs_fputs (const CHAR *s, M2MB_FILE_T *stream) |
Write string to file as stream. More... | |
INT32 | m2mb_fs_remove (const CHAR *path) |
Delete file. More... | |
INT32 | m2mb_fs_rename (const CHAR *oldpath, const CHAR *newpath) |
Rename file or directory. More... | |
This section describes the M2MB APIs to perform various File system stdio operations.
#define M2MB_SEEK_CUR 1 |
Seek from current position.
Definition at line 53 of file m2mb_fs_stdio.h.
#define M2MB_SEEK_END 2 |
Seek from end of file.
Definition at line 54 of file m2mb_fs_stdio.h.
#define M2MB_SEEK_SET 0 |
Seek from beginning of file.
Definition at line 52 of file m2mb_fs_stdio.h.
#define NULL 0 |
Definition at line 47 of file m2mb_fs_stdio.h.
typedef struct M2MB_FILE_TAG M2MB_FILE_T |
Definition at line 59 of file m2mb_fs_stdio.h.
INT32 m2mb_fs_fclose | ( | M2MB_FILE_T * | stream | ) |
Close file as stream.
The function flushes the stream pointed to by stream (writing any buffered output data) and closes the underlying file descriptor.
[in] | stream | Pointer to stream file object. |
m2mb_fs_fclose(file_fd);
INT32 m2mb_fs_fgetc | ( | M2MB_FILE_T * | stream | ) |
Read char from file as stream.
The function reads the next character from the stream pointed to by stream.
[in] | stream | Pointer to stream file object. |
m2mb_fs_fgetc(file_fd);
CHAR* m2mb_fs_fgets | ( | CHAR * | s, |
INT32 | size, | ||
M2MB_FILE_T * | stream | ||
) |
Read line string from file as stream.
The function reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an end of file or a newline. If a newline is read, it is stored into the buffer. A terminating null byte ('\0') is stored after the last character in the buffer.
[out] | s | Buffer to fill with read data. |
[in] | size | Size of buffer s. One more than the max number of characters to be read. |
[in] | stream | Pointer to stream file object. |
m2mb_fs_fgets(str,80,fp);
M2MB_FILE_T* m2mb_fs_fopen | ( | const CHAR * | path, |
const CHAR * | mode | ||
) |
Opens file as stream.
The function opens the file whose name is the string pointed to by path and associates a stream with it.
[in] | path | Name of file to be open. |
[in] | mode | Mode for opening file. r Open text file for reading. The stream is positioned at the beginning of the file. r+ Open for reading and writing. The stream is positioned at the beginning of the file. w Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. w+ Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file. a Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file. a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file. The mode string can also include the letter 'b' either as a last character or as a character between the characters in any of the two-character strings described above. The 'b' is ignored. |
m2mb_fs_fopen( M2MB_PROV_FILE_CUST_JS_PATH, r+ );
INT32 m2mb_fs_fputc | ( | INT32 | c, |
M2MB_FILE_T * | stream | ||
) |
Write char to file as stream.
The function writes the character c, cast to an unsigned char, to the stream pointed to by stream.
[in] | c | Character to be written. |
[in] | stream | Pointer to stream file object. |
m2mb_fs_fputc(string[i], file_fd);
INT32 m2mb_fs_fputs | ( | const CHAR * | s, |
M2MB_FILE_T * | stream | ||
) |
Write string to file as stream.
The function writes the string s to stream, without its terminating null byte ('\0').
[in] | s | Null byte terminated string to be written. |
[in] | stream | Pointer to stream file object. |
m2mb_fs_fputs(string,file_fd);
SIZE_T m2mb_fs_fread | ( | void * | ptr, |
SIZE_T | size, | ||
SIZE_T | nitems, | ||
M2MB_FILE_T * | stream | ||
) |
Read file as stream.
The function reads nitems elements of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr.
[out] | ptr | Buffer to fill with read data. |
[in] | size | Size in bytes of each item. |
[in] | nitems | Number of items to read. |
[in] | stream | Pointer to stream file object. |
m2mb_fs_fread(&Stu,sizeof(Stu),1,file_fd)
INT32 m2mb_fs_fseek | ( | M2MB_FILE_T * | stream, |
INT32 | offset, | ||
INT32 | whence | ||
) |
Move file position indicator.
The function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence.
[in] | stream | Pointer to stream file object. |
[in] | offset | Number of bytes to move the file position indicator from the position specified by whence. |
[in] | whence | File position. M2MB_SEEK_SET Beginning of the file. M2MB_SEEK_CUR Current file position. M2MB_SEEK_END End of file. |
m2mb_fs_fseek(file_fd, 0, M2MB_SEEK_END);
INT32 m2mb_fs_ftell | ( | M2MB_FILE_T * | stream | ) |
Get file position indicator.
The function obtains the current value of the file position indicator for the stream pointed to by stream.
[in] | stream | Pointer to stream file object. |
m2mb_fs_ftell(file_fd);
SIZE_T m2mb_fs_fwrite | ( | void * | ptr, |
SIZE_T | size, | ||
SIZE_T | nitems, | ||
M2MB_FILE_T * | stream | ||
) |
Write file as stream.
The function writes nitems elements of data, each size bytes long, to the stream pointed to by stream, obtaining them from the location given by ptr.
[in] | ptr | Buffer containing data to be written. |
[in] | size | Size in bytes of each item. |
[in] | nitems | Number of items to write. |
[in] | stream | Pointer to stream file object. |
m2mb_fs_fwrite(&Stu,sizeof(Stu),1,file_fd);
Delete file.
The function deletes the file whose name is the string pointed to by path.
[in] | path | Name of file to be deleted. |
m2mb_fs_remove(M2MB_PROV_FILE_CUST_JS_PATH);
Rename file or directory.
The function changes the name of a file or a directory. The old argument points to the pathname of the file to be renamed. The new argument points to the new pathname of the file.
[in] | oldpath | Name of file to be renamed. |
[in] | newpath | Name of new file. |
m2mb_fs_rename( M2MB_PROV_FILE_CUST_JS_PATH,M2MB_PROV_FILE_NEW__PATH);