11#ifndef CCGL_UTILS_FILESYSTEM_H
12#define CCGL_UTILS_FILESYSTEM_H
25namespace utils_filesystem {
75string GetSuffix(
string const& full_filename);
82string ReplaceSuffix(
string const& full_filename,
string const& new_suffix);
91string AppendCoreFileName(
string const& full_filename,
string const& endstr,
char deli =
'_');
105string PrefixCoreFileName(
string const& full_filename,
string const& prestr,
char deli =
'_');
122string ConcatFullName(
string const& fdir,
string const& corename,
string const& suffix = std::string());
159int FindFiles(
const char* lp_path,
const char* expression, vector<string>& vec_files);
int DeleteExistedFile(const string &filepath)
Delete the given file if existed.
Definition: utils_filesystem.cpp:57
bool FileExists(string const &filename)
Return a flag indicating if the given file exists.
Definition: utils_filesystem.cpp:23
string GetSuffix(string const &full_filename)
Return the suffix of a given file's path without dot, e.g., "tif", "asc".
Definition: utils_filesystem.cpp:311
bool DeleteDirectory(const string &dirpath, bool del_subdirs)
Delete a directory if exists.
Definition: utils_filesystem.cpp:170
string GetAbsolutePath(string const &full_filename)
Return the absolute file path from a given file path.
Definition: utils_filesystem.cpp:283
bool PathExists(string const &fullpath)
Return a flag indicating if the given path (directory or file) exists.
Definition: utils_filesystem.cpp:43
string AppendCoreFileName(string const &full_filename, string const &endstr, char deli)
Append a given string to the core filename.
Definition: utils_filesystem.cpp:328
string GetPathFromFullName(string const &full_filename)
Get Path From full file path string.
Definition: utils_filesystem.cpp:350
string ReplaceSuffix(string const &full_filename, string const &new_suffix)
Replace the suffix by a given suffix.
Definition: utils_filesystem.cpp:320
string GetCoreFileName(string const &full_filename)
Return the file name from a given file's path.
Definition: utils_filesystem.cpp:296
string ConcatFullName(string const &fdir, string const &corename, string const &suffix)
Concatenate directory, core file name, and suffix.
Definition: utils_filesystem.cpp:361
string GetAppPath()
Get the root path of the current executable file.
Definition: utils_filesystem.cpp:250
string PrefixCoreFileName(string const &full_filename, string const &prestr, char deli)
Add a prefix to the core filename.
Definition: utils_filesystem.cpp:339
bool CleanDirectory(const string &dirpath)
Clean a directory if exists, otherwise create it.
Definition: utils_filesystem.cpp:150
int FindFiles(const char *lp_path, const char *expression, vector< string > &vec_files)
Find files in given paths.
Definition: utils_filesystem.cpp:65
bool FilesExist(vector< string > &filenames)
Return a flag indicating if given files exist.
Definition: utils_filesystem.cpp:35
bool MakeDirectory(const string &dirpath)
Make directory if not exists.
Definition: utils_filesystem.cpp:139
bool LoadPlainTextFile(const string &filepath, vector< string > &content_strs)
Load short plain text file as string vector, ignore comments begin with '#' and empty lines.
Definition: utils_filesystem.cpp:372
bool DirectoryExists(const string &dirpath)
Check the given directory path (not regular file!) is exists or not.
Definition: utils_filesystem.cpp:123
Common Cross-platform Geographic Library (CCGL)
Definition: basic.cpp:17