26bool exists (
char const* pathname);
41char*
get_cwd (
char* buf, std::size_t size);
48bool set_cwd (
char const* pathname);
56bool mkdir (
char const* pathname);
59bool rmdir (
char const* pathname);
62bool unlink (
char const* pathname);
65bool rename (
char const* from,
char const* to);
68void copy_file (
char const* src,
char const* dst);
85 std::string
const& filename);
107std::string
join_path (std::string
const& path1, std::string
const& path2);
110std::string
abspath (std::string
const& path);
113std::string
dirname (std::string
const& path);
116std::string
basename (std::string
const& path);
135 File (std::string
const& path, std::string
const& name,
bool isdir =
false);
136 std::string get_absolute_name (
void)
const;
137 bool operator< (
File const& rhs)
const;
150 void scan (std::string
const& path);
188 FileLock (std::string
const& filename);
196 Status acquire (std::string
const& filename);
203 Status acquire_retry (std::string
const& filename,
204 int retries = 50,
int sleep = 100);
209 bool is_locked (std::string
const& filename);
216 bool wait_lock (std::string
const& filename,
217 int retries = 50,
int sleep = 100);
228 std::string
const& get_reason (
void)
const;
231 std::string lockfile;
246File::File (std::string
const& path, std::string
const& name,
bool isdir)
247 : path(path), name(name), is_dir(isdir)
273inline std::string
const&
Directory abstraction to scan directory contents.
void scan(std::string const &path)
A simple file-based file lock implementation.
bool release(void)
Removes the lock if it exists.
std::string const & get_reason(void) const
If locking failes, this returns the reason for failure.
@ LOCK_CREATED
The lock has been created successfully.
@ LOCK_EXISTS
The lock has NOT been created because a lock already exists.
@ LOCK_PERSISTENT
The lock has NOT been created because an existing lock persisted.
~FileLock(void)
Removes the lock if it exists.
std::string replace_extension(std::string const &fn, std::string const &ext)
Replaces extension of the given file with 'ext'.
bool unlink(char const *pathname)
Unlinks (deletes) the given file.
std::string sanitize_path(std::string const &path)
Canonicalize slashes in the given path.
std::string abspath(std::string const &path)
Returns the absolute representation of the given path.
bool is_absolute(std::string const &path)
Checks whether the given path is absolute.
char * get_cwd(char *buf, size_t size)
bool mkdir(char const *pathname)
Creates a new directory.
void write_string_to_file(std::string const &data, std::string const &filename)
Writes the given data into a file.
bool rmdir(char const *pathname)
Removes an empty directory.
void copy_file(char const *src, char const *dst)
Copies a file from 'src' to 'dst', throws FileException on error.
bool exists(char const *pathname)
Determines if the given path is a directory.
std::string get_binary_path(void)
Returns the path of the binary currently executing.
std::string dirname(std::string const &path)
Returns the directory name component of the given path.
bool dir_exists(char const *pathname)
Determines if the given path is a directory.
char const * get_app_data_dir(void)
Determines the current user's path for application data.
bool rename(char const *from, char const *to)
Renames the given file 'from' to new name 'to'.
bool set_cwd(char const *pathname)
Changes the current working directory to 'pathname' and returns true on success.
std::string join_path(std::string const &path1, std::string const &path2)
Concatenate and canonicalize two paths.
bool file_exists(char const *pathname)
Determines if the given path is a file.
std::string basename(std::string const &path)
Returns the file name component of the given path.
void read_file_to_string(std::string const &filename, std::string *data)
Reads the whole file into a string.
char const * get_home_dir(void)
Determines the home path for the current user.
std::string get_cwd_string(void)
Determines the CWD and returns a convenient string.
#define UTIL_NAMESPACE_BEGIN
#define UTIL_NAMESPACE_END
#define UTIL_FS_NAMESPACE_BEGIN
#define UTIL_FS_NAMESPACE_END