8#ifndef HPP_ALIB_FILES_FINFO
9#define HPP_ALIB_FILES_FINFO 1
19namespace alib {
namespace files {
248 return int(type) < 2;
278 "FILES",
"Cant get count for file type {!Q}", type )
422 [[nodiscard]]
constexpr uint32_t
Owner () const noexcept {
return owner; }
424 [[nodiscard]]
constexpr uint32_t
Group () const noexcept {
return group; }
447 "Requesting sums for FInfo that is not a directory.")
449 "Requesting sums for FInfo that has no sums set. Quality: ",
Quality() )
466 "Given node is not a directory or symbolic link pointing to a directory.")
486 "Given node is not a symbolic link.")
500 "Given node is not a symbolic link.")
549 #if !defined( _WIN32)
558 #if DOXYGEN || !defined( _WIN32)
563 : ownerCache(poolAllocator, 6,6)
564 , groupCache(poolAllocator, 6,6) {}
584 #elif !defined( _WIN32)
586 { ownerCache.
Reserve( numberOfLists, entriesPerList ); }
588 { groupCache.
Reserve( numberOfLists, entriesPerList); }
void Reserve(integer newQtyLists, integer newQtyEntriesPerList)
The entry type which is embedded in each tree node.
lang::system::CPathString & GetLinkTarget() const noexcept
uint32_t group
The group id that owns the file.
uint32_t owner
The user id that owns the file.
void SetOwner(uint32_t v) noexcept
Sets the ID of the owner of the file/folder.
constexpr bool IsSymbolicLink() const noexcept
static constexpr TOwnerAndGroupID UnknownID
Constant value for owner and group IDs to denote that the field was not determined.
void SetCDate(DateTime v) noexcept
Sets the change date of this file/folder.
Bits bits
A bitfield encoding various information.
constexpr bool TargetIsArtificialFS() const noexcept
constexpr Permissions Perms() const noexcept
constexpr uint32_t Group() const noexcept
constexpr void SetSums(const DirectorySums &sums) const
void SetBDate(DateTime v) noexcept
Sets the birth date of this file/folder.
void SetTargetArtificialFS() noexcept
Mark the entry as a symlink who's target is residing on an artificial filesystem.
constexpr DateTime MDate() const noexcept
uint32_t TOwnerAndGroupID
Type definition for owner and group ids.
uint32_t qtyHardLinks
The number of hard links to the file.
constexpr void SetExtendedInfo(ExtendedEntryInfo *extInfo)
constexpr DirectorySums & Sums() const
void SetLinkTarget(FTree &tree, const lang::system::PathString &target, const lang::system::PathString &realTarget)
void SetQtyHardlinks(uint32_t v) noexcept
Sets the number of hard links that point to this file.
void SetTargetCrossingFS() noexcept
Mark the entry as a symlink who's target is residing on a different filesystem than the symlink.
constexpr uinteger Size() const noexcept
constexpr uint32_t QtyHardLinks() const noexcept
ExtendedEntryInfo * extendedInfo
Extended information, depending on the entry type.
Permissions
Permission flags. Compatible with posix* definition.
@ MASK
All valid permission bits. Equivalent to all | set_uid | set_gid | sticky_bit.
@ GROUP_READ
< S_IRWXU File owner has read, write, and execute/search permissions Equivalent to owner_read | owner...
@ OTHERS_ALL
S_IRWXO Other users have read, write, and execute/search permissions Equivalent to others_read | othe...
@ GROUP_EXEC
< S_IWGRP The file's user group has write permission
@ OTHERS_EXEC
S_IXOTH Other users have execute/search permission.
@ GROUP_WRITE
< S_IRGRP The file's user group has read 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
< S_IXUSR File owner has execute/search permission
@ STICKY_BIT
S_ISVTX Implementation-defined meaning, but POSIX XSI specifies that when set on a directory,...
@ SET_UID
S_ISUID Set user ID to file owner user ID on execution.
@ OWNER_EXEC
< S_IWUSR File owner has write permission
@ SET_GID
S_ISGID Set group ID to file's user group ID on execution.
@ NONE
no permission bits are set
@ OWNER_WRITE
< S_IRUSR File owner has read permission
@ OTHERS_READ
< S_IRWXG The file's user group has read, write, and execute/search permissions Equivalent to group_r...
@ OTHERS_WRITE
S_IWOTH Other users have write permission.
@ GROUP_ALL
< S_IXGRP The file's user group has execute/search permission
constexpr ExtendedEntryInfo * GetExtendedInfo() const
void SetADate(DateTime v) noexcept
Sets the time of last access of this file/folder.
void SetQuality(Qualities v) noexcept
Sets the quality of scan of the entry.
constexpr bool IsCrossingFS() const noexcept
Qualities
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.
@ MAX_DEPTH_REACHED
Scanner stopped, because maximum depth was reached.
@ NOT_CROSSING_FS
A directory that represented a mounted filesystem was not followed due to field.
@ RESOLVED
Read symlink target strings.
@ NO_ACCESS_SL
Scanner failure due to limited access rights.
@ 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.
@ 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 SetPerms(Permissions v) noexcept
Sets the permissions of the entry.
void SetType(Types v) noexcept
Sets the type of the entry.
constexpr DateTime CDate() const noexcept
constexpr DateTime ADate() const noexcept
constexpr Qualities Quality() const noexcept
constexpr bool IsDirectory() const noexcept
constexpr bool TargetIsCrossingFS() const noexcept
void SetMDate(DateTime v) noexcept
Sets the last modification date of this file/folder.
void * custom
Pool-allocated custom data.
constexpr uint32_t Owner() const noexcept
void SetSize(uinteger v) noexcept
Sets the file size.
constexpr Types Type() const noexcept
@ MARKER_TYPES_END
A marker for the last countable type. The rest are unused/errors.
@ DIRECTORY
Directory/folder.
@ CHARACTER
A character special file.
@ BLOCK
A block special file.
@ FIFO
A FIFO (also known as pipe) file.
void SetGroup(uint32_t v) noexcept
Sets the ID of the group of the file/folder.
const std::type_info * dbgCustomType
The custom type attached. Used for asserting misuse in debug-compilations.
uinteger size
The file size. In case of a directory, this is 0.
lang::system::CPathString & GetRealLinkTarget() const noexcept
constexpr bool IsArtificialFS() const noexcept
void SetArtificialFS() noexcept
Mark the entry as residing on an artificial filesystem.
constexpr DateTime BDate() const noexcept
void SetCrossingFS() noexcept
Mark the entry as residing on a different filesystem than its parent.
OwnerAndGroupResolver(PoolAllocator &poolAllocator)
ALIB_API const NString & GetGroupName(const FInfo &fInfo)
ALIB_API const NString & GetOwnerName(const FInfo &fInfo)
void SetGroupCacheCapacity(integer numberOfLists, integer entriesPerList)
void SetOwnerCacheCapacity(integer numberOfLists, integer entriesPerList)
#define ALIB_ENUMS_MAKE_BITWISE(TEnum)
#define ALIB_WARNINGS_RESTORE
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
#define ALIB_ENUMS_MAKE_ITERABLE(TEnum, StopElement)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ALIB_RESOURCED_IN_MODULE(T, Camp, ResName)
files::File File
Type alias in namespace alib.
files::OwnerAndGroupResolver OwnerAndGroupResolver
Type alias in namespace alib.
lang::uinteger uinteger
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
files::FilesCamp FILES
The singleton instance of ALib Camp class FilesCamp.
files::FInfo FInfo
Type alias in namespace alib.
files::FTree FTree
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
A bitfield encoding various information.
bool TargetIsArtificialFS
Denotes whether a link points into an artificial filesystem.
Qualities Quality
The scan quality.
Permissions Permission
The unix file-permissions.
bool IsCrossingFS
Denotes whether the file is a mount point.
Bits()
Default constructor. Sets all members to NONE, false or Error.
bool TargetIsCrossingFS
Denotes whether a link points to a mount point.
bool IsArtificialFS
Denotes whether the file resides in an artificial filesystem.
Recursively accumulated values for directories.
uint32_t QtyErrsAccess
Number of access errors in the folder and subfolders.
uint32_t QtyStopsOnCircularLinks
Number of recursion aborts due to detected circular links reach of maximum recursion depth.
constexpr bool IsDirType(Types type) const noexcept
ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE uinteger Size
The cumulated sizes of all files and directories.
constexpr DirectorySums & Add(const FInfo &finfo) noexcept
uint32_t Count() const noexcept
constexpr DirectorySums() noexcept=default
Defaulted default constructor.
uint32_t Count(Types type) const noexcept
uint32_t CountNonDirectories() const noexcept
uint32_t TypeCounters[int(Types::MARKER_TYPES_END)]
Per-type counters.
DirectorySums & operator-=(const DirectorySums &rhs)
uint32_t QtyStopsOnMaxDepth
Number of recursion aborts due to reach of maximum recursion depth.
uint32_t QtyErrsBrokenLink
Number of broken symbolic links in the directory and its subfolders.
uint32_t CountDirectories() const noexcept
DirectorySums Sums
The recursive sums evaluated during scan.
DirectorySums Sums
The recursive sums evaluated during scan.
lang::system::CPathString RealTarget
The resolved real target path.
lang::system::CPathString Target
Base type to create pointers to different extended entry information structs.