ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
filestatus.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_system of the \aliblong.
4///
5/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8
9ALIB_EXPORT namespace alib { namespace system {
10
11/// Represents metadata of a filesystem entry.
12///
13/// This type is the lightweight data container to hold file attributes such as:
14/// - file type and scan state,
15/// - size, timestamps, ownership, permissions and hard-link count,
16/// - optional scan flags related to symlink resolution and filesystem boundaries.
17///
18/// Instances are typically populated with the overloaded method #"Update(Path)".
19/// The result of retrieval is reflected in the field #".ScanState" and may indicate partial or failed
20/// retrieval (for example, non-existing paths or missing access rights).
21///
22/// \par Relationship To Module \alib_filetree_nl
23/// The module \alibmod_nl \alib_filetree builds on this type by extending this type to the class
24/// #"FTValue" with scan- and file-tree-specific payload.
25/// With this, users of module \alib_filetree_nl gain additional features when scanning the file
26/// system, including symbolic-vs-real path handling, symbolic link resolving, symbolic parent
27/// tracking, and formatted file information output.<br>
28/// To keep the code efficient, some of the features that are available only with the class
29/// #"%FTValue" are already reflected in this class. For example, the enumeration element
30/// #"Types::SYMBOLIC_LINK_DIR;3" is never set with methods #".Update(Path)", but only when scanning
31/// file trees. While this can be considered an inconsistent API definition, this approach serves
32/// runtime efficiency.
33///
34/// \par Restrictions On Non-POSIX Systems
35/// Two versions of the implementation of overloaded methods #".Update(Path)" exist, which depend
36/// on the target system and optionally on the configuration macro
37/// #"ALIB_SYSTEM_FORCE_STD_FILE_STATUS". The non-POSIX version is restricted due to the fact
38/// that the \c std::filesystem API is less feature-richt than what POSIX offers.
39///
40/// @see Classes #"filetree::FTFile" and #"filetree::FTValue".
42 public:
43 /// Enumeration of the possible file types. This is compatible with the POSIX list of types,
44 /// with the exception that symbolic links are differentiated between those linking to
45 /// a directory and those linking to any other file type.
46 enum class Types : uint8_t {
47 DIRECTORY = 0, ///< Directory/folder.
48 SYMBOLIC_LINK_DIR = 1, ///< Symbolic link targeting a directory.
49 ///< In case scanning does not resolve links, this is never set.
50 REGULAR = 2, ///< Regular file.
51 SYMBOLIC_LINK = 3, ///< Symbolic link targeting a non-directory file.
52 ///< In case scanning does not resolve links, possibly to a directory.
53 BLOCK = 4, ///< A block special file.
54 CHARACTER = 5, ///< A character special file.
55 FIFO = 6, ///< A FIFO (also known as pipe) file.
56 SOCKET = 7, ///< A socket file.
57
58 UNKNOWN_OR_ERROR = 8, ///< Filetype (should never or seldom happen).
59 ///< Maybe filesystem changed during scan or similar strange thing.
60 MARKER_TYPES_END = 9, ///< A marker for the last countable type. The rest are unused/errors
61 };
62
63 /// This is a resourced enumeration that is equivalent to enum class #".Types" but uses
64 /// a 1-Letter code when serialized. The symbols are taken from GNU/Linux command
65 /// <c>'ls -l'</c>, except special type \b SYMBOLIC_LINK_DIR which uses an upper case <c>'L'</c>
66 /// in contrast to the lower case <c>'l'</c> used with links to files.
67 enum class TypeNames1Letter : uint8_t {
68 DIRECTORY = 0, ///< d: Directory/folder.
69 SYMBOLIC_LINK_DIR = 1, ///< L: Symbolic link targeting a directory.
70 REGULAR = 2, ///< -: Regular file.
71 SYMBOLIC_LINK = 3, ///< l: Symbolic link targeting a non-directory file.
72 BLOCK = 4, ///< b: A block special file.
73 CHARACTER = 5, ///< c: A character special file.
74 FIFO = 6, ///< p: A FIFO (also known as pipe) file.
75 SOCKET = 7, ///< s: A socket file.
76 };
77
78 /// This is a resourced enumeration that is equivalent to enum class #".Types" but uses
79 /// a 2-Letter code when serialized.
80 enum class TypeNames2Letters : uint8_t {
81 DIRECTORY = 0, ///< DR: Directory/folder.
82 SYMBOLIC_LINK_DIR = 1, ///< LD: Symbolic link targeting a directory.
83 REGULAR = 2, ///< RF: Regular file.
84 SYMBOLIC_LINK = 3, ///< LF: Symbolic link targeting a non-directory file.
85 BLOCK = 4, ///< BL: A block special file.
86 CHARACTER = 5, ///< CH: A character special file.
87 FIFO = 6, ///< FF: A FIFO (also known as pipe) file.
88 SOCKET = 7, ///< SO: A socket file.
89 };
90
91 /// This is a resourced enumeration that is equivalent to enum class #".Types" but uses
92 /// a 3-Letter code when serialized.
93 enum class TypeNames3Letters : uint8_t {
94 DIRECTORY = 0, ///< DIR: Directory/folder.
95 SYMBOLIC_LINK_DIR = 1, ///< SLD: Symbolic link targeting a directory.
96 REGULAR = 2, ///< REG: Regular file.
97 SYMBOLIC_LINK = 3, ///< SLF: Symbolic link targeting a non-directory file.
98 BLOCK = 4, ///< BLK: A block special file.
99 CHARACTER = 5, ///< CHR: A character special file.
100 FIFO = 6, ///< FFO: A FIFO (also known as pipe) file.
101 SOCKET = 7, ///< SCK: A socket file.
102 };
103
104
105 /// Permission flags. Compatible with POSIX definition.
106 enum class Permissions : uint32_t {
107 NONE = 0, ///< no permission bits are set
108 UNKNOWN = 010000, ///< Unknown permissions (e.g., when not read, or filesystem does not support permissions)
109 MASK = 07777, ///< All valid permission bits. Equivalent to all | set_uid | set_gid | sticky_bit
110 ALL = 0777, ///< All users have read, write, and execute/search permissions Equivalent to owner_all | group_all | others_all
111
112 OWNER_READ = 0400, ///< Posix \b S_IRUSR: File owner has read permission
113 OWNER_WRITE = 0200, ///< Posix \b S_IWUSR: File owner has write permission
114 OWNER_EXEC = 0100, ///< Posix \b S_IXUSR: File owner has execute/search permission
115 OWNER_ALL = 0700, ///< Posix \b S_IRWXU: File owner has read, write, and execute/search permissions Equivalent to owner_read | owner_write | owner_exec
116
117 GROUP_READ = 040, ///< Posix \b S_IRGRP: The file's user group has read permission
118 GROUP_WRITE = 020, ///< Posix \b S_IWGRP: The file's user group has write permission
119 GROUP_EXEC = 010, ///< Posix \b S_IXGRP: The file's user group has execute/search permission
120 GROUP_ALL = 070, ///< Posix \b S_IRWXG: The file's user group has read, write, and execute/search permissions Equivalent to group_read | group_write | group_exec
121
122 OTHERS_READ = 04, ///< Posix \b S_IROTH: Other users have read permission
123 OTHERS_WRITE = 02, ///< Posix \b S_IWOTH: Other users have write permission
124 OTHERS_EXEC = 01, ///< Posix \b S_IXOTH: Other users have execute/search permission
125 OTHERS_ALL = 07, ///< Posix \b S_IRWXO: Other users have read, write, and execute/search permissions Equivalent to others_read | others_write | others_exec
126
127 SET_UID = 04000, ///< Posix \b S_ISUID: Set user ID to file owner user ID on execution
128 SET_GID = 02000, ///< Posix \b S_ISGID: Set group ID to file's user group ID on execution
129 STICKY_BIT = 01000, ///< Posix \b S_ISVTX: Implementation-defined meaning, but POSIX XSI specifies that when set on a directory, only file owners may delete files even if the directory is writeable to others (used with /tmp)
130 };
131
132 /// Type definition for owner and group ids
133 using TOwnerAndGroupID = uint32_t;
134
135 /// Constant value for owner and group IDs to denote that the field was not determined.
136 static constexpr TOwnerAndGroupID UnknownID= (std::numeric_limits<uint32_t>::max)();
137
138 /// Per-entry information about how a node was scanned.
139 enum class ScanStates : uint8_t {
140 NONE = 0, ///< Node created only from the given start path.
141 STATS = 1, ///< Only stats (size, date, owner, etc.) read.
142
143 RESOLVED = 2, ///< Read symlink target strings.
144
145 MAX_DEPTH_REACHED = 3, ///< Scanning stopped because maximum depth was reached.
146 NOT_FOLLOWED = 4, ///< A symbolic link that targets a directory, but scan parameters specify not to follow.
147 NOT_CROSSING_FS = 5, ///< A directory that represented a mounted filesystem was not followed due to the field
148 ///< #"ScanParameters::CrossFileSystems;*" being set to \c false.
149 NO_AFS = 6, ///< A directory that represented a mounted filesystem was not followed due to the field
150 ///< #"ScanParameters::IncludeArtificialFS;*" being set to \c false.
151 RECURSIVE = 7, ///< Follow symlink target strings.
152
153 NO_ACCESS = 8, ///< Scanner failure due to limited access rights.
154 NO_ACCESS_SL = 9, ///< Scanner failure due to limited access rights on a symbolic link.
155 NO_ACCESS_SL_TARGET=10, ///< Scanner failure due to limited access rights on a symbolic link's target.
156 NO_ACCESS_DIR =11, ///< Scanner failure due to limited access rights on a directory.
157 BROKEN_LINK =12, ///< A symbolic link targets a non-existent file or directory.
158 CIRCULAR_LINK =13, ///< Set if recursion stopped at a symbolic link which was identified by the
159 ///< operating system as a circular link.
160 DUPLICATE =14, ///< Set if recursion stopped on a symbolic link who's target had been scanned already.
161 ///< This might happen either because the path was already scanned by another search, or
162 ///< because a symbolic link is circular or because of a mixture of both.
163 ///< Thus, this can indicate a circular link, but does not have to.
164 NOT_EXISTENT =15, ///< Set if a given start path does not exist.
165 UNKNOWN_ERROR =16, ///< Unknown scanner failure
166 };
167
168 /// This is a resourced enumeration that is equivalent to enum class #"ScanStates" but uses
169 /// a 3-Letter code when serialized.
170 enum class ScanStates3Letters : uint8_t {
171 NONE = 0, ///< NON: Node created only from given start path path.
172 STATS = 1, ///< STA: Only stats (size, date, owner, etc.) read.
173
174 RESOLVED = 2, ///< RES: Read symlink target strings.
175
176 MAX_DEPTH_REACHED = 3, ///< MDR:Scanner stopped, because maximum depth was reached.
177 NOT_FOLLOWED = 4, ///< NFO:A symbolic link that targets a directory, but scan parameters specify not to follow.
178 NOT_CROSSING_FS = 5, ///< NCF:A directory that represented a mounted filesystem was not followed due to the field
179 ///< #"ScanParameters::CrossFileSystems;*" being set to \c false.
180 NO_AFS = 6, ///< NAF:A directory that represented a mounted filesystem was not followed due to the field
181 ///< #"ScanParameters::IncludeArtificialFS;*" being set to \c false.
182 RECURSIVE = 7, ///< REC:Follow symlink target strings.
183
184 NO_ACCESS = 8, ///< NAC: Scanner failure due to limited access rights.
185 NO_ACCESS_SL = 9, ///< NSL: Scanner failure due to limited access rights.
186 NO_ACCESS_SL_TARGET=10, ///< NAT: Scanner failure due to limited access rights.
187 NO_ACCESS_DIR =11, ///< NAD: Scanner failure due to limited access rights.
188 BROKEN_LINK =12, ///< BRL: A symbolic link targets a non-existent file or directory.
189 CIRCULAR_LINK =13, ///< CIL: Set if recursion stopped on a symbolic link which was identified by the
190 ///< operating system as a circular link.
191 DUPLICATE =14, ///< DUP: Set if recursion stopped on a symbolic link who's target had been scanned already.
192 ///< This might happen either because the path was already scanned by another search, or
193 ///< because a symbolic link is circular or because of a mixture of both.
194 ///< Thus, this can indicate a circular link, but does not have to.
195 NOT_EXISTENT =15, ///< NEX: Set if a given start path does not exist.
196 UNKNOWN_ERROR =16, ///< UKE: Unknown scanner failure
197 };
198
199
200 protected:
201 DateTime mDate; ///< The last date and time the contents of the file was modified.
202 ///< This timestamp is should be correct on all platforms/filesystems.
203 DateTime bDate; ///< The date this file was created. This timestamp is correctly set
204 ///< only with certain filesystems under GNU/Linux, e.g., 'EXT4'.
205 ///< If not available, the smallest value of the other three timestamps
206 ///< is used.
207 DateTime cDate; ///< The date of the last change of the files' meta-information
208 ///< (e.g., owner). This is not correctly set on all
209 ///< platforms/filesystems. If not available, it will be set to #".mDate".
210 DateTime aDate; ///< The date of last read or write access.
211 ///< This is not correctly set on all platforms/filesystems.
212 ///< If not available, it will be set to #".mDate".
213 uinteger symParent= 0; ///< A cursor handle to the symbolic parent. See manual chapter
214 ///< #"alib_filetree_tut_scan_realpath" for more information.
215 uinteger size; ///< The file size. In case of a directory, this is \c 0.
216 uint32_t owner; ///< The user id that owns the file.
217 uint32_t group; ///< The group id that owns the file.
218 uint32_t qtyHardLinks; ///< The number of hard links to the file.
219
220
221 /// A bitfield encoding various information.
222 struct Bits {
223 Types Type : 4; ///< The file type.
224 bool IsArtificialFS : 1; ///< Denotes whether the file resides in an artificial filesystem.
225 bool TargetIsArtificialFS: 1; ///< Denotes whether a link points into an artificial filesystem.
226 bool IsCrossingFS : 1; ///< Denotes whether the file is a mount point.
227 bool TargetIsCrossingFS : 1; ///< Denotes whether a link points to a mount point.
228 Permissions Permission : 13; ///< The unix file-permissions.
229 ScanStates ScanState : 5; ///< The scan state.
230
231 /// Default constructor. Sets all members to #"Permissions::NONE", \c false, respectively
232 /// #"Types::UNKNOWN_OR_ERROR".
235 , IsArtificialFS {false}
236 , TargetIsArtificialFS{false}
237 , IsCrossingFS {false}
238 , TargetIsCrossingFS {false}
240 , ScanState {ScanStates::NONE } {}
241 };
242
243 Bits bits; ///< A bitfield encoding various information.
244
245 uint64_t device; ///< The POSIX device ID. Available only if
246 ///< #"ALIB_SYSTEM_FILE_STATUS_IMPL" equals
247 ///< #"ALIB_SYSTEM_FILE_POSIX_STATUS".
248
249 public:
250 /// Default constructor
251 FileStatus() : mDate{lang::Initialization::Nulled}, bDate{lang::Initialization::Nulled},
252 cDate{lang::Initialization::Nulled}, aDate{lang::Initialization::Nulled},
253 size{0}, owner{0}, group{0},
254 qtyHardLinks{0}, device{0} {}
255
256 /// Constructor taking a path. Calls #".Update(Path);*".
257 /// @param path The file path to get the status for.
258 /// @param isCanonical If given as \c true, then the caller guarantees that \p{path} does not
259 /// resemble a symbolic link. Defaults to \c false, which causes the
260 /// method to call #"MakeCanonical;2" on \p{path} first.
261 FileStatus(Path& path, bool isCanonical= false) { Update(path, isCanonical); }
262
263 /// Updates all members according to the given path.
264 /// @param path The file path to get the status for.
265 /// @param isCanonical If given as \c true, then the caller guarantees that \p{path} does not
266 /// resemble a symbolic link. Defaults to \c false, which causes the
267 /// method to call #"MakeCanonical;2" on \p{path} first.
268 /// @return The result of retrieving the given filePaths' state.
270 ScanStates Update(Path& path, bool isCanonical= false);
271
272 /// Updates all members according to the given <c>std::filesystem::path</c>.
273 /// @param path The file path to get the status for.
274 /// @param isCanonical If given as \c true, then the caller guarantees that \p{path} does not
275 /// resemble a symbolic link. Defaults to \c false, which causes the
276 /// method to call #"MakeCanonical;2" on \p{path} first.
277 /// @return The result of retrieving the given filePaths' state.
279 ScanStates Update(std::filesystem::path& path, bool isCanonical= false);
280
281
282 /// @return Retrieves the permissions of the entry.
283 [[nodiscard]] constexpr Permissions Perms () const noexcept { return bits.Permission; }
284 /// @return Retrieves the type of the entry
285 [[nodiscard]] constexpr Types Type () const noexcept { return bits.Type; }
286 /// @return Checks type for being either directory or symbolic link pointing to one.
287 [[nodiscard]] constexpr bool IsDirectory () const noexcept { return int(bits.Type) < 2; }
288 /// @return Checks type for being a symbolic link (to normal file or to a directory).
289 [[nodiscard]] constexpr bool IsSymbolicLink () const noexcept { return Type() == Types::SYMBOLIC_LINK
291 /// @return Retrieves the scan sate of the entry.
292 [[nodiscard]] constexpr ScanStates ScanState () const noexcept { return bits.ScanState ; }
293 /// @return Returns true if the entry resides on an artificial filesystem.
294 [[nodiscard]] constexpr bool IsArtificialFS () const noexcept { return bits.IsArtificialFS; }
295 /// @return Returns true if the entry is a symlink and its target resides on an artificial filesystem.
296 [[nodiscard]] constexpr bool TargetIsArtificialFS() const noexcept { return bits.TargetIsArtificialFS; }
297 /// @return Returns true if the entry resides on a different filesystem than it's parent.
298 [[nodiscard]] constexpr bool IsCrossingFS () const noexcept { return bits.IsCrossingFS; }
299 /// @return Returns true if the entry is a symlink and resides on a different filesystem than the link.
300 [[nodiscard]] constexpr bool TargetIsCrossingFS () const noexcept { return bits.TargetIsCrossingFS; }
301 /// @return Returns the POSIX device code.
302 [[nodiscard]] constexpr uint64_t PosixDevice () const noexcept { return device; }
303 /// @return Retrieves the file size.
304 [[nodiscard]] constexpr uinteger Size () const noexcept { return size; }
305 /// @return Retrieves the #"mDate;last modification date" of this file/folder.
306 [[nodiscard]] constexpr DateTime MDate () const noexcept { return mDate; }
307 /// @return Retrieves the #"bDate;birth date" of this file/folder.
308 [[nodiscard]] constexpr DateTime BDate () const noexcept { return bDate; }
309 /// @return Retrieves the #"cDate;change date" of this file/folder. If unavailable, same as #".MDate".
310 [[nodiscard]] constexpr DateTime CDate () const noexcept { return cDate; }
311 /// @return Retrieves the #"aDate;timestamp of last access" to this file/folder. If unavailable, same as #".MDate".
312 [[nodiscard]] constexpr DateTime ADate () const noexcept { return aDate; }
313 /// @return Retrieves the ID of the owner of the file/folder if available. Otherwise set to #".UnknownID".
314 [[nodiscard]] constexpr uint32_t Owner () const noexcept { return owner; }
315 /// @return Retrieves the ID of the group of the file/folder if available. Otherwise set to #".UnknownID".
316 [[nodiscard]] constexpr uint32_t Group () const noexcept { return group; }
317 /// @return Retrieves the number of hard links pointing to this file if available. Otherwise set to #".UnknownID".
318 [[nodiscard]] constexpr uint32_t QtyHardLinks () const noexcept { return qtyHardLinks; }
319
320 /// @return Retrieves the name of the owner of the file/folder if available.
321 /// Otherwise, and on the WindowsOS platform, <c>"?"</c> is returned.
322 ALIB_DLL [[nodiscard]] const NString GetOwnerName() const;
323
324 /// @return Retrieves the name of the group of the file/folder if available.
325 /// Otherwise, and on the WindowsOS platform, <c>"?"</c> is returned.
326 ALIB_DLL [[nodiscard]] const NString GetGroupName() const;
327
328 /// Sets the permissions of the entry.
329 /// @param v The value to set.
330 void SetPerms (Permissions v) noexcept { bits.Permission= v; }
331
332 /// Sets the type of the entry.
333 /// @param v The value to set.
334 void SetType (Types v) noexcept { bits.Type= v; }
335
336 /// Sets the state of scan of the entry.
337 /// @param v The value to set.
338 void SetScanState (ScanStates v) noexcept { bits.ScanState= v; }
339
340 /// Mark the entry as residing on an artificial filesystem.
341 void SetArtificialFS() noexcept { bits.IsArtificialFS= true; }
342
343 /// Mark the entry as a symlink who's target is residing on an artificial filesystem.
344 void SetTargetArtificialFS() noexcept { bits.TargetIsArtificialFS=true; }
345
346 /// Mark the entry as residing on a different filesystem than its parent.
347 void SetCrossingFS() noexcept { bits.IsCrossingFS= true; }
348
349 /// Set the POSIX device code.
350 /// @param deviceCode The POSIX device code.
351 void SetPosixDevice(uint64_t deviceCode) noexcept { device= deviceCode; }
352
353 /// Mark the entry as a symlink who's target is residing in a different filesystem than the
354 /// symlink.
355 void SetTargetCrossingFS() noexcept { bits.TargetIsCrossingFS=true; }
356
357 /// Sets the file size.
358 /// @param v The value to set.
359 void SetSize (uinteger v) noexcept { size = v; }
360
361 /// Sets the #"mDate;last modification date" of this file/folder.
362 /// @param v The value to set.
363 void SetMDate (DateTime v) noexcept { mDate= v; }
364
365 /// Sets the #"bDate;birth date" of this file/folder.
366 /// @param v The value to set.
367 void SetBDate (DateTime v) noexcept { bDate= v; }
368
369 /// Sets the #"cDate;change date" of this file/folder.
370 /// @param v The value to set.
371 void SetCDate (DateTime v) noexcept { cDate= v; }
372
373 /// Sets the #"aDate;time of last access" of this file/folder.
374 /// @param v The value to set.
375 void SetADate (DateTime v) noexcept { aDate= v; }
376
377 /// Sets the ID of the owner of the file/folder.
378 /// @param v The value to set.
379 void SetOwner (uint32_t v) noexcept { owner= v; }
380
381 /// Sets the ID of the group of the file/folder.
382 /// @param v The value to set.
383 void SetGroup (uint32_t v) noexcept { group= v; }
384
385 /// Sets the number of hard links that point to this file.
386 /// @param v The value to set.
387 void SetQtyHardlinks(uint32_t v) noexcept { qtyHardLinks= v; }
388}; // class FTValue
389
390
391} // namespace alib[::system]
392
393
394/// Type alias in namespace #"%alib".
396
397} // namespace [alib]
398
408//ALIB_RESOURCED_IN_CAMP(alib::system::FileStatus::Types , alib::FILETREE, "FT" )
409//ALIB_RESOURCED_IN_CAMP(alib::system::FileStatus::TypeNames1Letter , alib::FILETREE, "FT1" )
410//ALIB_RESOURCED_IN_CAMP(alib::system::FileStatus::TypeNames2Letters , alib::FILETREE, "FT2" )
411//ALIB_RESOURCED_IN_CAMP(alib::system::FileStatus::TypeNames3Letters , alib::FILETREE, "FT3" )
412//ALIB_RESOURCED_IN_CAMP(alib::system::FileStatus::ScanStates , alib::FILETREE, "FQ" )
413//ALIB_RESOURCED_IN_CAMP(alib::system::FileStatus::ScanStates3Letters , alib::FILETREE, "FQ3" )
414
415
#define ALIB_DLL
#define ALIB_EXPORT
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
constexpr DateTime BDate() const noexcept
@ MARKER_TYPES_END
A marker for the last countable type. The rest are unused/errors.
@ CHARACTER
A character special file.
@ BLOCK
A block special file.
@ FIFO
A FIFO (also known as pipe) file.
constexpr DateTime MDate() const noexcept
void SetScanState(ScanStates v) noexcept
constexpr uint32_t Owner() const noexcept
void SetType(Types v) noexcept
constexpr uinteger Size() const noexcept
void SetCrossingFS() noexcept
Mark the entry as residing on a different filesystem than its parent.
const NString GetOwnerName() const
Definition filestatus.cpp:8
void SetArtificialFS() noexcept
Mark the entry as residing on an artificial filesystem.
constexpr uint32_t QtyHardLinks() const noexcept
void SetADate(DateTime v) noexcept
uinteger size
The file size. In case of a directory, this is 0.
FileStatus()
Default constructor.
constexpr bool IsCrossingFS() const noexcept
constexpr uint64_t PosixDevice() const noexcept
uint32_t group
The group id that owns the file.
constexpr bool IsSymbolicLink() const noexcept
void SetMDate(DateTime v) noexcept
constexpr Types Type() const noexcept
uint32_t owner
The user id that owns the file.
constexpr Permissions Perms() const noexcept
void SetTargetCrossingFS() noexcept
constexpr DateTime ADate() const noexcept
void SetSize(uinteger v) noexcept
constexpr uint32_t Group() const noexcept
FileStatus(Path &path, bool isCanonical=false)
Permissions
Permission flags. Compatible with POSIX definition.
@ MASK
All valid permission bits. Equivalent to all | set_uid | set_gid | sticky_bit.
@ GROUP_READ
Posix S_IRGRP: The file's user group has read permission.
@ OTHERS_ALL
Posix S_IRWXO: Other users have read, write, and execute/search permissions Equivalent to others_read...
@ GROUP_EXEC
Posix S_IXGRP: The file's user group has execute/search permission.
@ OTHERS_EXEC
Posix S_IXOTH: Other users have execute/search permission.
@ GROUP_WRITE
Posix S_IWGRP: The file's user group has write permission.
@ ALL
All users have read, write, and execute/search permissions Equivalent to owner_all | group_all | othe...
@ UNKNOWN
Unknown permissions (e.g., when not read, or filesystem does not support permissions).
@ OWNER_ALL
Posix S_IRWXU: File owner has read, write, and execute/search permissions Equivalent to owner_read | ...
@ OWNER_READ
Posix S_IRUSR: File owner has read permission.
@ STICKY_BIT
Posix S_ISVTX: Implementation-defined meaning, but POSIX XSI specifies that when set on a directory,...
@ SET_UID
Posix S_ISUID: Set user ID to file owner user ID on execution.
@ OWNER_EXEC
Posix S_IXUSR: File owner has execute/search permission.
@ SET_GID
Posix S_ISGID: Set group ID to file's user group ID on execution.
@ NONE
no permission bits are set
@ OWNER_WRITE
Posix S_IWUSR: File owner has write permission.
@ OTHERS_READ
Posix S_IROTH: Other users have read permission.
@ OTHERS_WRITE
Posix S_IWOTH: Other users have write permission.
@ GROUP_ALL
Posix S_IRWXG: The file's user group has read, write, and execute/search permissions Equivalent to gr...
void SetOwner(uint32_t v) noexcept
void SetPerms(Permissions v) noexcept
static constexpr TOwnerAndGroupID UnknownID
Constant value for owner and group IDs to denote that the field was not determined.
Bits bits
A bitfield encoding various information.
const NString GetGroupName() const
constexpr bool TargetIsArtificialFS() const noexcept
void SetBDate(DateTime v) noexcept
constexpr bool TargetIsCrossingFS() const noexcept
constexpr DateTime CDate() const noexcept
uint32_t TOwnerAndGroupID
Type definition for owner and group ids.
ScanStates Update(Path &path, bool isCanonical=false)
uint32_t qtyHardLinks
The number of hard links to the file.
constexpr bool IsDirectory() const noexcept
void SetPosixDevice(uint64_t deviceCode) noexcept
constexpr ScanStates ScanState() const noexcept
void SetCDate(DateTime v) noexcept
constexpr bool IsArtificialFS() const noexcept
ScanStates
Per-entry information about how a node was scanned.
@ RECURSIVE
Follow symlink target strings.
@ STATS
Only stats (size, date, owner, etc.) read.
@ NO_ACCESS_DIR
Scanner failure due to limited access rights on a directory.
@ MAX_DEPTH_REACHED
Scanning stopped because maximum depth was reached.
@ RESOLVED
Read symlink target strings.
@ NO_ACCESS_SL
Scanner failure due to limited access rights on a symbolic link.
@ UNKNOWN_ERROR
Unknown scanner failure.
@ BROKEN_LINK
A symbolic link targets a non-existent file or directory.
@ NO_ACCESS_SL_TARGET
Scanner failure due to limited access rights on a symbolic link's target.
@ NOT_FOLLOWED
A symbolic link that targets a directory, but scan parameters specify not to follow.
@ NO_ACCESS
Scanner failure due to limited access rights.
@ NOT_EXISTENT
Set if a given start path does not exist.
void SetQtyHardlinks(uint32_t v) noexcept
void SetTargetArtificialFS() noexcept
Mark the entry as a symlink who's target is residing on an artificial filesystem.
void SetGroup(uint32_t v) noexcept
#define ALIB_ENUMS_MAKE_BITWISE(TEnum)
#define ALIB_ENUMS_MAKE_ITERABLE(TEnum, StopElement)
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
Definition alox.cpp:14
strings::TString< nchar > NString
Type alias in namespace #"%alib".
Definition string.hpp:2174
system::FileStatus FileStatus
Type alias in namespace #"%alib".
lang::uinteger uinteger
Type alias in namespace #"%alib".
Definition integers.hpp:152
time::DateTime DateTime
Type alias in namespace #"%alib".
Definition datetime.hpp:188
A bitfield encoding various information.
bool IsArtificialFS
Denotes whether the file resides in an artificial filesystem.
bool TargetIsCrossingFS
Denotes whether a link points to a mount point.
ScanStates ScanState
The scan state.
bool IsCrossingFS
Denotes whether the file is a mount point.
bool TargetIsArtificialFS
Denotes whether a link points into an artificial filesystem.
Permissions Permission
The unix file-permissions.