![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform various File system posix operations. More...
#define | M2MB_O_RDONLY 00 |
#define | M2MB_O_WRONLY 01 |
#define | M2MB_O_RDWR 02 |
#define | M2MB_O_CREAT 0100 |
#define | M2MB_O_EXCL 0200 |
#define | M2MB_O_TRUNC 01000 |
#define | M2MB_O_APPEND 02000 |
#define | M2MB_SEEK_SET 0 |
#define | M2MB_SEEK_CUR 1 |
#define | M2MB_SEEK_END 2 |
enum | M2MB_FR_E { M2MB_FR_ERROR = -1, M2MB_FR_OK = 0, M2MB_FR_DISK_ERR, M2MB_FR_INT_ERR, M2MB_FR_NOT_READY, M2MB_FR_NO_FILE, M2MB_FR_NO_PATH, M2MB_FR_INVALID_NAME, M2MB_FR_DENIED, M2MB_FR_EXIST, M2MB_FR_INVALID_OBJECT, M2MB_FR_WRITE_PROTECTED, M2MB_FR_INVALID_DRIVE, M2MB_FR_NOT_ENABLED, M2MB_FR_NO_FILESYSTEM, M2MB_FR_MKFS_ABORTED, M2MB_FR_TIMEOUT, M2MB_FR_LOCKED, M2MB_FR_NOT_ENOUGH_CORE, M2MB_FR_TOO_MANY_OPEN_FILES, M2MB_FR_INVALID_PARAMETER } |
typedef struct M2MB_STAT | M2MB_STAT_T |
typedef struct M2MB_LS_ENTRY | M2MB_LS_ENTRY_T |
M2MB_STATUS_T | m2mb_fs_init (VOID) |
File system initialization. More... | |
INT32 | m2mb_fs_open (const CHAR *path, INT32 oflag,...) |
Open file. More... | |
INT32 | m2mb_fs_secure_open (const CHAR *path, INT32 oflag, const char *pwd) |
Open secure file. More... | |
SSIZE_T | m2mb_fs_read (INT32 fd, void *buf, UINT32 nbyte) |
Read file. More... | |
SSIZE_T | m2mb_fs_write (INT32 fd, const void *buf, UINT32 nbyte) |
Write file. More... | |
SSIZE_T | m2mb_fs_length (INT32 fd) |
Write file. More... | |
INT32 | m2mb_fs_close (INT32 fd) |
Close file. More... | |
OFF_T | m2mb_fs_lseek (INT32 fd, OFF_T offset, INT32 whence) |
Move file offset. More... | |
INT32 | m2mb_fs_stat (const CHAR *path, struct M2MB_STAT *buf) |
File status. More... | |
INT32 | m2mb_fs_unlink (const CHAR *path) |
Delete file. More... | |
INT32 | m2mb_fs_ls_open (const char *path, HANDLE *handle) |
The function opens the folder whose name is the string pointed to by path. Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration. More... | |
INT32 | m2mb_fs_ls_next (HANDLE ls_hdl, struct M2MB_LS_ENTRY *ls_entry) |
Returns the next file system entry while listing. Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration. More... | |
INT32 | m2mb_fs_ls_close (HANDLE ls_hdl) |
File system ls close. More... | |
This section describes the M2MB APIs to perform various File system posix operations.
#define M2MB_O_APPEND 02000 |
File Append mode, the file offset shall be set to the end of the file prior to each write.
Definition at line 60 of file m2mb_fs_posix.h.
#define M2MB_O_CREAT 0100 |
File create mode
Definition at line 57 of file m2mb_fs_posix.h.
#define M2MB_O_EXCL 0200 |
Definition at line 58 of file m2mb_fs_posix.h.
#define M2MB_O_RDONLY 00 |
Read only mode
Definition at line 54 of file m2mb_fs_posix.h.
#define M2MB_O_RDWR 02 |
Read-write mode
Definition at line 56 of file m2mb_fs_posix.h.
#define M2MB_O_TRUNC 01000 |
File Truncate mode
Definition at line 59 of file m2mb_fs_posix.h.
#define M2MB_O_WRONLY 01 |
write only mode
Definition at line 55 of file m2mb_fs_posix.h.
#define M2MB_SEEK_CUR 1 |
Seek from current position
Definition at line 64 of file m2mb_fs_posix.h.
#define M2MB_SEEK_END 2 |
Seek from end of file
Definition at line 65 of file m2mb_fs_posix.h.
#define M2MB_SEEK_SET 0 |
Seek from beginning of file
Definition at line 63 of file m2mb_fs_posix.h.
typedef struct M2MB_LS_ENTRY M2MB_LS_ENTRY_T |
typedef struct M2MB_STAT M2MB_STAT_T |
enum M2MB_FR_E |
Definition at line 68 of file m2mb_fs_posix.h.
Close file.
The function closes the file associated with the open file descriptor, fd.
[in] | fd | File descriptor. |
m2mb_fs_close(fd);
M2MB_STATUS_T m2mb_fs_init | ( | VOID | ) |
File system initialization.
The function initialization File system.
Write file.
The function returns the length of the file associated with the open file descriptor, fd.
[in] | fd | File descriptor. |
m2mb_fs_length( fd );
File system ls close.
The function is called to close the ls functionality.
[in] | ls_hdl | File ls handle. |
m2mb_fs_ls_close( handle );
INT32 m2mb_fs_ls_next | ( | HANDLE | ls_hdl, |
struct M2MB_LS_ENTRY * | ls_entry | ||
) |
Returns the next file system entry while listing. Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration.
[in] | ls_hdl | Handle to the ls. |
[in] | ls_entry | Returns non NULL ls entry on success, or NULL for an error. |
struct M2MB_LS_ENTRY { char file_path[100]; struct M2MB_STAT sbuf; }; struct M2MB_STAT { DEV_T st_dev; UINT32 st_ino; UINT32 st_size; UINT32 st_blksize; UINT32 st_blocks; }; st_dev : Unique Device ID st_ino : INode number associated with the file. st_size : File size in bytes. st_blksize : Block size, smallest allocation unit of the file system. Unit in which block count is represented. st_blocks : Number of blocks allocated for this file in st_blksize units.
m2mb_fs_ls_next( handle, &ls_entry );
The function opens the folder whose name is the string pointed to by path.
Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration.
[in] | path | path of the file system to iterate. |
[in] | handle | Returns non NULL iterator handle on success, or NULL for an error. |
m2mb_fs_ls_open( file_path, &handle ));
Move file offset.
The function sets the file offset for the open file description associated with the file descriptor fd. The new offset, measured in bytes, is obtained by adding offset bytes to the position specified by whence.
[in] | fd | File descriptor. |
[in] | offset | Number of bytes to move the file offset 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_lseek( fd, 0, M2MB_SEEK_END );
Open file.
The function opens the file whose name is the string pointed to by path.
[in] | path | Name of file to be open. |
[in] | oflag | Flags for opening file. One of the following three flags must be used: M2MB_O_RDONLY Open for reading only. M2MB_O_WRONLY Open for writing only. M2MB_O_RDWR Open for reading and writing. In addition any of the following flags may be bitwise ORed: M2MB_O_APPEND If set, the file offset shall be set to the end of the file prior to each write. M2MB_O_CREAT If the file exists, this flag has no effect except as noted under M2MB_O_EXCL below. Otherwise, the file shall be created. M2MB_O_EXCL If M2MB_O_CREAT and M2MB_O_EXCL are set, open fails if the file exists. M2MB_O_TRUNC If the file exists and is a regular file, and the file is successfully opened with M2MB_O_RDWR or M2MB_O_WRONLY, its length is truncated to 0, and the mode is unchanged. |
m2mb_fs_open( M2MB_PROV_FILE_CUST_JS_PATH, 0 );
Read file.
The function reads nbyte bytes from the file associated with the open file descriptor, fd, into the buffer pointed to by buf.
[in] | fd | File descriptor. |
[out] | buf | Buffer to fill with read data. |
[in] | nbyte | Number of bytes to read. |
m2mb_fs_read( fd, data, len );
Open secure file.
The function opens the file in secured mode, whose name is the string pointed to by path.
[in] | path | Name of file to be open. |
[in] | oflag | Flags for opening files. One of the following three flags must be used: M2MB_O_RDONLY Open for reading only. M2MB_O_WRONLY Open for writing only. M2MB_O_RDWR Open for reading and writing. In addition, any of the following flags may be bitwise ORed: M2MB_O_APPEND If set, the file offset shall be set to the end of the file prior to each write. M2MB_O_CREAT If the file exists, this flag has no effect except as noted under M2MB_O_EXCL below. Otherwise, the file shall be created. M2MB_O_EXCL If M2MB_O_CREAT and M2MB_O_EXCL are set, open fails if the file exists. M2MB_O_TRUNC If the file exists and is a regular file, and the file is successfully opened with M2MB_O_RDWR or M2MB_O_WRONLY, its length is truncated to 0, and the mode is unchanged. |
[in] | pwd | Password of the file to be opened. The password must of be 16 bytes length |
m2mb_fs_secure_open( file_name,M2MB_O_RDONLY, profile_pwd );
File status.
The function gets status of the file whose name is the string pointed to by path, and writes it to the area pointed to by buf.
[in] | path | Name of file. |
[in] | buf | Pointer to a stat structure (see definition) to be filled with the status of the file. |
m2mb_fs_stat( M2MB_PROV_FILE_CUST_JS_PATH, &stat );
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_unlink( file_name );
Write file.
The function writes nbyte bytes from the buffer pointed to by buf to the file associated with the open file descriptor, fd.
[in] | fd | File descriptor. |
[in] | buf | Buffer containing data to be written. |
[in] | nbyte | Number of bytes to write. |
m2mb_fs_write( fd, (UINT8*)buffer, (UINT32)length );