8 #ifdef HAVE_SYS_TYPES_H
11 #ifdef HAVE_SYS_STAT_H
19 #ifdef HAVE_SYS_PARAM_H
20 #include <sys/param.h>
22 #ifdef HAVE_SYS_MOUNT_H
23 #include <sys/mount.h>
37 #ifdef HAVE_SYS_STATVFS_H
39 # ifdef _FILE_OFFSET_BITS
40 # if _FILE_OFFSET_BITS == 64
41 # define __HOLD_FILE_OFFSET_BITS_64
42 # undef _FILE_OFFSET_BITS
46 #include <sys/statvfs.h>
47 # ifdef __HOLD_FILE_OFFSET_BITS_64
48 # define _FILE_OFFSET_BITS 64
49 # undef __HOLD_FILE_OFFSET_BITS_64
59 #ifdef HAVE_SYS_STATVFS_H
60 #define STATFS statvfs
67 const std::string
cwd(
void);
68 const pid_t
pid(
void);
78 const std::string a_path,
79 const std::string a_rel_path
82 const std::string a_path_to,
83 const std::string a_path_from
85 bool exists(
const std::string& a_path);
86 bool readable(
const std::string& a_path);
87 bool writable(
const std::string& a_path);
90 bool is_fifo_special(
const std::string& a_path);
93 bool is_char_special(
const std::string& a_path);
96 bool is_dir(
const std::string& a_path);
99 bool is_file(
const std::string& a_path);
102 bool is_block_special(
const std::string& a_path);
105 bool is_link(
const std::string& a_path);
108 bool is_socket(
const std::string& a_path);
111 bool is_door(
const std::string& a_path);
113 void mk_dir(
const std::string& a_path);
114 void rm_dir(
const std::string a_path);
115 void rm_file(
const std::string a_path);
117 void rename_file(
const std::string a_from,
const std::string a_to);
118 void mk_symlink(
const std::string a_from,
const std::string a_to);
130 type_character_special,
167 void path(
const std::string a_path);
168 const std::string
path(
void)
const;
170 const std::string
link(
void)
const;
189 const std::string
uid_name(
void)
const;
190 const std::string
gid_name(
void)
const;
195 const bool is_fifo_special(
void)
const;
198 const bool is_character_special(
void)
const;
201 const bool is_block_special(
void)
const;
204 const bool is_link(
void)
const;
207 const bool is_socket(
void)
const;
210 const bool is_door(
void)
const;
213 const bool is_directory(
void)
const;
216 const bool is_regular_file(
void)
const;
220 const bool user_can_read(
void)
const;
223 const bool user_can_write(
void)
const;
226 const bool user_can_execute(
void)
const;
229 const bool group_can_read(
void)
const;
232 const bool group_can_write(
void)
const;
235 const bool group_can_execute(
void)
const;
238 const bool other_can_read(
void)
const;
241 const bool other_can_write(
void)
const;
244 const bool other_can_execute(
void)
const;
247 const bool is_set_uid(
void)
const;
250 const bool is_set_gid(
void)
const;
253 const bool is_set_sticky(
void)
const;
276 typedef std::vector<std::string>
type;
280 subdirectory(
const std::string a_path,
const std::string a_filter =
"*");
286 path(
const std::string a_path,
const std::string a_filter =
"*");
303 typedef std::vector<std::string>
type;
310 const type&
path(
const std::string& a_path);
325 void path(
const std::string& a_path);
326 const std::string
path(
void)
const;
353 void lockfile(
const std::string& a_lockfile);
354 const std::string
lockfile(
void)
const;
Retrieve information about a filesystem.
const size_type total_inodes(void) const
Return the filesystem's total number of inodes, if supported by the filesystem, otherwise the result ...
bool readable(const std::string &a_path)
Return true if the file or directory exists and is readable.
const type & path(const std::string &a_path)
Retrieve a list of paths that match the wildcard path given.
Basic types definitions and templates.
bool absolute_path(const std::string &a_path)
Return true if the string looks like an absolute path.
std::string path_basename(const std::string &a_path)
Return everything after the last slash from a path.
std::string path_dirname(const std::string &a_path)
Return everything up to the last slash from a path.
void rm_recursive(const std::string a_path)
Recursively delete the contents of a directory.
void mk_dir(const std::string &a_path)
Create a directory.
const size_type blocks(void) const
Return the number of blocks used to store this file.
std::string mk_relative_path(const std::string a_path_to, const std::string a_path_from)
Make the path a_path_to relative from a_path_from, where a_path_to and a_path_from are directory name...
const bool gid_is_found(void) const
If the file's owner's GID is found in the passwd file, return true.
std::string reform_path(const std::string &a_path)
Reformat a path to remove double slashes.
const bool uid_is_found(void) const
If the file's owner's UID is found in the passwd file, return true.
const size_type blocksize(void) const
Return the filesystem block size.
const inode_type inode(void) const
Return the file inode.
const std::string link(void) const
If the pathname is a link, return the path it is linked to.
bool relative_path(const std::string &a_path)
Return true if the string looks like a relative path.
bool exists(const std::string &a_path)
Return true if the file or directory exists.
bool executable(const std::string &a_path)
Return true if the file or directory exists and is executable.
const size_type used_blocks(void) const
Return the filesystem's number of used blocks.
const pid_t pid(void)
Return the PID of this process.
Retrieve a list of pathnames that match a given wildcard path.
void mk_relative_symlink(const std::string a_from, const std::string a_to)
Given a from and to path, create a relative symbolic link.
const time_type last_status_change_time(void) const
Return the last status change time of this file.
const size_type blocksize(void) const
Return the blocksize used to store this file.
bool writable(const std::string &a_path)
Return true if the file or directory exists and is writable.
const std::string lockfile(void) const
Get the lockfile path.
const mode_type mode(void) const
Return the file mode.
filesystem & operator=(const filesystem &a_class)
Copy values from another instance.
std::vector< std::string > type
void rm_dir(const std::string a_path)
Remove a directory.
A simple locking mechanism.
const type & path(const std::string a_path, const std::string a_filter="*")
Return a vector of strings of a list of files in a subdirectory.
const pid_type locked_by(void) const
Get the PID of the locking process.
const filetype type(void) const
Return the type of file.
const size_type free_inodes(void) const
Return the filesystem's total number of free inodes, if supported by the filesystem, otherwise the result is system-dependent, but usually 0.
const std::string uid_name(void) const
Return the file's owner's user name (from UID)
const uid_type uid(void) const
Return the file's owner's UID.
const time_type last_modification_time(void) const
Return the last modification time of this file.
std::string permute_path(const std::string &a_path)
Reformat a path to remove the begining and trailing slashes, and replace all other slashes with under...
const minor_type get_minor(void) const
If the pathname is a special file, return it's minor number.
void rename_file(const std::string a_from, const std::string a_to)
Rename a file or directory.
const std::string cwd(void)
Return the current working directory.
const device_type dev(void) const
Return the file's device.
std::string mk_absolute_path(const std::string a_path, const std::string a_rel_path)
Make the path a_rel_path absolute with respect to a_path, where a_rel_path and a_path are directory n...
Retrieve information about a file or directory.
void clear(void)
Clear the simple_lock object.
const std::string path(void) const
Return the pathname that this filestatus object has information about.
const size_type used_inodes(void) const
Return the filesystem's number of used inodes.
void mk_dirhier(const std::string a_path)
Recursively create a directory heirarchy.
void clear(void)
Clear all values.
const size_type free_blocks(void) const
Return the filesystem's number of free blocks.
const std::string gid_name(void) const
Return the file's owner's group name (from UID)
const size_type size(void) const
Return the file size in bytes.
void assign(const subdirectory &a_class)
Assign the contents of a given subdirectory to this subdirectory.
const gid_type gid(void) const
Return the file's owner's GID.
std::vector< std::string > type
const num_links_type num_links(void) const
Return the number of links to this file.
const time_type last_access_time(void) const
Return the last access time of this file.
Retrieve a list of files in a subdirectory that match a given wildcard filename.
void clear(void)
Clear the filesystem object.
void mk_symlink(const std::string a_from, const std::string a_to)
Create a symbolic link.
const device_type rdev(void) const
Return the file's raw device.
const std::string path(void) const
Return the path from which this filesystem information was obtained.
const major_type get_major(void) const
If the pathname is a special file, return it's major number.
const size_type total_blocks(void) const
Return the filesystem's total number of blocks.
const pid_t parent_pid(void)
Return the PID of the parent process.
const bool is_locked(void) const
Find out whether or not the lock is in place.
subdirectory & operator=(const subdirectory &a_class)
void rm_file(const std::string a_path)
Remove a file.