A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fs.hpp File Reference

Detailed Description

Provides functions for accessing the file system.

Definition in file fs.hpp.

#include <string>
#include <unordered_map>
#include <vector>

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::utils
 

Functions

void dir_create (std::string const &path)
 Create a directory. More...
 
bool dir_exists (std::string const &dir)
 Return true iff the directory exists. More...
 
std::vector< std::string > dir_list_contents (std::string const &dir, bool full_path=false, std::string const &regex="")
 Get a list of files and directories in a directory. More...
 
std::vector< std::string > dir_list_directories (std::string const &dir, bool full_path=false, std::string const &regex="")
 Get a list of directories in a directory. More...
 
std::vector< std::string > dir_list_files (std::string const &dir, bool full_path=false, std::string const &regex="")
 Get a list of files in a directory. More...
 
std::string dir_normalize_path (std::string const &path)
 Normalize a dir name, i.e., make sure that the given path ends with exaclty one slash. More...
 
void file_append (std::string const &content, std::string const &filename)
 Append the content of a string to a file. More...
 
std::string file_basename (std::string const &filename)
 Remove directory name from file name if present. More...
 
bool file_exists (std::string const &filename)
 Return true iff the file exists. More...
 
std::string file_extension (std::string const &filename)
 Return the extension name of a file. More...
 
std::string file_filename (std::string const &filename)
 Remove extension if present. More...
 
std::unordered_map
< std::string, std::string > 
file_info (std::string const &filename)
 Return information about a file. More...
 
std::string file_path (std::string const &filename)
 Return the path leading to a file. More...
 
std::string file_read (std::string const &filename)
 Return the contents of a file as a string. More...
 
size_t file_size (std::string const &filename)
 Return the size of a file. More...
 
void file_write (std::string const &content, std::string const &filename)
 Write the content of a string to a file. More...
 
bool is_dir (std::string const &path)
 Return true iff the provided path is a directory. More...
 
bool is_file (std::string const &path)
 Return true iff the provided path is a file. More...
 
bool is_valid_filname (std::string const &filename)
 Check whether a file name is valid. More...
 
std::string sanitize_filname (std::string const &filename)
 Remove or replace all invalid parts of a filename. More...