SimGrid  3.16
Versatile Simulation of Distributed Systems
File Management Functions

Detailed Description

MSG files (msg_file_t) and associated functions, inspired from POSIX.

(msg_file_t) and the functions for managing it.

See also
msg_file_t

Functions

msg_error_t MSG_file_set_data (msg_file_t fd, void *data)
 Set the user data of a msg_file_t. More...
 
voidMSG_file_get_data (msg_file_t fd)
 Return the user data of a msg_file_t. More...
 
void MSG_file_dump (msg_file_t fd)
 Display information related to a file descriptor. More...
 
sg_size_t MSG_file_read (msg_file_t fd, sg_size_t size)
 Read a file (local or remote) More...
 
sg_size_t MSG_file_write (msg_file_t fd, sg_size_t size)
 Write into a file (local or remote) More...
 
msg_file_t MSG_file_open (const char *fullpath, void *data)
 Opens the file whose name is the string pointed to by path. More...
 
int MSG_file_close (msg_file_t fd)
 Close the file. More...
 
msg_error_t MSG_file_unlink (msg_file_t fd)
 Unlink the file pointed by fd. More...
 
sg_size_t MSG_file_get_size (msg_file_t fd)
 Return the size of a file. More...
 
msg_error_t MSG_file_seek (msg_file_t fd, sg_offset_t offset, int origin)
 Set the file position indicator in the msg_file_t by adding offset bytes to the position specified by origin (either SEEK_SET, SEEK_CUR, or SEEK_END). More...
 
sg_size_t MSG_file_tell (msg_file_t fd)
 Returns the current value of the position indicator of the file. More...
 
msg_error_t MSG_file_move (msg_file_t fd, const char *fullpath)
 Move a file to another location on the same mount point. More...
 
msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char *fullpath)
 Copy a file to another location on a remote host. More...
 
msg_error_t MSG_file_rmove (msg_file_t file, msg_host_t host, const char *fullpath)
 Move a file to another location on a remote host. More...
 

Function Documentation

◆ MSG_file_set_data()

msg_error_t MSG_file_set_data ( msg_file_t  fd,
void data 
)

Set the user data of a msg_file_t.

This functions attach data to file.

◆ MSG_file_get_data()

void* MSG_file_get_data ( msg_file_t  fd)

Return the user data of a msg_file_t.

This functions checks whether file is a valid pointer and return the user data associated to file if possible.

◆ MSG_file_dump()

void MSG_file_dump ( msg_file_t  fd)

Display information related to a file descriptor.

Parameters
fdis a the file descriptor

◆ MSG_file_read()

sg_size_t MSG_file_read ( msg_file_t  fd,
sg_size_t  size 
)

Read a file (local or remote)

Parameters
sizeof the file to read
fdis a the file descriptor
Returns
the number of bytes successfully read or -1 if an error occurred

◆ MSG_file_write()

sg_size_t MSG_file_write ( msg_file_t  fd,
sg_size_t  size 
)

Write into a file (local or remote)

Parameters
sizeof the file to write
fdis a the file descriptor
Returns
the number of bytes successfully write or -1 if an error occurred

◆ MSG_file_open()

msg_file_t MSG_file_open ( const char *  fullpath,
void data 
)

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

Parameters
fullpathis the file location on the storage
datauser data to attach to the file
Returns
An msg_file_t associated to the file

◆ MSG_file_close()

int MSG_file_close ( msg_file_t  fd)

Close the file.

Parameters
fdis the file to close
Returns
0 on success or 1 on error

◆ MSG_file_unlink()

msg_error_t 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

◆ MSG_file_get_size()

sg_size_t MSG_file_get_size ( msg_file_t  fd)

Return the size of a file.

Parameters
fdis the file descriptor (msg_file_t)
Returns
the size of the file (as a sg_size_t)

◆ MSG_file_seek()

msg_error_t MSG_file_seek ( msg_file_t  fd,
sg_offset_t  offset,
int  origin 
)

Set the file position indicator in the msg_file_t by adding offset bytes to the position specified by origin (either SEEK_SET, SEEK_CUR, or SEEK_END).

Parameters
fd: file object that identifies the stream
offset: number of bytes to offset from origin
origin: Position used as reference for the offset. It is specified by one of the following constants defined in <stdio.h> exclusively to be used as arguments for this function (SEEK_SET = beginning of file, SEEK_CUR = current position of the file pointer, SEEK_END = end of file)
Returns
If successful, the function returns MSG_OK (=0). Otherwise, it returns MSG_TASK_CANCELED (=8).

◆ MSG_file_tell()

sg_size_t MSG_file_tell ( msg_file_t  fd)

Returns the current value of the position indicator of the file.

Parameters
fd: file object that identifies the stream
Returns
On success, the current value of the position indicator is returned.

◆ MSG_file_move()

msg_error_t MSG_file_move ( msg_file_t  fd,
const char *  fullpath 
)

Move a file to another location on the same mount point.

◆ MSG_file_rcopy()

msg_error_t MSG_file_rcopy ( msg_file_t  file,
msg_host_t  host,
const char *  fullpath 
)

Copy a file to another location on a remote host.

Parameters
file: the file to move
host: the remote host where the file has to be copied
fullpath: the complete path destination on the remote host
Returns
If successful, the function returns MSG_OK. Otherwise, it returns MSG_TASK_CANCELED.

◆ MSG_file_rmove()

msg_error_t MSG_file_rmove ( msg_file_t  file,
msg_host_t  host,
const char *  fullpath 
)

Move a file to another location on a remote host.

Parameters
file: the file to move
host: the remote host where the file has to be moved
fullpath: the complete path destination on the remote host
Returns
If successful, the function returns MSG_OK. Otherwise, it returns MSG_TASK_CANCELED.