1 #ifndef GENESIS_UTILS_CORE_FS_H_ 2 #define GENESIS_UTILS_CORE_FS_H_ 35 #include <unordered_map> 71 std::string
file_read( std::string
const& filename,
bool detect_compression =
true );
81 std::vector<std::string>
file_read_lines( std::string
const& filename,
bool detect_compression =
true );
91 void file_write( std::string
const& content, std::string
const& filename );
98 void file_append( std::string
const& content, std::string
const& filename );
124 void dir_create( std::string
const&
path,
bool with_parents =
true );
140 std::string
const& dir,
141 bool full_path =
false,
142 std::string
const& regex =
"" 152 std::string
const& dir,
153 bool full_path =
false,
154 std::string
const& regex =
"" 164 std::string
const& dir,
165 bool full_path =
false,
166 std::string
const& regex =
"" 191 std::string
real_path( std::string
const&
path,
bool resolve_link =
true );
200 std::unordered_map<std::string, std::string>
file_info ( std::string
const& filename );
205 size_t file_size ( std::string
const& filename );
213 std::string
file_path ( std::string
const& filename );
287 #endif // include guard bool is_file(std::string const &path)
Return true iff the provided path is a file.
void file_write(std::string const &content, std::string const &filename)
Write the content of a string to a file.
std::unordered_map< std::string, std::string > file_info(std::string const &filename)
Return information about 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.
std::string file_extension(std::string const &filename)
Return the extension name of a file.
std::string file_path(std::string const &filename)
Return the path leading to a file.
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.
std::string file_read(std::string const &filename, bool detect_compression)
Return the contents of a file as a string.
bool dir_exists(std::string const &dir)
Return true iff the directory exists.
std::string file_filename(std::string const &filename)
Remove extension if present.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
bool file_exists(std::string const &filename)
Return true iff the file exists.
bool is_dir(std::string const &path)
Return true iff the provided path is 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::string file_basename(std::string const &filename)
Remove directory name from file name if present.
utils::Range< IteratorPath< true > > path(ElementType const &start, ElementType const &finish)
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_valid_filename(std::string const &filename)
Check whether a file name is valid.
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::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.
void file_append(std::string const &content, std::string const &filename)
Append the content of a string to a file.
std::string sanitize_filename(std::string const &filename)
Remove or replace all invalid parts of a filename.
bool path_exists(std::string const &path)
Return whether a path exists, i.e., is a file or directory.
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.