MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
Classes | Functions | Variables
util::fs Namespace Reference

Cross-platform file system functions. More...

Classes

class  Directory
 Directory abstraction to scan directory contents. More...
 
struct  File
 
class  FileLock
 A simple file-based file lock implementation. More...
 

Functions

std::string abspath (std::string const &path)
 Returns the absolute representation of the given path.
 
std::string basename (std::string const &path)
 Returns the file name component of the given path.
 
void copy_file (char const *src, char const *dst)
 Copies a file from 'src' to 'dst', throws FileException on error.
 
bool dir_exists (char const *pathname)
 Determines if the given path is a directory.
 
std::string dirname (std::string const &path)
 Returns the directory name component of the given path.
 
bool exists (char const *pathname)
 Determines if the given path is a directory.
 
bool file_exists (char const *pathname)
 Determines if the given path is a file.
 
char const * get_app_data_dir (void)
 Determines the current user's path for application data.
 
std::string get_binary_path (void)
 Returns the path of the binary currently executing.
 
char * get_cwd (char *buf, size_t size)
 
char * get_cwd (char *buf, std::size_t size)
 Determines the current working directory of the process.
 
std::string get_cwd_string (void)
 Determines the CWD and returns a convenient string.
 
char const * get_home_dir (void)
 Determines the home path for the current user.
 
bool is_absolute (std::string const &path)
 Checks whether the given path is absolute.
 
std::string join_path (std::string const &path1, std::string const &path2)
 Concatenate and canonicalize two paths.
 
bool mkdir (char const *pathname)
 Creates a new directory.
 
void read_file_to_string (std::string const &filename, std::string *data)
 Reads the whole file into a string.
 
bool rename (char const *from, char const *to)
 Renames the given file 'from' to new name 'to'.
 
std::string replace_extension (std::string const &fn, std::string const &ext)
 Replaces extension of the given file with 'ext'.
 
bool rmdir (char const *pathname)
 Removes an empty directory.
 
std::string sanitize_path (std::string const &path)
 Canonicalize slashes in the given path.
 
bool set_cwd (char const *pathname)
 Changes the current working directory to 'pathname' and returns true on success.
 
bool unlink (char const *pathname)
 Unlinks (deletes) the given file.
 
void write_string_to_file (char const *data, std::size_t len, std::string const &filename)
 Writes the given data into a file.
 
void write_string_to_file (std::string const &data, std::string const &filename)
 Writes the given data into a file.
 

Variables

char app_data_path [2048] = { 0 }
 
char home_path [2048] = { 0 }
 

Detailed Description

Cross-platform file system functions.

Function Documentation

◆ abspath()

std::string util::fs::abspath ( std::string const &  path)

Returns the absolute representation of the given path.

Definition at line 408 of file file_system.cc.

◆ basename()

std::string util::fs::basename ( std::string const &  path)

Returns the file name component of the given path.

Definition at line 440 of file file_system.cc.

◆ copy_file()

void util::fs::copy_file ( char const *  src,
char const *  dst 
)

Copies a file from 'src' to 'dst', throws FileException on error.

Definition at line 248 of file file_system.cc.

◆ dir_exists()

bool util::fs::dir_exists ( char const *  pathname)

Determines if the given path is a directory.

Definition at line 71 of file file_system.cc.

◆ dirname()

std::string util::fs::dirname ( std::string const &  path)

Returns the directory name component of the given path.

Definition at line 414 of file file_system.cc.

◆ exists()

bool util::fs::exists ( char const *  pathname)

Determines if the given path is a directory.

Definition at line 53 of file file_system.cc.

◆ file_exists()

bool util::fs::file_exists ( char const *  pathname)

Determines if the given path is a file.

Definition at line 95 of file file_system.cc.

◆ get_app_data_dir()

char const * util::fs::get_app_data_dir ( void  )

Determines the current user's path for application data.

Definition at line 182 of file file_system.cc.

◆ get_binary_path()

std::string util::fs::get_binary_path ( void  )

Returns the path of the binary currently executing.

Definition at line 303 of file file_system.cc.

◆ get_cwd() [1/2]

char * util::fs::get_cwd ( char *  buf,
size_t  size 
)

Definition at line 119 of file file_system.cc.

◆ get_cwd() [2/2]

char * util::fs::get_cwd ( char *  buf,
std::size_t  size 
)

Determines the current working directory of the process.

◆ get_cwd_string()

std::string util::fs::get_cwd_string ( void  )

Determines the CWD and returns a convenient string.

Definition at line 280 of file file_system.cc.

◆ get_home_dir()

char const * util::fs::get_home_dir ( void  )

Determines the home path for the current user.

Definition at line 209 of file file_system.cc.

◆ is_absolute()

bool util::fs::is_absolute ( std::string const &  path)

Checks whether the given path is absolute.

Definition at line 356 of file file_system.cc.

◆ join_path()

std::string util::fs::join_path ( std::string const &  path1,
std::string const &  path2 
)

Concatenate and canonicalize two paths.

The result is where you would end up after cd path1; cd path2.

Definition at line 393 of file file_system.cc.

◆ mkdir()

bool util::fs::mkdir ( char const *  pathname)

Creates a new directory.

Definition at line 143 of file file_system.cc.

◆ read_file_to_string()

void util::fs::read_file_to_string ( std::string const &  filename,
std::string *  data 
)

Reads the whole file into a string.

Throws on error.

Definition at line 478 of file file_system.cc.

◆ rename()

bool util::fs::rename ( char const *  from,
char const *  to 
)

Renames the given file 'from' to new name 'to'.

Definition at line 237 of file file_system.cc.

◆ replace_extension()

std::string util::fs::replace_extension ( std::string const &  fn,
std::string const &  ext 
)

Replaces extension of the given file with 'ext'.

If the file name does not have an extension, the given extension is appended.

Definition at line 460 of file file_system.cc.

◆ rmdir()

bool util::fs::rmdir ( char const *  pathname)

Removes an empty directory.

Definition at line 159 of file file_system.cc.

◆ sanitize_path()

std::string util::fs::sanitize_path ( std::string const &  path)

Canonicalize slashes in the given path.

Definition at line 366 of file file_system.cc.

◆ set_cwd()

bool util::fs::set_cwd ( char const *  pathname)

Changes the current working directory to 'pathname' and returns true on success.

NOTE: An application should never change its working directory. Make sure this is really necessary.

Definition at line 131 of file file_system.cc.

◆ unlink()

bool util::fs::unlink ( char const *  pathname)

Unlinks (deletes) the given file.

Definition at line 170 of file file_system.cc.

◆ write_string_to_file() [1/2]

void util::fs::write_string_to_file ( char const *  data,
std::size_t  len,
std::string const &  filename 
)

Writes the given data into a file.

Throws on error.

Definition at line 498 of file file_system.cc.

◆ write_string_to_file() [2/2]

void util::fs::write_string_to_file ( std::string const &  data,
std::string const &  filename 
)

Writes the given data into a file.

Throws on error.

Definition at line 492 of file file_system.cc.

Variable Documentation

◆ app_data_path

char util::fs::app_data_path[2048] = { 0 }

Definition at line 50 of file file_system.cc.

◆ home_path

char util::fs::home_path[2048] = { 0 }

Definition at line 49 of file file_system.cc.