SimGrid  3.9
Versatile Simulation of Distributed Systems
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
File Management Functions

This section describes the file structure of MSG (msg_file_t) and the functions for managing it. It is based on POSIX functions. More...

Data Structures

struct  file_stat
 Strucure containing information on file like stat on POSIX. More...

Typedefs

typedef struct msg_file * msg_file_t
 File datatype.You should consider this as an opaque object.
typedef s_file_stat_t s_msg_stat_t
 File datatype.You should consider this as an opaque object.
typedef struct file_stat s_file_stat_t
 Strucure containing information on file like stat on POSIX.

Functions

double MSG_file_read (void *ptr, size_t size, size_t nmemb, msg_file_t stream)
 Read elements of a file.
size_t MSG_file_write (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 *mount, const char *path, const char *mode)
 Opens the file whose name is the string pointed to by path.
int MSG_file_close (msg_file_t fp)
 Close the file.
int MSG_file_stat (msg_file_t fd, s_msg_stat_t *buf)
 Stats the file pointed by fd.
void MSG_file_free_stat (s_msg_stat_t *stat)
 Free the stat structure.
int MSG_file_unlink (msg_file_t fd)
 Unlink the file pointed by fd.
xbt_dict_t MSG_file_ls (const char *mount, const char *path)
 Search for file.

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.

@htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Files" --> \endhtmlonly

(msg_file_t) and the functions for managing it.

See Also
msg_file_t

Function Documentation

double MSG_file_read ( void *  ptr,
size_t  size,
size_t  nmemb,
msg_file_t  stream 
)

Read elements of a file.

Parameters
ptrbuffer to where the data is copied
sizeof each element
nmembis the number of elements of data to read
streamto read
Returns
the number of items successfully read
size_t MSG_file_write ( const void *  ptr,
size_t  size,
size_t  nmemb,
msg_file_t  stream 
)

Write elements into a file.

Parameters
ptrbuffer from where the data is copied
sizeof each element
nmembis the number of elements of data to write
streamto write
Returns
the number of items successfully write
msg_file_t MSG_file_open ( const char *  mount,
const char *  path,
const char *  mode 
)

Opens the file whose name is the string pointed to by path.

Parameters
mountis the mount point where find the file is located
pathis the file location on the storage
modepoints 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 ( msg_file_t  fp)

Close the file.

Parameters
fpis the file to close
Returns
0 on success or 1 on error
int MSG_file_stat ( msg_file_t  fd,
s_msg_stat_t buf 
)

Stats the file pointed by fd.

Parameters
fdis the file descriptor (msg_file_t)
bufis the return structure with informations
Returns
0 on success or 1 on error
void MSG_file_free_stat ( s_msg_stat_t stat)

Free the stat structure.

Parameters
statthe s_msg_stat_t to free
int MSG_file_unlink ( msg_file_t  fd)

Unlink the file pointed by fd.

Parameters
fdis the file descriptor (msg_file_t)
Returns
0 on success or 1 on error
xbt_dict_t MSG_file_ls ( const char *  mount,
const char *  path 
)

Search for file.

Parameters
mountis the mount point where find the file is located
paththe file regex to find
Returns
a xbt_dict_t of file where key is the name of file and the value the msg_stat_t corresponding to the key