ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
FInfo Class Reference

Description:

The entry type which is embedded in each tree node.

Definition at line 41 of file finfo.hpp.

#include <finfo.hpp>

Collaboration diagram for FInfo:
[legend]

Inner Type Index:

struct  DirectorySums
 
struct  EIDirectory
 
struct  EISymLinkDir
 
struct  EISymLinkFile
 
struct  ExtendedEntryInfo
 
struct  InfoBox
 

Public Type Index:

enum class  Permissions : int32_t {
  NONE = 0 , UNKNOWN = 0xFFFF , 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
}
 
enum class  Qualities {
  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
 
enum class  Types : int8_t {
  DIRECTORY = 0 , SYMBOLIC_LINK_DIR = 1 , REGULAR = 2 , SYMBOLIC_LINK = 3 ,
  BLOCK = 4 , CHARACTER = 5 , FIFO = 6 , SOCKET = 7 ,
  MARKER_TYPES_END = 8 , UNKNOWN_OR_ERROR = 8
}
 

Public Static Field Index:

static constexpr TOwnerAndGroupID UnknownID = (std::numeric_limits<uint32_t>::max)()
 

Public Method Index:

 FInfo ()
 
void AddCustomData (MonoAllocator *monoAllocator, Box data)
 
constexpr DateTime ATime () const noexcept
 
constexpr DateTime CTime () const noexcept
 
template<typename T >
Box GetCustomData ()
 
Box GetCustomData (int idx)
 
constexpr ExtendedEntryInfoGetExtendedInfo () const
 
CStringGetLinkTarget () const noexcept
 
CStringGetRealLinkTarget () const noexcept
 
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 MTime () const noexcept
 
constexpr uint32_t Owner () const noexcept
 
constexpr Permissions Perms () const noexcept
 
constexpr Qualities Quality () const noexcept
 
void SetArtificialFS () noexcept
 
void SetATime (DateTime v) noexcept
 
void SetCrossingFS () noexcept
 
void SetCTime (DateTime v) noexcept
 
constexpr void SetExtendedInfo (ExtendedEntryInfo *extInfo)
 
void SetGroup (uint32_t v) noexcept
 
void SetLinkTarget (const String &target, const String &realTarget)
 
void SetMTime (DateTime v) noexcept
 
void SetOwner (uint32_t v) noexcept
 
void SetPerms (Permissions v) noexcept
 
void SetQuality (Qualities v) noexcept
 
void SetSize (uinteger v) noexcept
 
constexpr void SetSums (const DirectorySums &sums) const
 
void SetTargetArtificialFS () noexcept
 
void SetTargetCrossingFS () noexcept
 
void SetType (Types v) noexcept
 
constexpr uinteger Size () const noexcept
 
constexpr DirectorySumsSums () const
 
constexpr bool TargetIsArtificialFS () const noexcept
 
constexpr bool TargetIsCrossingFS () const noexcept
 
constexpr Types Type () const noexcept
 
AStringWriteTypeAndAccess (AString &target) const
 

Type Definition Details:

◆ TOwnerAndGroupID

using TOwnerAndGroupID = uint32_t

Type definition for owner and group ids

Definition at line 95 of file finfo.hpp.

Enumeration Details:

◆ Permissions

enum class Permissions : int32_t
strong

Permission flags. Compatible with posix* definition.

Enumerator
NONE 

no permission bits are set

UNKNOWN 

Unknown permissions (e.g. when not read or filesystem does not support permissions)

MASK 

All valid permission bits. Equivalent to all | set_uid | set_gid | sticky_bit.

ALL 

All users have read, write, and execute/search permissions Equivalent to owner_all | group_all | others_all.

OWNER_WRITE 

< S_IRUSR File owner has read permission

OWNER_EXEC 

< S_IWUSR File owner has write permission

OWNER_ALL 

< S_IXUSR File owner has execute/search permission

GROUP_READ 

< S_IRWXU File owner has read, write, and execute/search permissions Equivalent to owner_read | owner_write | owner_exec

GROUP_WRITE 

< S_IRGRP The file's user group has read permission

GROUP_EXEC 

< S_IWGRP The file's user group has write permission

GROUP_ALL 

< S_IXGRP The file's user group has execute/search permission

OTHERS_READ 

< S_IRWXG The file's user group has read, write, and execute/search permissions Equivalent to group_read | group_write | group_exec

S_IROTH Other users have read permission

OTHERS_WRITE 

S_IWOTH Other users have write permission.

OTHERS_EXEC 

S_IXOTH Other users have execute/search permission.

OTHERS_ALL 

S_IRWXO Other users have read, write, and execute/search permissions Equivalent to others_read | others_write | others_exec.

SET_UID 

S_ISUID Set user ID to file owner user ID on execution.

SET_GID 

S_ISGID Set group ID to file's user group ID on execution.

STICKY_BIT 

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)

Definition at line 67 of file finfo.hpp.

◆ Qualities

enum class Qualities
strong

Per-entry information about how a node was scanned.

Enumerator
NONE 

Node created only from given (real) start path.

STATS 

Only stats (size, time, owner, etc.) read.

RESOLVED 

Read symlink target strings.

MAX_DEPTH_REACHED 

Scanner 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 field.

NO_AFS 

A directory that represented a mounted filesystem was not followed due to field ScanParameters::CrossFileSystems being set to false.

RECURSIVE 

Follow symlink target strings.

NO_ACCESS 

Scanner failure due to limited access rights.

NO_ACCESS_SL 

Scanner failure due to limited access rights.

NO_ACCESS_SL_TARGET 

Scanner failure due to limited access rights.

NO_ACCESS_DIR 

Scanner failure due to limited access rights.

BROKEN_LINK 

A symbolic link targets a non-existent file or directory.

CIRCULAR_LINK 

Set if recursion stopped on 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 101 of file finfo.hpp.

◆ Types

enum class Types : int8_t
strong

Enumeration of the possible file types. This is compatible with the posix list of types, with the exclamation that symbolic links are differentiated between those linking to a directory and those linking to any other file type.

Enumerator
DIRECTORY 

Directory/folder.

SYMBOLIC_LINK_DIR 

Symbolic link targeting a directory. In case scanning does not resolve links, this is never set.

REGULAR 

Regular file.

SYMBOLIC_LINK 

Symbolic link targeting a non-directory file. In case scanning does not resolve links, possibly to a directory.

BLOCK 

A block special file.

CHARACTER 

A character special file.

FIFO 

A FIFO (also known as pipe) file.

SOCKET 

A socket file.

MARKER_TYPES_END 

A marker for the last countable type. The rest are unused/errors.

UNKNOWN_OR_ERROR 

Filetype (should never or seldom happen). Maybe filesystem changed during scan or similar strange thing.

Definition at line 47 of file finfo.hpp.

Field Details:

◆ aTime

DateTime aTime
protected

The time of last access. This is not always available, depends on operating- and filesystem.

Definition at line 299 of file finfo.hpp.

◆ bits

uint32_t bits
protected

Bits encoding the following information: 0 - 3: Type 4: IsArtificialFS 5: TargetIsArtificialFS 6: IsCrossingFS 7: TargetIsCrossingFS 8 - 23: Perms 24 - 31: Quality

Definition at line 313 of file finfo.hpp.

◆ cTime

DateTime cTime
protected

The time of creation. This is not always available, depends on operating- and filesystem.

Definition at line 297 of file finfo.hpp.

◆ custom

lang::SidiListHelper<InfoBox> custom
protected

A list of boxed custom data objects.

Definition at line 316 of file finfo.hpp.

◆ extendedInfo

ExtendedEntryInfo* extendedInfo
protected

Extended information, depending on the entry type.

Definition at line 315 of file finfo.hpp.

◆ group

uint32_t group
protected

The group id that owns the file.

Definition at line 303 of file finfo.hpp.

◆ mTime

DateTime mTime
protected

The last write time. (Always available.)

Definition at line 296 of file finfo.hpp.

◆ owner

uint32_t owner
protected

The user id that owns the file.

Definition at line 302 of file finfo.hpp.

◆ size

uinteger size
protected

The file size. In case of a directory, this is 0.

Definition at line 301 of file finfo.hpp.

◆ UnknownID

constexpr TOwnerAndGroupID UnknownID = (std::numeric_limits<uint32_t>::max)()
staticconstexpr

Constant value for owner and group IDs to denote that the field was not determined.

Definition at line 98 of file finfo.hpp.

Constructor(s) / Destructor Details::

◆ FInfo()

FInfo ( )
inline

Constructor providing no values. Only sets ScanQuality::NONE

Definition at line 321 of file finfo.hpp.

Method Details:

◆ AddCustomData()

void AddCustomData ( MonoAllocator * monoAllocator,
Box data )
inline

This method, together with GetCustomData, provides a simple mechanism to attach some custom information to an entry in FTree.

The allocator of the FTree object has to be provided as a parameter, as it is otherwise not reachable from within this entry object. While this might also be some other, external allocator, it is not easily thinkable of a use case for this.

Note that any object that does not fit as a value into the Box is simply stored as a pointer. No copy is created! Therefore such object has to be allocated persistent. Usually, such objects are created in the same monoAllocator as given, right before the invocation of this method.

See also
Method GetCustomData.
For more information on class box, see Programmer's Manual of module ALib Boxing .
Parameters
monoAllocatorUsually, the allocator of the FTree object that this entry belongs to and as such received with FTree::GetAllocator().
dataThe data to attach.

Definition at line 348 of file finfo.hpp.

Here is the call graph for this function:

◆ ATime()

constexpr DateTime ATime ( ) const
inlineconstexprnoexcept
Returns
Retrieves the time of last access to the file/folder. If unavailable, same as MTime.

Definition at line 430 of file finfo.hpp.

◆ CTime()

constexpr DateTime CTime ( ) const
inlineconstexprnoexcept
Returns
Retrieves the creation time of the file/folder. If unavailable, same as MTime.

Definition at line 428 of file finfo.hpp.

◆ GetCustomData() [1/2]

template<typename T >
Box GetCustomData ( )
inline

Alternative version of method GetCustomData(int idx), which searches the attached list of boxes for a first one that contains custom data of type T .

See also
Method AddCustomData.
Template Parameters
TThe custom type to search for in the attached list of data.
Returns
The (still) boxed value. In case no box with an object of type T is found, a nulled box is returned.

Definition at line 391 of file finfo.hpp.

◆ GetCustomData() [2/2]

Box GetCustomData ( int idx)
inline

This method, together with AddCustomData, provides a simple mechanism to attach and retrieve some custom information to an entry in FTree

Custom data is stored in a single-linked list. This class does not provide an iterator for the data, because the application has to assure for itself how many custom data objects are placed in which order! Usually, only one custom object should be stored.

See also
Method AddCustomData.
Parameters
idxThe sequence number of the stored custom boxed element.
Returns
The boxed value. In case given idx is greater (or equal) to the number of stored custom elements, a nulled box is returned.

Definition at line 368 of file finfo.hpp.

◆ GetExtendedInfo()

constexpr ExtendedEntryInfo * GetExtendedInfo ( ) const
inlineconstexpr

Retrieves the extended info object of this entry.

Returns
The extended info object of this entry. If not available nullptr is returned.

Definition at line 438 of file finfo.hpp.

◆ GetLinkTarget()

CString & GetLinkTarget ( ) const
inlinenoexcept

Retrieves the non-translated target of a symbolic link. In debug compilations, the method asserts that Type returns either Types::SYMBOLIC_LINK or Types::SYMBOLIC_LINK_DIR .

Returns
A reference to a copy of the zero-terminated string stored in the symbolic link file.

Definition at line 486 of file finfo.hpp.

Here is the call graph for this function:

◆ GetRealLinkTarget()

CString & GetRealLinkTarget ( ) const
inlinenoexcept

Retrieves the resolved target of a symbolic link. In debug compilations, the method asserts that Type returns either Types::SYMBOLIC_LINK or Types::SYMBOLIC_LINK_DIR .

Returns
A reference to a zero-terminated string giving the translated real path that a symbolic link points to.

Definition at line 500 of file finfo.hpp.

Here is the call graph for this function:

◆ Group()

constexpr uint32_t Group ( ) const
inlineconstexprnoexcept
Returns
Retrieves the ID of the group of the file/folder if available. Otherwise set to UnknownID.

Definition at line 434 of file finfo.hpp.

◆ IsArtificialFS()

constexpr bool IsArtificialFS ( ) const
inlineconstexprnoexcept
Returns
Returns true if the entry resides on an artificial filesystem.

Definition at line 416 of file finfo.hpp.

◆ IsCrossingFS()

constexpr bool IsCrossingFS ( ) const
inlineconstexprnoexcept
Returns
Returns true if the entry resides on a different filesystem than it's parent.

Definition at line 420 of file finfo.hpp.

◆ IsDirectory()

constexpr bool IsDirectory ( ) const
inlineconstexprnoexcept
Returns
Checks type for being either directory or symbolic link pointing to one.

Definition at line 409 of file finfo.hpp.

◆ IsSymbolicLink()

constexpr bool IsSymbolicLink ( ) const
inlineconstexprnoexcept
Returns
Checks type for being a symbolic link (to normal file or to a directory).

Definition at line 411 of file finfo.hpp.

Here is the call graph for this function:

◆ MTime()

constexpr DateTime MTime ( ) const
inlineconstexprnoexcept
Returns
Retrieves the last modification time of the file/folder.

Definition at line 426 of file finfo.hpp.

◆ Owner()

constexpr uint32_t Owner ( ) const
inlineconstexprnoexcept
Returns
Retrieves the ID of the owner of the file/folder if available. Otherwise set to UnknownID.

Definition at line 432 of file finfo.hpp.

◆ Perms()

constexpr Permissions Perms ( ) const
inlineconstexprnoexcept
Returns
Retrieves the permissions of the entry.

Definition at line 405 of file finfo.hpp.

◆ Quality()

constexpr Qualities Quality ( ) const
inlineconstexprnoexcept
Returns
Retrieves the scan quality of the entry.

Definition at line 414 of file finfo.hpp.

◆ SetArtificialFS()

void SetArtificialFS ( )
inlinenoexcept

Mark the entry as residing on an artificial filesystem.

Definition at line 516 of file finfo.hpp.

◆ SetATime()

void SetATime ( DateTime v)
inlinenoexcept

Sets the time of last access to the file/folder. If unavailable, same as MTime.

Parameters
vThe value to set.

Definition at line 530 of file finfo.hpp.

◆ SetCrossingFS()

void SetCrossingFS ( )
inlinenoexcept

Mark the entry as residing on a different filesystem than its parent.

Definition at line 520 of file finfo.hpp.

◆ SetCTime()

void SetCTime ( DateTime v)
inlinenoexcept

Sets the creation time of the file/folder. If unavailable, same as MTime.

Parameters
vThe value to set.

Definition at line 528 of file finfo.hpp.

◆ SetExtendedInfo()

constexpr void SetExtendedInfo ( ExtendedEntryInfo * extInfo)
inlineconstexpr

Sets the externally allocated extended information object.

Parameters
extInfoA pointer to the information object to use.

Definition at line 443 of file finfo.hpp.

◆ SetGroup()

void SetGroup ( uint32_t v)
inlinenoexcept

Sets the ID of the group of the file/folder if available. Otherwise set to UnknownID.

Parameters
vThe value to set.

Definition at line 534 of file finfo.hpp.

◆ SetLinkTarget()

void SetLinkTarget ( const String & target,
const String & realTarget )

Stores the link targets in the extended information object created for symbolic links.

Parameters
targetThe target as stored in the symlink
realTargetThe translated, 'real' target path (if not broken).

Definition at line 55 of file finfo.cpp.

Here is the call graph for this function:

◆ SetMTime()

void SetMTime ( DateTime v)
inlinenoexcept

Sets the last modification time of the file/folder.

Parameters
vThe value to set.

Definition at line 526 of file finfo.hpp.

◆ SetOwner()

void SetOwner ( uint32_t v)
inlinenoexcept

Sets the ID of the owner of the file/folder if available. Otherwise set to UnknownID.

Parameters
vThe value to set.

Definition at line 532 of file finfo.hpp.

◆ SetPerms()

void SetPerms ( Permissions v)
inlinenoexcept

Sets the permissions of the entry.

Parameters
vThe value to set.

Definition at line 510 of file finfo.hpp.

◆ SetQuality()

void SetQuality ( Qualities v)
inlinenoexcept

Sets the quality of scan of the entry.

Parameters
vThe value to set.

Definition at line 514 of file finfo.hpp.

◆ SetSize()

void SetSize ( uinteger v)
inlinenoexcept

Sets the file size.

Parameters
vThe value to set.

Definition at line 524 of file finfo.hpp.

◆ SetSums()

constexpr void SetSums ( const DirectorySums & sums) const
inlineconstexpr

Sets the sums of the extended info object of this entry.

Parameters
sumsThe sums to set.

Definition at line 461 of file finfo.hpp.

Here is the call graph for this function:

◆ SetTargetArtificialFS()

void SetTargetArtificialFS ( )
inlinenoexcept

Mark the entry as a symlink who's target is residing on an artificial filesystem.

Definition at line 518 of file finfo.hpp.

◆ SetTargetCrossingFS()

void SetTargetCrossingFS ( )
inlinenoexcept

Mark the entry as a symlink who's target is residing on a different filesystem than the symlink.

Definition at line 522 of file finfo.hpp.

◆ SetType()

void SetType ( Types v)
inlinenoexcept

Sets the type of the entry.

Parameters
vThe value to set.

Definition at line 512 of file finfo.hpp.

◆ Size()

constexpr uinteger Size ( ) const
inlineconstexprnoexcept
Returns
Retrieves the file size.

Definition at line 424 of file finfo.hpp.

◆ Sums()

constexpr DirectorySums & Sums ( ) const
inlineconstexpr

Retrieves the directory sums of this directory or symbolic link to directory.

Returns
A reference to the sums.

Definition at line 448 of file finfo.hpp.

Here is the call graph for this function:

◆ TargetIsArtificialFS()

constexpr bool TargetIsArtificialFS ( ) const
inlineconstexprnoexcept
Returns
Returns true if the entry is a symlink and its target resides on an artificial filesystem.

Definition at line 418 of file finfo.hpp.

◆ TargetIsCrossingFS()

constexpr bool TargetIsCrossingFS ( ) const
inlineconstexprnoexcept
Returns
Returns true if the entry is a symlink and resides on a different filesystem than the link.

Definition at line 422 of file finfo.hpp.

◆ Type()

constexpr Types Type ( ) const
inlineconstexprnoexcept
Returns
Retrieves the type of the entry

Definition at line 407 of file finfo.hpp.

◆ WriteTypeAndAccess()

AString & WriteTypeAndAccess ( AString & target) const

Writes the file type and the permission flags to the given target string in the same format as GNU/Linux command 'ls -l' does.

Parameters
targetThe target string to write into.
Returns
The given target to allow concatenated calls.

Definition at line 22 of file finfo.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: