#include <string>
#include <list>
Go to the source code of this file.
Functions | |
bool | copy_file (std::string const &source, std::string const &destination) |
bool | is_directory (std::string const &dirname) |
return true if dir is an existing directory | |
bool | is_files_identical (std::string const &file1, std::string const &file2) |
std::string const | op_realpath (std::string const &name) |
bool | op_file_readable (std::string const &file) |
return true if the given file is readable | |
bool | create_file_list (std::list< std::string > &file_list, std::string const &base_dir, std::string const &filter="*", bool recursive=false) |
std::string | op_dirname (std::string const &file_name) |
std::string | op_basename (std::string const &path_name) |
Useful file management helpers
Definition in file file_manip.h.
bool copy_file | ( | std::string const & | source, | |
std::string const & | destination | |||
) |
copy_file - copy a file.
source | filename to copy from | |
destination | filename to copy into |
the last modification time of the source file is preserved, file attribute and owner are preserved if possible. Return true if copying successful.
bool create_file_list | ( | std::list< std::string > & | file_list, | |
std::string const & | base_dir, | |||
std::string const & | filter = "*" , |
|||
bool | recursive = false | |||
) |
file_list | where to store result | |
base_dir | directory from where lookup start | |
filter | a filename filter | |
recursive | if true lookup in sub-directory |
create a filelist under base_dir, filtered by filter and optionally looking in sub-directory. If we look in sub-directory only sub-directory which match filter are traversed.
bool is_directory | ( | std::string const & | dirname | ) |
return true if dir is an existing directory
bool is_files_identical | ( | std::string const & | file1, | |
std::string const & | file2 | |||
) |
is_file_identical - check for identical files
file1 | first filename | |
file2 | second filename |
return true if the two filenames belong to the same file
std::string op_basename | ( | std::string const & | path_name | ) |
op_basename - get the basename of a path
path_name | path |
Returns the basename of a path with trailing '/' removed.
Always use this instead of the C basename() - header order can affect behaviour for basename("/")
std::string op_dirname | ( | std::string const & | file_name | ) |
op_dirname - get the path component of a filename
file_name | filename |
Returns the path name of a filename with trailing '/' removed.
bool op_file_readable | ( | std::string const & | file | ) |
return true if the given file is readable
std::string const op_realpath | ( | std::string const & | name | ) |
op_realpath - resolve symlinks etc. Resolve a path as much as possible. Accounts for relative paths (from cwd), ".." and ".". For success, the target file must exist !
Resolve a symbolic link as far as possible. Returns the original string on failure.