class::sys::FileInfo

class sys::FileInfo
  : public api::SysInfoObject

The FileInfo 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>

FileInfo 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();

Methods

Details

publicFileInfo()

Constructs a new object.

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


public inlineFileInfo(const structstat& st)

Constructs a new object from the struct stat data provided.


public boolis_block_device() const

Returns true if the file is a block device.


public boolis_character_device() const

Returns true if the file is a character device.


public boolis_device() const

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


public boolis_directory() const

Returns true if the file is a directory.


public boolis_executable() const

Returns true if the file is executable.


public boolis_fifo() const

Returns true if the file is a FIFO.


public boolis_file() const

Returns true if the file is a regular file.


public boolis_socket() const

Returns true if the file is a socket.


public inline boolis_valid() const

Returns true if the object is valid.


public inline u32mode() const

Returns the file mode value.


public u32size() const

Returns the size of the file in bytes.

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


X

Thanks for Coming!

Subscribe to news and updates