class::fs::Stat

class fs::Stat
  : public api::FsInfoObject

The Stat class is basically a wrapper of struct stat and provides information on the type and size of the file.

The file can be any filesystem object including a file, directory, or device.

#include <sapi/sys.hpp>

Info info = File::get_info("/home/test.txt");

if( info.is_file() ){
  printf("Is a file\n");
} else if( info.is_directory() ){
  printf("Is a directory\n");
}

//grabbing the info of an already open file
File file;
file.open("/home/test.txt", File::RDONLY);
//grab the info from a file that is already open
info = file.get_info();
file.close();

Members

Stat()
Stat(

const struct stat & st
)

bool is_block_device() const
bool is_character_device() const
bool is_device() const
bool is_directory() const
bool is_executable() const
bool is_fifo() const
bool is_file() const
bool is_socket() const
bool is_valid() const
Permissions permissions() const
u32 size() const
enum mode

Details

Stat()

Constructs a new object.

For the newly constructed object, is_valid() returns false.


Stat(

const struct stat & st
)

Constructs a new object from the struct stat data provided.


bool is_block_device() const

Returns true if the file is a block device.


bool is_character_device() const

Returns true if the file is a character device.


bool is_device() const

Returns true if the file is a device (block or character).


bool is_directory() const

Returns true if the file is a directory.


bool is_executable() const

Returns true if the file is executable.


bool is_fifo() const

Returns true if the file is a FIFO.


bool is_file() const

Returns true if the file is a regular file.


bool is_socket() const

Returns true if the file is a socket.


bool is_valid() const

Returns true if the object is valid.


Permissions permissions() const

Returns the file mode value.


u32 size() const

Returns the size of the file in bytes.

This method is only valid for regular files (ie is_file() must return true).


enum mode
  • FORMAT Mode format mask
  • FILE_SOCKET Mode Socket mask
  • REGULAR Mode regular file value
  • BLOCK Mode block device value
  • CHARACTER Mode character device value
  • DIRECTORY Mode directory value
  • FIFO Mode FIFO value
  • SYMBOLIC_LINK Mode symbolic link value

X

Thanks for Coming!

Subscribe to news and updates