This section describes the file structure of MSG (msg_file_t) and the functions for managing it. It is based on POSIX functions.
More...
Typedefs |
typedef struct msg_file * | msg_file_t |
| File datatype.You should consider this as an opaque object.
|
Functions |
size_t | MSG_file_read (const char *storage, void *ptr, size_t size, size_t nmemb, msg_file_t stream) |
| Read elements of a file.
|
size_t | MSG_file_write (const char *storage, const void *ptr, size_t size, size_t nmemb, msg_file_t stream) |
| Write elements into a file.
|
msg_file_t | MSG_file_open (const char *storage, const char *path, const char *mode) |
| Opens the file whose name is the string pointed to by path.
|
int | MSG_file_close (const char *storage, msg_file_t fp) |
| Close the file.
|
int | MSG_file_stat (const char *storage, msg_file_t fd, s_msg_stat_t *buf) |
| Stats the file pointed by fd.
|
Detailed Description
This section describes the file structure of MSG (msg_file_t) and the functions for managing it. It is based on POSIX functions.
(
msg_file_t) and the functions for managing it.
- See also:
- msg_file_t
Function Documentation
size_t MSG_file_read |
( |
const char * |
storage, |
|
|
void * |
ptr, |
|
|
size_t |
size, |
|
|
size_t |
nmemb, |
|
|
msg_file_t |
stream |
|
) |
| |
Read elements of a file.
- Parameters:
-
storage | is the name where find the stream |
ptr | buffer to where the data is copied |
size | of each element |
nmemb | is the number of elements of data to read |
stream | to read |
- Returns:
- the number of items successfully read
size_t MSG_file_write |
( |
const char * |
storage, |
|
|
const void * |
ptr, |
|
|
size_t |
size, |
|
|
size_t |
nmemb, |
|
|
msg_file_t |
stream |
|
) |
| |
Write elements into a file.
- Parameters:
-
storage | is the name where find the stream |
ptr | buffer from where the data is copied |
size | of each element |
nmemb | is the number of elements of data to write |
stream | to write |
- Returns:
- the number of items successfully write
msg_file_t MSG_file_open |
( |
const char * |
storage, |
|
|
const char * |
path, |
|
|
const char * |
mode |
|
) |
| |
Opens the file whose name is the string pointed to by path.
- Parameters:
-
storage | is the name where find the file to open |
path | is the file location on the storage |
mode | points to a string beginning with one of the following sequences (Additional characters may follow these sequences.): 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. |
- Returns:
- An msg_file_t associated to the file
int MSG_file_close |
( |
const char * |
storage, |
|
|
msg_file_t |
fp |
|
) |
| |
Close the file.
- Parameters:
-
storage | is the name where find the stream |
fp | is the file to close |
- Returns:
- 0 on success or 1 on error
int MSG_file_stat |
( |
const char * |
storage, |
|
|
msg_file_t |
fd, |
|
|
s_msg_stat_t * |
buf |
|
) |
| |
Stats the file pointed by fd.
- Parameters:
-
storage | is the name where find the stream |
fd | is the file descriptor (msg_file_t) |
buf | is the return structure with informations |
- Returns:
- 0 on success or 1 on error