|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_CORE_FS_H_
2 #define GENESIS_UTILS_CORE_FS_H_
35 #include <unordered_map>
94 std::string
const& filename,
95 bool detect_compression =
true
107 std::string
const& filename,
108 bool detect_compression =
true
120 std::string
const& content,
121 std::string
const& filename,
122 bool create_dirs =
true
131 std::string
const& content,
132 std::string
const& filename,
133 bool create_dirs =
true
160 void dir_create( std::string
const&
path,
bool with_parents =
true );
176 std::string
const& dir,
177 bool full_path =
false,
178 std::string
const& regex =
""
188 std::string
const& dir,
189 bool full_path =
false,
190 std::string
const& regex =
""
200 std::string
const& dir,
201 bool full_path =
false,
202 std::string
const& regex =
""
227 std::string
real_path( std::string
const&
path,
bool resolve_link =
true );
236 std::unordered_map<std::string, std::string>
file_info ( std::string
const& filename );
241 size_t file_size( std::string
const& filename );
249 std::string
file_path( std::string
const& filename );
274 std::string
const& filename,
275 std::vector<std::string>
const& remove_extensions
345 #endif // include guard
std::string current_path()
Return the current (working) directory, simiar to getcwd().
void dir_create(std::string const &path, bool with_parents)
Create a directory.
size_t file_size(std::string const &filename)
Return the size of a file.
std::vector< std::string > dir_list_directories(std::string const &dir, bool full_path, std::string const ®ex)
Get a list of directories in a directory.
std::unordered_map< std::string, std::string > file_info(std::string const &filename)
Return information about a file.
std::string file_path(std::string const &filename)
Return the path leading to a file.
bool dir_exists(std::string const &dir)
Return true iff the directory exists.
std::string sanitize_filename(std::string const &filename)
Remove or replace all invalid parts of a filename.
std::string file_filename(std::string const &filename)
Remove extension if present.
utils::Range< IteratorPath< true > > path(ElementType const &start, ElementType const &finish)
std::string file_read(std::string const &filename, bool detect_compression)
Return the contents of a file as a string.
std::string real_path(std::string const &path, bool resolve_link)
Return the real path of a file or directory, similar to realpath().
bool is_dir(std::string const &path)
Return true iff the provided path is a directory.
std::vector< std::string > file_read_lines(std::string const &filename, bool detect_compression)
Return the contents of a file as a vector of strings, one entry for each line.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
bool path_exists(std::string const &path)
Return whether a path exists, i.e., is a file or directory.
bool file_is_readable(std::string const &filename)
Return whether a file is readable.
bool is_file(std::string const &path)
Return true iff the provided path is a (readable) file.
bool file_exists(std::string const &filename)
Return true iff the file exists (and is in fact a file, and not, e.g., a directory).
std::vector< std::string > dir_list_contents(std::string const &dir, bool full_path, std::string const ®ex)
Get a list of files and directories in a directory.
std::string file_basename(std::string const &filename)
Remove directory name from file name if present.
bool is_valid_filename(std::string const &filename)
Check whether a file name is valid.
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.
void file_write(std::string const &content, std::string const &filename, bool create_dirs)
Write the content of a string to a file.
void file_append(std::string const &content, std::string const &filename, bool create_dirs)
Append the content of a string to a file.
std::string file_extension(std::string const &filename)
Return the extension name of a file.
std::vector< std::string > dir_list_files(std::string const &dir, bool full_path, std::string const ®ex)
Get a list of files in a directory.