Represents metadata of a filesystem entry.
This type is the lightweight data container to hold file attributes such as:
Instances are typically populated with the overloaded method Update. The result of retrieval is reflected in the field ScanState and may indicate partial or failed retrieval (for example, non-existing paths or missing access rights).
FTValue are already reflected in this class. For example, the enumeration element FileStatus::Types::SYMBOLIC_LINK_DIR is never set with methods Update, but only when scanning file trees. While this can be considered an inconsistent API definition, this approach serves runtime efficiency.std::filesystem API is less feature-richt than what POSIX offers.Definition at line 41 of file filestatus.hpp.
#include <filestatus.hpp>
Inner Type Index: | |
| struct | Bits |
| A bitfield encoding various information. More... | |
Public Type Index: | |
| enum class | Permissions : uint32_t { NONE = 0 , UNKNOWN = 010000 , MASK = 07777 , ALL = 0777 , OWNER_READ = 0400 , OWNER_WRITE = 0200 , OWNER_EXEC = 0100 , OWNER_ALL = 0700 , GROUP_READ = 040 , GROUP_WRITE = 020 , GROUP_EXEC = 010 , GROUP_ALL = 070 , OTHERS_READ = 04 , OTHERS_WRITE = 02 , OTHERS_EXEC = 01 , OTHERS_ALL = 07 , SET_UID = 04000 , SET_GID = 02000 , STICKY_BIT = 01000 } |
| Permission flags. Compatible with POSIX definition. More... | |
| enum class | ScanStates : uint8_t { NONE = 0 , STATS = 1 , RESOLVED = 2 , MAX_DEPTH_REACHED = 3 , NOT_FOLLOWED = 4 , NOT_CROSSING_FS = 5 , NO_AFS = 6 , RECURSIVE = 7 , NO_ACCESS = 8 , NO_ACCESS_SL = 9 , NO_ACCESS_SL_TARGET =10 , NO_ACCESS_DIR =11 , BROKEN_LINK =12 , CIRCULAR_LINK =13 , DUPLICATE =14 , NOT_EXISTENT =15 , UNKNOWN_ERROR =16 } |
| Per-entry information about how a node was scanned. More... | |
| enum class | ScanStates3Letters : uint8_t { NONE = 0 , STATS = 1 , RESOLVED = 2 , MAX_DEPTH_REACHED = 3 , NOT_FOLLOWED = 4 , NOT_CROSSING_FS = 5 , NO_AFS = 6 , RECURSIVE = 7 , NO_ACCESS = 8 , NO_ACCESS_SL = 9 , NO_ACCESS_SL_TARGET =10 , NO_ACCESS_DIR =11 , BROKEN_LINK =12 , CIRCULAR_LINK =13 , DUPLICATE =14 , NOT_EXISTENT =15 , UNKNOWN_ERROR =16 } |
| using | TOwnerAndGroupID = uint32_t |
| Type definition for owner and group ids. | |
| enum class | TypeNames1Letter : uint8_t { DIRECTORY = 0 , SYMBOLIC_LINK_DIR = 1 , REGULAR = 2 , SYMBOLIC_LINK = 3 , BLOCK = 4 , CHARACTER = 5 , FIFO = 6 , SOCKET = 7 } |
| enum class | TypeNames2Letters : uint8_t { DIRECTORY = 0 , SYMBOLIC_LINK_DIR = 1 , REGULAR = 2 , SYMBOLIC_LINK = 3 , BLOCK = 4 , CHARACTER = 5 , FIFO = 6 , SOCKET = 7 } |
| enum class | TypeNames3Letters : uint8_t { DIRECTORY = 0 , SYMBOLIC_LINK_DIR = 1 , REGULAR = 2 , SYMBOLIC_LINK = 3 , BLOCK = 4 , CHARACTER = 5 , FIFO = 6 , SOCKET = 7 } |
| enum class | Types : uint8_t { DIRECTORY = 0 , SYMBOLIC_LINK_DIR = 1 , REGULAR = 2 , SYMBOLIC_LINK = 3 , BLOCK = 4 , CHARACTER = 5 , FIFO = 6 , SOCKET = 7 , UNKNOWN_OR_ERROR = 8 , MARKER_TYPES_END = 9 } |
Public Static Field Index: | |
| static constexpr TOwnerAndGroupID | UnknownID = (std::numeric_limits<uint32_t>::max)() |
| Constant value for owner and group IDs to denote that the field was not determined. | |
Public Method Index: | |
| FileStatus () | |
| Default constructor. | |
| FileStatus (Path &path, bool isCanonical=false) | |
| constexpr DateTime | ADate () const noexcept |
| constexpr DateTime | BDate () const noexcept |
| constexpr DateTime | CDate () const noexcept |
| const NString | GetGroupName () const |
| const NString | GetOwnerName () const |
| constexpr uint32_t | Group () const noexcept |
| constexpr bool | IsArtificialFS () const noexcept |
| constexpr bool | IsCrossingFS () const noexcept |
| constexpr bool | IsDirectory () const noexcept |
| constexpr bool | IsSymbolicLink () const noexcept |
| constexpr DateTime | MDate () const noexcept |
| constexpr uint32_t | Owner () const noexcept |
| constexpr Permissions | Perms () const noexcept |
| constexpr uint64_t | PosixDevice () const noexcept |
| constexpr uint32_t | QtyHardLinks () const noexcept |
| constexpr ScanStates | ScanState () const noexcept |
| void | SetADate (DateTime v) noexcept |
| void | SetArtificialFS () noexcept |
| Mark the entry as residing on an artificial filesystem. | |
| void | SetBDate (DateTime v) noexcept |
| void | SetCDate (DateTime v) noexcept |
| void | SetCrossingFS () noexcept |
| Mark the entry as residing on a different filesystem than its parent. | |
| void | SetGroup (uint32_t v) noexcept |
| void | SetMDate (DateTime v) noexcept |
| void | SetOwner (uint32_t v) noexcept |
| void | SetPerms (Permissions v) noexcept |
| void | SetPosixDevice (uint64_t deviceCode) noexcept |
| void | SetQtyHardlinks (uint32_t v) noexcept |
| void | SetScanState (ScanStates v) noexcept |
| void | SetSize (uinteger v) noexcept |
| void | SetTargetArtificialFS () noexcept |
| Mark the entry as a symlink who's target is residing on an artificial filesystem. | |
| void | SetTargetCrossingFS () noexcept |
| void | SetType (Types v) noexcept |
| constexpr uinteger | Size () const noexcept |
| constexpr bool | TargetIsArtificialFS () const noexcept |
| constexpr bool | TargetIsCrossingFS () const noexcept |
| constexpr Types | Type () const noexcept |
| ScanStates | Update (Path &path, bool isCanonical=false) |
| ScanStates | Update (std::filesystem::path &path, bool isCanonical=false) |
Protected Field Index: | |
| DateTime | aDate |
| DateTime | bDate |
| Bits | bits |
| A bitfield encoding various information. | |
| DateTime | cDate |
| uint64_t | device |
| uint32_t | group |
| The group id that owns the file. | |
| DateTime | mDate |
| uint32_t | owner |
| The user id that owns the file. | |
| uint32_t | qtyHardLinks |
| The number of hard links to the file. | |
| uinteger | size |
The file size. In case of a directory, this is 0. | |
| uinteger | symParent = 0 |
| using alib::system::FileStatus::TOwnerAndGroupID = uint32_t |
Type definition for owner and group ids.
Definition at line 133 of file filestatus.hpp.
|
strong |
Permission flags. Compatible with POSIX definition.
Definition at line 106 of file filestatus.hpp.
|
strong |
Per-entry information about how a node was scanned.
| Enumerator | |
|---|---|
| NONE | Node created only from the given start path. |
| STATS | Only stats (size, date, owner, etc.) read. |
| RESOLVED | Read symlink target strings. |
| MAX_DEPTH_REACHED | Scanning stopped because maximum depth was reached. |
| NOT_FOLLOWED | A symbolic link that targets a directory, but scan parameters specify not to follow. |
| NOT_CROSSING_FS | A directory that represented a mounted filesystem was not followed due to the field bool CrossFileSystems being set to |
| NO_AFS | A directory that represented a mounted filesystem was not followed due to the field bool IncludeArtificialFS being set to |
| RECURSIVE | Follow symlink target strings. |
| NO_ACCESS | Scanner failure due to limited access rights. |
| NO_ACCESS_SL | Scanner failure due to limited access rights on a symbolic link. |
| NO_ACCESS_SL_TARGET | Scanner failure due to limited access rights on a symbolic link's target. |
| NO_ACCESS_DIR | Scanner failure due to limited access rights on a directory. |
| BROKEN_LINK | A symbolic link targets a non-existent file or directory. |
| CIRCULAR_LINK | Set if recursion stopped at a symbolic link which was identified by the operating system as a circular link. |
| DUPLICATE | Set if recursion stopped on a symbolic link who's target had been scanned already. This might happen either because the path was already scanned by another search, or because a symbolic link is circular or because of a mixture of both. Thus, this can indicate a circular link, but does not have to. |
| NOT_EXISTENT | Set if a given start path does not exist. |
| UNKNOWN_ERROR | Unknown scanner failure. |
Definition at line 139 of file filestatus.hpp.
|
strong |
This is a resourced enumeration that is equivalent to enum class ScanStates but uses a 3-Letter code when serialized.
| Enumerator | |
|---|---|
| NONE | NON: Node created only from given start path path. |
| STATS | STA: Only stats (size, date, owner, etc.) read. |
| RESOLVED | RES: Read symlink target strings. |
| MAX_DEPTH_REACHED | MDR:Scanner stopped, because maximum depth was reached. |
| NOT_FOLLOWED | NFO:A symbolic link that targets a directory, but scan parameters specify not to follow. |
| NOT_CROSSING_FS | NCF:A directory that represented a mounted filesystem was not followed due to the field bool CrossFileSystems being set to |
| NO_AFS | NAF:A directory that represented a mounted filesystem was not followed due to the field bool IncludeArtificialFS being set to |
| RECURSIVE | REC:Follow symlink target strings. |
| NO_ACCESS | NAC: Scanner failure due to limited access rights. |
| NO_ACCESS_SL | NSL: Scanner failure due to limited access rights. |
| NO_ACCESS_SL_TARGET | NAT: Scanner failure due to limited access rights. |
| NO_ACCESS_DIR | NAD: Scanner failure due to limited access rights. |
| BROKEN_LINK | BRL: A symbolic link targets a non-existent file or directory. |
| CIRCULAR_LINK | CIL: Set if recursion stopped on a symbolic link which was identified by the operating system as a circular link. |
| DUPLICATE | DUP: Set if recursion stopped on a symbolic link who's target had been scanned already. This might happen either because the path was already scanned by another search, or because a symbolic link is circular or because of a mixture of both. Thus, this can indicate a circular link, but does not have to. |
| NOT_EXISTENT | NEX: Set if a given start path does not exist. |
| UNKNOWN_ERROR | UKE: Unknown scanner failure. |
Definition at line 170 of file filestatus.hpp.
|
strong |
This is a resourced enumeration that is equivalent to enum class Types but uses a 1-Letter code when serialized. The symbols are taken from GNU/Linux command 'ls -l', except special type SYMBOLIC_LINK_DIR which uses an upper case 'L' in contrast to the lower case 'l' used with links to files.
Definition at line 67 of file filestatus.hpp.
|
strong |
This is a resourced enumeration that is equivalent to enum class Types but uses a 2-Letter code when serialized.
Definition at line 80 of file filestatus.hpp.
|
strong |
This is a resourced enumeration that is equivalent to enum class Types but uses a 3-Letter code when serialized.
Definition at line 93 of file filestatus.hpp.
|
strong |
Enumeration of the possible file types. This is compatible with the POSIX list of types, with the exception that symbolic links are differentiated between those linking to a directory and those linking to any other file type.
Definition at line 46 of file filestatus.hpp.
|
protected |
The date of last read or write access. This is not correctly set on all platforms/filesystems. If not available, it will be set to mDate.
Definition at line 210 of file filestatus.hpp.
|
protected |
The date this file was created. This timestamp is correctly set only with certain filesystems under GNU/Linux, e.g., 'EXT4'. If not available, the smallest value of the other three timestamps is used.
Definition at line 203 of file filestatus.hpp.
|
protected |
A bitfield encoding various information.
Definition at line 243 of file filestatus.hpp.
|
protected |
The date of the last change of the files' meta-information (e.g., owner). This is not correctly set on all platforms/filesystems. If not available, it will be set to mDate.
Definition at line 207 of file filestatus.hpp.
|
protected |
The POSIX device ID. Available only if ALIB_SYSTEM_FILE_STATUS_IMPL equals ALIB_SYSTEM_FILE_POSIX_STATUS.
Definition at line 245 of file filestatus.hpp.
|
protected |
The group id that owns the file.
Definition at line 217 of file filestatus.hpp.
|
protected |
The last date and time the contents of the file was modified. This timestamp is should be correct on all platforms/filesystems.
Definition at line 201 of file filestatus.hpp.
|
protected |
The user id that owns the file.
Definition at line 216 of file filestatus.hpp.
|
protected |
The number of hard links to the file.
Definition at line 218 of file filestatus.hpp.
|
protected |
The file size. In case of a directory, this is 0.
Definition at line 215 of file filestatus.hpp.
|
protected |
A cursor handle to the symbolic parent. See manual chapter 2.3 Real-Paths for more information.
Definition at line 213 of file filestatus.hpp.
|
staticconstexpr |
Constant value for owner and group IDs to denote that the field was not determined.
Definition at line 136 of file filestatus.hpp.
|
inline |
Default constructor.
Definition at line 251 of file filestatus.hpp.
|
inline |
Constructor taking a path. Calls ScanStates Update(Path&, bool) .
| path | The file path to get the status for. |
| isCanonical | If given as true, then the caller guarantees that path does not resemble a symbolic link. Defaults to false, which causes the method to call Path::MakeCanonical on path first. |
Definition at line 261 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 312 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 308 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 310 of file filestatus.hpp.
|
nodiscard |
"?" is returned. Definition at line 17 of file filestatus.cpp.
|
nodiscard |
"?" is returned. Definition at line 8 of file filestatus.cpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 316 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 294 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 298 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 287 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 289 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 306 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 314 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 283 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 302 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 318 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 292 of file filestatus.hpp.
|
inlinenoexcept |
Sets the time of last access of this file/folder.
| v | The value to set. |
Definition at line 375 of file filestatus.hpp.
|
inlinenoexcept |
Mark the entry as residing on an artificial filesystem.
Definition at line 341 of file filestatus.hpp.
|
inlinenoexcept |
Sets the birth date of this file/folder.
| v | The value to set. |
Definition at line 367 of file filestatus.hpp.
|
inlinenoexcept |
Sets the change date of this file/folder.
| v | The value to set. |
Definition at line 371 of file filestatus.hpp.
|
inlinenoexcept |
Mark the entry as residing on a different filesystem than its parent.
Definition at line 347 of file filestatus.hpp.
|
inlinenoexcept |
Sets the ID of the group of the file/folder.
| v | The value to set. |
Definition at line 383 of file filestatus.hpp.
|
inlinenoexcept |
Sets the last modification date of this file/folder.
| v | The value to set. |
Definition at line 363 of file filestatus.hpp.
|
inlinenoexcept |
Sets the ID of the owner of the file/folder.
| v | The value to set. |
Definition at line 379 of file filestatus.hpp.
|
inlinenoexcept |
Sets the permissions of the entry.
| v | The value to set. |
Definition at line 330 of file filestatus.hpp.
|
inlinenoexcept |
Set the POSIX device code.
| deviceCode | The POSIX device code. |
Definition at line 351 of file filestatus.hpp.
|
inlinenoexcept |
Sets the number of hard links that point to this file.
| v | The value to set. |
Definition at line 387 of file filestatus.hpp.
|
inlinenoexcept |
Sets the state of scan of the entry.
| v | The value to set. |
Definition at line 338 of file filestatus.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
Mark the entry as a symlink who's target is residing on an artificial filesystem.
Definition at line 344 of file filestatus.hpp.
|
inlinenoexcept |
Mark the entry as a symlink who's target is residing in a different filesystem than the symlink.
Definition at line 355 of file filestatus.hpp.
|
inlinenoexcept |
Sets the type of the entry.
| v | The value to set. |
Definition at line 334 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 304 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 296 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 300 of file filestatus.hpp.
|
inlinenodiscardconstexprnoexcept |
Definition at line 285 of file filestatus.hpp.
| FileStatus::ScanStates alib::system::FileStatus::Update | ( | Path & | path, |
| bool | isCanonical = false ) |
Updates all members according to the given path.
| path | The file path to get the status for. |
| isCanonical | If given as true, then the caller guarantees that path does not resemble a symbolic link. Defaults to false, which causes the method to call Path::MakeCanonical on path first. |
Definition at line 56 of file filestatus.cpp.
| FileStatus::ScanStates alib::system::FileStatus::Update | ( | std::filesystem::path & | path, |
| bool | isCanonical = false ) |
Updates all members according to the given std::filesystem::path.
| path | The file path to get the status for. |
| isCanonical | If given as true, then the caller guarantees that path does not resemble a symbolic link. Defaults to false, which causes the method to call Path::MakeCanonical on path first. |
Definition at line 51 of file filestatus.cpp.