|
A library for working with phylogenetic and population genetic data.
v0.27.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>
72 std::string
const& filename,
73 bool detect_compression =
true
85 std::string
const& filename,
86 bool detect_compression =
true
98 std::string
const& content,
99 std::string
const& filename,
100 bool create_dirs =
true
109 std::string
const& content,
110 std::string
const& filename,
111 bool create_dirs =
true
138 void dir_create( std::string
const&
path,
bool with_parents =
true );
154 std::string
const& dir,
155 bool full_path =
false,
156 std::string
const& regex =
""
166 std::string
const& dir,
167 bool full_path =
false,
168 std::string
const& regex =
""
178 std::string
const& dir,
179 bool full_path =
false,
180 std::string
const& regex =
""
205 std::string
real_path( std::string
const&
path,
bool resolve_link =
true );
214 std::unordered_map<std::string, std::string>
file_info ( std::string
const& filename );
219 size_t file_size( std::string
const& filename );
227 std::string
file_path( std::string
const& filename );
252 std::string
const& filename,
253 std::vector<std::string>
const& remove_extensions
323 #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 is_file(std::string const &path)
Return true iff the provided path is a file.
bool file_exists(std::string const &filename)
Return true iff the file exists.
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.