![]() |
m2mb API docs
30.00.005
m2mb API sets documentation
|
File system posix library implementation. More...
Go to the source code of this file.
Data Structures | |
struct | M2MB_STAT |
struct | M2MB_STATVFS |
struct | M2MB_DIRENT |
Typedefs | |
typedef struct M2MB_DIR_TAG | M2MB_DIR_T |
Functions | |
INT32 | m2mb_fs_open (const CHAR *path, INT32 oflag,...) |
Open file. More... | |
SSIZE_T | m2mb_fs_read (INT32 fd, void *buf, SIZE_T nbyte) |
Read file. More... | |
SSIZE_T | m2mb_fs_write (INT32 fd, const void *buf, SIZE_T nbyte) |
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_fstat (INT32 fd, struct M2MB_STAT *buf) |
File status. More... | |
INT32 | m2mb_fs_unlink (const CHAR *path) |
Delete file. More... | |
INT32 | m2mb_fs_truncate (const CHAR *path, OFF_T length) |
Truncate file. More... | |
INT32 | m2mb_fs_mkdir (const CHAR *path, MODE_T mode) |
Create directory. More... | |
INT32 | m2mb_fs_rmdir (const CHAR *path) |
Remove directory. More... | |
M2MB_DIR_T * | m2mb_fs_opendir (const CHAR *name) |
Open directory as stream. More... | |
struct M2MB_DIRENT * | m2mb_fs_readdir (M2MB_DIR_T *dirp) |
Read directory as stream. More... | |
INT32 | m2mb_fs_closedir (M2MB_DIR_T *dirp) |
Close directory as stream. More... | |
INT32 | m2mb_fs_statvfs (const CHAR *path, struct M2MB_STATVFS *buf) |
File system statistics. More... | |
File system posix library implementation.
m2m/m2m_common/m2mb_inc/m2mb_fs_posix.h
posix library for files. Not all the standard posix functions are available but only the most commonly used.
@notes Dependencies: m2m/m2m_common/m2mb_inc/m2mb_types.h
INT32 m2mb_fs_close | ( | INT32 | fd | ) |
Close file.
The function closes the file associated with the open file descriptor, fd.
[in] | fd | File descriptor. |
Example
INT32 m2mb_fs_closedir | ( | M2MB_DIR_T * | dirp | ) |
Close directory as stream.
The function closes the directory stream pointed to by dirp (writing any buffered output data) and closes the underlying file descriptor.
[in] | stream | Pointer to stream directory object. |
Example
INT32 m2mb_fs_fstat | ( | INT32 | fd, |
struct M2MB_STAT * | buf | ||
) |
File status.
The function gets status of the open file associated with the file descriptor fd, and writes it to the area pointed to by buf.
[in] | fd | File descriptor. |
[in] | buf | Pointer to a stat structure (see definition) to be filled with the stutus of the file. |
Example
OFF_T m2mb_fs_lseek | ( | INT32 | fd, |
OFF_T | offset, | ||
INT32 | whence | ||
) |
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. |
Example
INT32 m2mb_fs_mkdir | ( | const CHAR * | path, |
MODE_T | mode | ||
) |
Create directory.
The function creates a new directory with name path.
[in] | path | Name of directory to be created. |
[in] | ... | Mode for creating directory. It defines file permissions. See m2mb_fs_open for details. |
Example
INT32 m2mb_fs_open | ( | const CHAR * | path, |
INT32 | oflag, | ||
... | |||
) |
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. |
[in] | ... | Mode for opening file. It must be used only if oflag includes M2MB_O_CREAT. It defines file permissions. M2MB_S_IRUSR 0400 User has Read permission M2MB_S_IWUSR 0200 User has Write permission M2MB_S_IXUSR 0100 User has eXecute permission M2MB_S_IRWU 0700 M2MB_S_IRGRP 0040 Group has Read permission M2MB_S_IWGRP 0020 Group has Write permission M2MB_S_IXGRP 0010 Group has eXecute permission M2MB_S_IRWXG 0070 M2MB_S_IROTH 0004 Others has Read permission M2MB_S_IWOTH 0002 Others has Write permission M2MB_S_IXOTH 0001 Others has eXecutepermission M2MB_S_IRWXO 0007 M2MB_ACCESSPERMS 0777 M2MB_ALLPERMS 0777 |
Example
M2MB_DIR_T* m2mb_fs_opendir | ( | const CHAR * | name | ) |
Open directory as stream.
The function opens the directory whose name is the string pointed to by name, and and associates a stream with it. The stream is positioned at the first entry in the directory.
[in] | name | Name of directory to be open. |
Example
SSIZE_T m2mb_fs_read | ( | INT32 | fd, |
void * | buf, | ||
SIZE_T | nbyte | ||
) |
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. |
Example
struct M2MB_DIRENT* m2mb_fs_readdir | ( | M2MB_DIR_T * | dirp | ) |
Read directory as stream.
The function reads the next directory entry in the directory stream pointed to by dirp and returns corresponding information in a pointer to a dirent structure. It returns NULL on reaching the end of the directory stream
[in] | dirp | Pointer to stream directory object. |
Example
INT32 m2mb_fs_rmdir | ( | const CHAR * | path | ) |
Remove directory.
The function a directory whose name is given by path. The directory shall be removed only if it is an empty directory.
[in] | path | Name of directory to be removed. |
Example
INT32 m2mb_fs_stat | ( | const CHAR * | path, |
struct M2MB_STAT * | buf | ||
) |
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 stutus of the file. |
Example
INT32 m2mb_fs_statvfs | ( | const CHAR * | path, |
struct M2MB_STATVFS * | buf | ||
) |
File system statistics.
The function gets information about file system specified by the string pointed to by path, and writes it to the area pointed to by buf.
[in] | path | Pathname of any file within the mounted file system. |
[in] | buf | Pointer to a statvfs structure (see definition) to be filled with the information about file system. |
Example
INT32 m2mb_fs_truncate | ( | const CHAR * | path, |
OFF_T | length | ||
) |
Truncate file.
The function effect is that the regular file named by path will have a size which will be equal to length bytes.
[in] | path | Name of file to be truncated. |
[in] | length | New size of the file. |
Example
INT32 m2mb_fs_unlink | ( | const CHAR * | path | ) |
Delete file.
The function deletes the file whose name is the string pointed to by path.
[in] | path | Name of file to be deleted. |
Example
SSIZE_T m2mb_fs_write | ( | INT32 | fd, |
const void * | buf, | ||
SIZE_T | nbyte | ||
) |
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. |
Example