AFIO  v2.00 late alpha
afio_v2_xxx::stat_t Struct Reference

Metadata about a directory entry. More...

#include "stat.hpp"

Public Types

enum  bitfield__want : unsigned {
  dev = 1 << 0, ino = 1 << 1, type = 1 << 2, perms = 1 << 3,
  nlink = 1 << 4, uid = 1 << 5, gid = 1 << 6, rdev = 1 << 7,
  atim = 1 << 8, mtim = 1 << 9, ctim = 1 << 10, size = 1 << 11,
  allocated = 1 << 12, blocks = 1 << 13, blksize = 1 << 14, flags = 1 << 15,
  gen = 1 << 16, birthtim = 1 << 17, sparse = 1 << 24, compressed = 1 << 25,
  reparse_point = 1 << 26, all = static_cast<unsigned>(-1), none = 0
}
 Used to indicate what metadata should be filled in.
 

Public Member Functions

 stat_t ()
 Constructs a UNINITIALIZED instance i.e. full of random garbage.
 
constexpr stat_t (std::nullptr_t) noexcept
 Constructs a zeroed instance.
 
result< size_t > fill (const handle &h, want wanted=want::all) noexcept
 Fills in the structure with metadata, returning number of items filled in.
 

Public Attributes

uint64_t st_dev
 
uint64_t st_ino
 
filesystem::file_type st_type
 
stil1z::filesystem::perms st_perms
 
int16_t st_nlink
 
int16_t st_uid
 
int16_t st_gid
 
dev_t st_rdev
 
std::chrono::system_clock::time_point st_atim
 
std::chrono::system_clock::time_point st_mtim
 
std::chrono::system_clock::time_point st_ctim
 
handle::extent_type st_size
 
handle::extent_type st_allocated
 
handle::extent_type st_blocks
 
uint16_t st_blksize
 
uint32_t st_flags
 
uint32_t st_gen
 
std::chrono::system_clock::time_point st_birthtim
 
unsigned st_sparse: 1
 
unsigned st_compressed: 1
 
unsigned st_reparse_point: 1
 

Detailed Description

Metadata about a directory entry.

This structure looks somewhat like a struct stat, and indeed it was derived from BSD's struct stat. However there are a number of changes to better interoperate with modern practice, specifically:

  • inode value containers are forced to 64 bits.
  • Timestamps use C++11's std::chrono::system_clock::time_point or Boost equivalent. The resolution of these may or may not equal what a struct timespec can do depending on your STL.
  • The type of a file, which is available on Windows and on POSIX without needing an additional syscall, is provided by st_type which is one of the values from filesystem::file_type.
  • As type is now separate from permissions, there is no longer a st_mode, instead being a st_perms which is solely the permissions bits. If you want to test permission bits in st_perms but don't want to include platform specific headers, note that filesystem::perms contains definitions of the POSIX permissions flags.
  • The st_sparse and st_compressed flags indicate if your file is sparse and/or compressed, or if the directory will compress newly created files by default. Note that on POSIX, a file is sparse if and only if st_allocated < st_size which can include compressed files if that filing system is mounted with compression enabled (e.g. ZFS with ZLE compression which elides runs of zeros).
  • The st_reparse_point is a Windows only flag and is never set on POSIX, even on a NTFS volume.

Member Data Documentation

◆ st_allocated

handle::extent_type afio_v2_xxx::stat_t::st_allocated

bytes allocated for file (Windows, POSIX)

◆ st_atim

std::chrono::system_clock::time_point afio_v2_xxx::stat_t::st_atim

time of last access (Windows, POSIX)

◆ st_birthtim

std::chrono::system_clock::time_point afio_v2_xxx::stat_t::st_birthtim

time of file creation (Windows, FreeBSD, OS X, zero otherwise)

◆ st_blksize

uint16_t afio_v2_xxx::stat_t::st_blksize

block size used by this device (Windows, POSIX)

◆ st_blocks

handle::extent_type afio_v2_xxx::stat_t::st_blocks

number of blocks allocated (Windows, POSIX)

◆ st_compressed

unsigned afio_v2_xxx::stat_t::st_compressed

if this file is compressed, or this directory capable of compressed files (Windows)

◆ st_ctim

std::chrono::system_clock::time_point afio_v2_xxx::stat_t::st_ctim

time of last status change (Windows, POSIX)

◆ st_dev

uint64_t afio_v2_xxx::stat_t::st_dev

inode of device containing file (POSIX only)

◆ st_flags

uint32_t afio_v2_xxx::stat_t::st_flags

user defined flags for file (FreeBSD, OS X, zero otherwise)

◆ st_gen

uint32_t afio_v2_xxx::stat_t::st_gen

file generation number (FreeBSD, OS X, zero otherwise)

◆ st_gid

int16_t afio_v2_xxx::stat_t::st_gid

group ID of the file (POSIX only)

◆ st_ino

uint64_t afio_v2_xxx::stat_t::st_ino

inode of file (Windows, POSIX)

◆ st_mtim

std::chrono::system_clock::time_point afio_v2_xxx::stat_t::st_mtim

time of last data modification (Windows, POSIX)

◆ st_nlink

int16_t afio_v2_xxx::stat_t::st_nlink

number of hard links (Windows, POSIX)

◆ st_perms

stil1z::filesystem::perms afio_v2_xxx::stat_t::st_perms

uint16_t bitfield perms of file (POSIX only)

◆ st_rdev

dev_t afio_v2_xxx::stat_t::st_rdev

id of file if special (POSIX only)

◆ st_reparse_point

unsigned afio_v2_xxx::stat_t::st_reparse_point

if this file or directory is a reparse point (Windows)

◆ st_size

handle::extent_type afio_v2_xxx::stat_t::st_size

file size, in bytes (Windows, POSIX)

◆ st_sparse

unsigned afio_v2_xxx::stat_t::st_sparse

if this file is sparse, or this directory capable of sparse files (Windows, POSIX)

◆ st_type

filesystem::file_type afio_v2_xxx::stat_t::st_type

type of file (Windows, POSIX)

◆ st_uid

int16_t afio_v2_xxx::stat_t::st_uid

user ID of the file (POSIX only)


The documentation for this struct was generated from the following file: