simgrid::fsmod::File

class File

A class that implemented a file abstraction.

Public Functions

const std::string &get_access_mode() const

Get the file’s access mode.

Returns:

an access mode string

FileSystem *get_file_system() const

Retrieve the file system that holds this file.

Returns:

A FileSystem

const std::string &get_path() const

Get the file’s full path.

Returns:

a path string

sg_size_t read(const std::string &num_bytes, bool simulate_it = true)

Read data from the file.

Parameters:
  • num_bytes – the number of bytes to read as a string with units

  • simulate_it – if true simulate the I/O, if false the I/O takes zero time

Returns:

the actual number of bytes read in the file

sg_size_t read(sg_size_t num_bytes, bool simulate_it = true)

Read data from the file.

Parameters:
  • num_bytes – the number of bytes to read

  • simulate_it – if true simulate the I/O, if false the I/O takes zero time

Returns:

the actual number of bytes read in the file

s4u::IoPtr read_async(const std::string &num_bytes)

Asynchronously read data from the file.

Parameters:

num_bytes – the number of bytes to read as a string with units

Returns:

An I/O activity

s4u::IoPtr read_async(sg_size_t num_bytes)

Asynchronously read data from the file.

Parameters:

num_bytes – the number of bytes to read

Returns:

An I/O activity

void seek(sg_offset_t pos, int origin = SEEK_SET)

Seek to a position in the file from a given origin.

Parameters:
  • pos – the position as an offset from the given origin in the file

  • origin – where to start adding the offset in the file

std::unique_ptr<FileStat> stat() const

Obtain information about the file.

Returns:

A “file stat” object

sg_size_t write(const std::string &num_bytes, bool simulate_it = true)

Write data to the file.

Parameters:
  • num_bytes – the number of bytes to write as a string with units

  • simulate_it – if true simulate the I/O, if false the I/O takes zero time

Returns:

The number of bytes written

sg_size_t write(sg_size_t num_bytes, bool simulate_it = true)

Write data to the file.

Parameters:
  • num_bytes – the number of bytes to write

  • simulate_it – if true simulate the I/O, if false the I/O takes zero time

Returns:

The number of bytes written

s4u::IoPtr write_async(const std::string &num_bytes)

Asynchronously write data from the file.

Parameters:

num_bytes – the number of bytes to read as a string with units

Returns:

An I/O activity

s4u::IoPtr write_async(sg_size_t num_bytes)

Asynchronously write data from the file.

Parameters:

num_bytes – the number of bytes to read

Returns:

An I/O activity

Public Static Functions

static sg_size_t get_num_bytes_read(const s4u::IoPtr &read)

Get the number of bytes actually read by a given I/O Read activity.

Parameters:

write – the I/O (read) activity

Returns:

a number of bytes

static sg_size_t get_num_bytes_written(const s4u::IoPtr &write)

Get the number of bytes actually written by a given I/O Write activity.

Parameters:

write – the I/O (write) activity

Returns:

a number of bytes