sbuild
1.6.10
|
Get file status. More...
#include <sbuild-util.h>
Public Types | |
enum | error_code { FILE, FD } |
Error codes. More... | |
enum | mode_bits { FILE_TYPE_MASK = S_IFMT, FILE_TYPE_SOCKET = S_IFSOCK, FILE_TYPE_LINK = S_IFLNK, FILE_TYPE_REGULAR = S_IFREG, FILE_TYPE_BLOCK = S_IFBLK, FILE_TYPE_DIRECTORY = S_IFDIR, FILE_TYPE_CHARACTER = S_IFCHR, FILE_TYPE_FIFO = S_IFIFO, PERM_SETUID = S_ISUID, PERM_SETGIT = S_ISGID, PERM_STICKY = S_ISVTX, PERM_USER_MASK = S_IRWXU, PERM_USER_READ = S_IRUSR, PERM_USER_WRITE = S_IWUSR, PERM_USER_EXECUTE = S_IXUSR, PERM_GROUP_MASK = S_IRWXG, PERM_GROUP_READ = S_IRGRP, PERM_GROUP_WRITE = S_IWGRP, PERM_GROUP_EXECUTE = S_IXGRP, PERM_OTHER_MASK = S_IRWXO, PERM_OTHER_READ = S_IROTH, PERM_OTHER_WRITE = S_IWOTH, PERM_OTHER_EXECUTE = S_IXOTH } |
Mode bits. More... | |
typedef custom_error< error_code > | error |
Exception type. | |
Public Member Functions | |
stat (const char *file, bool link=false) | |
The constructor. More... | |
stat (std::string const &file, bool link=false) | |
The constructor. More... | |
stat (std::string const &file, int fd) | |
The constructor. More... | |
stat (int fd) | |
The constructor. More... | |
virtual | ~stat () |
The destructor. | |
void | check () const |
Check if the file status was obtained. More... | |
struct::stat const & | get_detail () |
Get the struct stat used internally. More... | |
dev_t | device () const |
Get the device the file resides on. More... | |
ino_t | inode () const |
Get the inode of the file. More... | |
mode_t | mode () const |
Get the mode of the file. More... | |
nlink_t | links () const |
Get the number of hard links to the file. More... | |
uid_t | uid () const |
Get the user id owning the file. More... | |
gid_t | gid () const |
Get the group id owning the file. More... | |
off_t | size () const |
Get the file size. More... | |
blksize_t | blocksize () const |
Get the file block size. More... | |
blkcnt_t | blocks () const |
Get the file block count. More... | |
time_t | atime () const |
Get the file access time. More... | |
time_t | mtime () const |
Get the file modification time. More... | |
time_t | ctime () const |
Get the file creation time. More... | |
bool | is_regular () const |
Is the file a regular file? More... | |
bool | is_directory () const |
Is the file a directory? More... | |
bool | is_character () const |
Is the file a character device? More... | |
bool | is_block () const |
Is the file a block device? More... | |
bool | is_fifo () const |
Is the file a named pipe (FIFO)? More... | |
bool | is_link () const |
Is the file a symbolic link? More... | |
bool | is_socket () const |
Is the file a socket? More... | |
bool | check_mode (mode_bits mask) const |
Check if particular mode bits are set. More... | |
Private Attributes | |
std::string | file |
The filename being checked (if specified). | |
int | fd |
The file descriptor being checked (if specified). | |
int | errorno |
The error number set after stat(2) error. | |
struct::stat | status |
The stat(2) results. | |
Get file status.
stat(2) wrapper.
Mode bits.
sbuild::stat::stat | ( | const char * | file, |
bool | link = false |
||
) |
sbuild::stat::stat | ( | std::string const & | file, |
bool | link = false |
||
) |
sbuild::stat::stat | ( | std::string const & | file, |
int | fd | ||
) |
sbuild::stat::stat | ( | int | fd | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Check if the file status was obtained.
An error will be thrown if stat(2) failed to get the file status.
References errorno, FD, fd, and FILE.
Referenced by atime(), blocks(), blocksize(), check_mode(), ctime(), device(), sbuild::session::get_shell(), gid(), inode(), links(), mode(), mtime(), size(), and uid().
|
inline |
Check if particular mode bits are set.
mask | A bitmask containing the bits to check are set. |
References check(), and status.
Referenced by ctime(), is_block(), is_character(), is_directory(), is_fifo(), is_link(), is_regular(), is_socket(), sbuild::chroot_config::load_data(), sbuild::chroot_loopback::setup_lock(), and sbuild::chroot_file::setup_lock().
|
inline |
Get the file creation time.
References check(), check_mode(), is_block(), is_character(), is_directory(), is_fifo(), is_link(), is_regular(), is_socket(), and status.
|
inline |
|
inline |
Get the struct stat used internally.
This is returned by stat(2).
References status.
|
inline |
|
inline |
|
inline |
Is the file a block device?
References check_mode(), FILE_TYPE_BLOCK, and FILE_TYPE_MASK.
Referenced by ctime(), and sbuild::chroot_lvm_snapshot::setup_lock().
|
inline |
Is the file a character device?
References check_mode(), FILE_TYPE_CHARACTER, and FILE_TYPE_MASK.
Referenced by ctime().
|
inline |
Is the file a directory?
References check_mode(), FILE_TYPE_DIRECTORY, and FILE_TYPE_MASK.
Referenced by ctime().
|
inline |
Is the file a named pipe (FIFO)?
References check_mode(), FILE_TYPE_FIFO, and FILE_TYPE_MASK.
Referenced by ctime().
|
inline |
Is the file a symbolic link?
References check_mode(), FILE_TYPE_LINK, and FILE_TYPE_MASK.
Referenced by ctime().
|
inline |
Is the file a regular file?
References check_mode(), FILE_TYPE_MASK, and FILE_TYPE_REGULAR.
Referenced by sbuild::chroot_config::add_config_directory(), ctime(), sbuild::find_program_in_path(), sbuild::chroot_config::load_data(), sbuild::chroot_loopback::setup_lock(), and sbuild::chroot_file::setup_lock().
|
inline |
Is the file a socket?
References check_mode(), FILE_TYPE_MASK, and FILE_TYPE_SOCKET.
Referenced by ctime().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the user id owning the file.
References check(), and status.
Referenced by sbuild::chroot_config::load_data(), sbuild::chroot_loopback::setup_lock(), and sbuild::chroot_file::setup_lock().