SpECTRE  v2024.05.11
file_system Namespace Reference

A light-weight file system library based on POSIX. More...

Functions

void copy (const std::string &from, const std::string &to)
 Copies files or directories. More...
 
std::string cwd ()
 Returns the current working directory, resolving symlinks.
 
void create_directory (const std::string &dir, double wait_time=1, size_t num_tries=40)
 Creates a directory, including any parents that don't exist. If the directory exists create_directory does nothing. More...
 
bool check_if_dir_exists (const std::string &dir)
 Returns true if the directory exists. More...
 
bool check_if_file_exists (const std::string &file)
 Returns true if the regular file or link to the regular file exists. More...
 
size_t file_size (const std::string &file)
 Returns the file size in bytes. More...
 
std::string get_absolute_path (const std::string &rel_path)
 Get the absolute path, resolving symlinks. More...
 
std::string get_file_name (const std::string &file_path)
 Given a path to a file returns the file name. More...
 
std::string get_parent_path (const std::string &path)
 Wraps the dirname function to get the pathname of the parent directory. More...
 
std::vector< std::stringglob (const std::string &pattern)
 Get a list of files matching the given glob pattern.
 
bool is_file (const std::string &path)
 Returns true if the path points to a regular file or a link to a regular file. More...
 
std::vector< std::stringls (const std::string &dir_name="./")
 Gets a list of files in a directory. More...
 
void rm (const std::string &path, bool recursive)
 Deletes a file or directory. More...
 

Detailed Description

A light-weight file system library based on POSIX.

We use this library instead of a subprocess based library because OpenMPI does not support forking of processes on all systems. Since the parallelization library we use may be implemented on top of OpenMPI we take the safe route and use POSIX.