SimGrid  3.21
Versatile Simulation of Distributed Systems
simgrid::s4u::File Class Reference

Detailed Description

A simulated file.

Used to simulate the time it takes to access to a file, but does not really store any information.

They are located on simgrid::s4u::Storage that are accessed from a given simgrid::s4u::Host through mountpoints. For now, you cannot change the mountpoints programatically, and must declare them from your platform file.

#include <file_system.h>

Public Member Functions

 File (std::string fullpath, void *userdata)
 
 File (std::string fullpath, sg_host_t host, void *userdata)
 
 ~File ()
 
const char * get_path ()
 Retrieves the path to the file. More...
 
sg_size_t read (sg_size_t size)
 Simulates a local read action. More...
 
sg_size_t write (sg_size_t size)
 Simulates a write action. More...
 
void set_userdata (void *data)
 Allows to store user data on that host. More...
 
void * get_userdata ()
 Retrieves the previously stored data. More...
 
sg_size_t size ()
 
void seek (sg_offset_t pos)
 
void seek (sg_offset_t pos, int origin)
 Sets the file head to the given position. More...
 
sg_size_t tell ()
 Sets the file head to the given position from a given origin. More...
 
void move (std::string fullpath)
 Retrieves the current file position. More...
 
int remote_copy (sg_host_t host, const char *fullpath)
 
int remote_move (sg_host_t host, const char *fullpath)
 
int unlink ()
 
void dump ()
 Remove a file from the contents of a disk. More...
 

Public Attributes

int desc_id = 0
 
Storagelocal_storage_
 
std::string mount_point_
 

Constructor & Destructor Documentation

◆ File() [1/2]

simgrid::s4u::File::File ( std::string  fullpath,
void *  userdata 
)

◆ File() [2/2]

simgrid::s4u::File::File ( std::string  fullpath,
sg_host_t  host,
void *  userdata 
)

◆ ~File()

simgrid::s4u::File::~File ( )

Member Function Documentation

◆ get_path()

const char* simgrid::s4u::File::get_path ( )
inline

Retrieves the path to the file.

◆ read()

sg_size_t simgrid::s4u::File::read ( sg_size_t  size)

Simulates a local read action.

Returns the size of data actually read

◆ write()

sg_size_t simgrid::s4u::File::write ( sg_size_t  size)

Simulates a write action.

Write into a file (local or remote)

Returns the size of data actually written.

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

◆ set_userdata()

void simgrid::s4u::File::set_userdata ( void *  data)
inline

Allows to store user data on that host.

◆ get_userdata()

void* simgrid::s4u::File::get_userdata ( )
inline

Retrieves the previously stored data.

◆ size()

sg_size_t simgrid::s4u::File::size ( )

◆ seek() [1/2]

void simgrid::s4u::File::seek ( sg_offset_t  pos)

◆ seek() [2/2]

void simgrid::s4u::File::seek ( sg_offset_t  pos,
int  origin 
)

Sets the file head to the given position.

◆ tell()

sg_size_t simgrid::s4u::File::tell ( )

Sets the file head to the given position from a given origin.

◆ move()

void simgrid::s4u::File::move ( std::string  fullpath)

Retrieves the current file position.

Rename a file. WARNING: It is forbidden to move the file to another mount point

◆ remote_copy()

int simgrid::s4u::File::remote_copy ( sg_host_t  host,
const char *  fullpath 
)

◆ remote_move()

int simgrid::s4u::File::remote_move ( sg_host_t  host,
const char *  fullpath 
)

◆ unlink()

int simgrid::s4u::File::unlink ( )

◆ dump()

void simgrid::s4u::File::dump ( )

Remove a file from the contents of a disk.

Member Data Documentation

◆ desc_id

int simgrid::s4u::File::desc_id = 0

◆ local_storage_

Storage* simgrid::s4u::File::local_storage_

◆ mount_point_

std::string simgrid::s4u::File::mount_point_

The documentation for this class was generated from the following files: