Furrent
Typedefs | Enumerations | Functions
fur::platform::io Namespace Reference

Typedefs

template<typename T >
using IOResult = util::Result< T, IOError >
 Empty result for handling IO errors. More...
 

Enumerations

enum  IOError {
  IOError::GenericError, IOError::CannotOpenFile, IOError::InvalidPath, IOError::PathDoesNotExists,
  IOError::FileAlreadyExists, IOError::DirectoryAlreadyExists
}
 

Functions

IOResult< Emptytouch (const std::string &filename, int64_t size)
 
IOResult< bool > exists (const std::string &filename)
 
IOResult< Emptyremove (const std::string &filename)
 
IOResult< Emptywrite_bytes (const std::string &filename, const std::vector< uint8_t > &bytes, int64_t offset)
 
IOResult< std::string > create_directories (const std::string &path, bool skip_last)
 
IOResult< std::string > load_file_text (const std::string &filepath)
 

Typedef Documentation

◆ IOResult

template<typename T >
using fur::platform::io::IOResult = typedef util::Result<T, IOError>

Empty result for handling IO errors.

Enumeration Type Documentation

◆ IOError

Enumerator
GenericError 
CannotOpenFile 
InvalidPath 
PathDoesNotExists 
FileAlreadyExists 
DirectoryAlreadyExists 

Function Documentation

◆ create_directories()

IOResult< std::string > fur::platform::io::create_directories ( const std::string &  path,
bool  skip_last = false 
)

Create a nested folders structure

Parameters
pathpath including all directories to create
skip_lastskip last section of the path, used for files
Returns
constructed path or and error

◆ exists()

IOResult< bool > fur::platform::io::exists ( const std::string &  filename)

Check if a directory or file exists

Parameters
filenamepath to check

◆ load_file_text()

IOResult< std::string > fur::platform::io::load_file_text ( const std::string &  filepath)

Load file content of a file

Parameters
filepathfilepath of the target file
Returns
loaded text or an error

◆ remove()

IOResult< Empty > fur::platform::io::remove ( const std::string &  filename)

Removes a file or directory

Parameters
filenamefilename of the target file/directory

◆ touch()

IOResult< Empty > fur::platform::io::touch ( const std::string &  filename,
int64_t  size 
)

Create a new file on the disk

Parameters
filenamefilename of the new file
sizesize of the new file

◆ write_bytes()

IOResult< Empty > fur::platform::io::write_bytes ( const std::string &  filename,
const std::vector< uint8_t > &  bytes,
int64_t  offset 
)

Write bytes to file

Parameters
filenamefilename of the target file
bytesnumber of files to write
offsetwhere to write the bytes in the file