This is the reference documentation of module ALib FileTree of the ALib C++ Framework.
Nested Namespaces: | |
| namespace | detail |
| This namespace implements internals of namespace alib::filetree. | |
| namespace | std |
Type Index: | |
| struct | CanonicalPathList |
| struct | CanonicalResult |
| Result information from MakeCanonical. More... | |
| struct | FFilter |
| class | FileExpressions |
| class | FilesCamp |
| class | FTFile |
| class | FTree |
| struct | FTreeListener |
| class | FTValue |
| class | OwnerAndGroupResolver |
| struct | ScanParameters |
| Input parameters to function ScanFiles. More... | |
| struct | TSharedFTree |
Type Definition Index: | |
| using | SPFileFilter = std::shared_ptr<FFilter> |
| A shared pointer to a filter. | |
Enumeration Index: | |
| enum class | PathRootKind { Errorneous , Relative , AbsoluteRoot , DriveLetter , UNC , URL , Device } |
| Classification of path root formats that cannot be directly scanned. More... | |
Function Index: | |
| AString & | DbgDump (AString &target, FTree &tree, EnumBitSet< FileStatus::Types > includedTypes=EnumBitSet< FileStatus::Types >(true), FTree::Cursor startNode=FTree::Cursor(), unsigned depth=(std::numeric_limits< unsigned int >::max)()) |
| void | FFormat_File (const Box &box, const String &formatSpec, NumberFormat &nf, AString &target) |
| CanonicalResult | MakeCanonical (Path &sourcePath, FTree::Cursor &node, Path &pathToNode, CanonicalPathList *resultPaths=nullptr) |
| FTValue::ScanStates | ScanFiles (FTree &tree, ScanParameters ¶meters, CanonicalPathList *resultPaths=nullptr, Path *remainingStart=nullptr) |
Variable Index: | |
| String | DBG_DUMP_FORMAT |
| String | DBG_FILETREE_SCAN_VERBOSE_LOG_FORMAT |
| using alib::filetree::SPFileFilter = std::shared_ptr<FFilter> |
A shared pointer to a filter.
Definition at line 43 of file ffilter.hpp.
|
strong |
Classification of path root formats that cannot be directly scanned.
Definition at line 241 of file fscanner.hpp.
| AString & alib::filetree::DbgDump | ( | AString & | target, |
| FTree & | tree, | ||
| EnumBitSet< FileStatus::Types > | includedTypes = EnumBitSet< FileStatus::Types >(true), | ||
| FTree::Cursor | startNode = FTree::Cursor(), | ||
| unsigned | depth = (std::numeric_limits< unsigned int >::max)() ) |
Dumps the given branch of this object's tree.
This function is only available with debug-compilations.
| target | The target string buffer. |
| tree | The tree to dump. |
| includedTypes | Optional filter for types. Defaults to 'all'. |
| startNode | The start node. If this is not valid, the root node is chosen. Defaults to an invalid cursor. |
| depth | The maximum depth of recursion. Defaults to unlimited depth. |
| void alib::filetree::FFormat_File | ( | const Box & | box, |
| const String & | formatSpec, | ||
| NumberFormat & | nf, | ||
| AString & | target ) |
This implementation of boxing function FFormat for objects of type FTFile, simply invokes the method AString & Format(Substring, AString&, lang::CurrentData, NumberFormat*) const and thus, using the format specification is given with that method.
Note that the NumberFormat instance used for formatting file sizes and similar, does not use the instance given with parameter nf. Instead, the instance retrieved with NumberFormat & GetNumberFormat() is used. This feature enables to determine the number format separately for file data output, independent of the settings the formater uses.
If the parameter formatSpec is empty, the string "ta h on gn s dm nal" is used, which is resourced in camp FILETREE under the key "FFMT".
| box | The box containing the file object. |
| formatSpec | The format string. |
| nf | The number format specification to use. |
| target | The target string to write to. |
Definition at line 417 of file ftfile.cpp.
| CanonicalResult alib::filetree::MakeCanonical | ( | Path & | sourcePath, |
| FTree::Cursor & | node, | ||
| Path & | pathToNode, | ||
| CanonicalPathList * | resultPaths = nullptr ) |
Analyses the given sourcePath and converts it to its canonical version. This is similar to what the POSIX function realpath() and C++ std::filesystem::canonical do.
This version, in addition, creates corresponding nodes in the FTree (passed indirectly with the parameter node). Besides removing "." and ".." entries, symbolic links are not only resolved, but the nodes they are targeting receive information about the link that targeted them. This information is set with the method SetSymbolicParent. With that, the path of directories or files that are children of such a targeted node, can re-establish the file-path as originally specified. This is done with the method AssembleSymbolicPath.
The method detects and handles various path root formats, creating appropriate tree nodes:
"foo/bar"'/'.'/'."/usr/local/bin" → root nodescheme:// where scheme is alphanumeric with +, -, or ..http, ftp).http://example.com → node http, file://path → node fileC:, C:\, or C:/.C:).C:\Windows → node "C:", "D:/data" → node "D:"\\ or //.//.\\server\share or //server/share → root node with //.\\.\... or //./....DEV.\\.\C: → node DEV:C:, \\.\UNC\server → treated as UNC after normalization.C: vs. a scheme c: from URL c://...).| [in,out] | sourcePath | The path to scan. This might contain "." and ".." directories, as well as symbolic links. When the method exits successfully, this path is empty. Otherwise, this path-string contains the remaining path, starting with the name of the file or directory that could not be found, accessed, or otherwise be resolved. |
| [in,out] | node | The starting node. In case the parameter sourcePath contains a root specification (absolute path, URL, etc.), this node is moved to the appropriate position in the tree (often the root). When the method exits successfully, this cursor targets the file that the source path resolved to. In case of failure, this cursor becomes invalid. |
| [in,out] | pathToNode | This path has to point to the given node when the method is called. When the method returns, it contains the canonical path to the then repositioned node. |
| [in,out] | resultPaths | Optional pointer to a CanonicalPathList that receives nodes for newly created paths during resolution. |
| FTValue::ScanStates alib::filetree::ScanFiles | ( | FTree & | tree, |
| ScanParameters & | parameters, | ||
| CanonicalPathList * | resultPaths = nullptr, | ||
| Path * | remainingStart = nullptr ) |
Scans the filesystem according to the given ScanParameters and adds FTValue entries to the given FTree.
This function has a contract with the class FTree that is used to store the scan results. This contract states that any file or directory found during a scan is always stored using the "Real Path" of the entry. This means that any symbolic link is resolved. The consequences are:
FTree.FTree, because also start paths are converted to a Real Path.The latter is reflected with (optional) parameter resultPaths of this function, which is of type CanonicalPathList.
Existing entries in the given tree are not overwritten. They might be scanned with "higher" ScanStates values, depending on given parameters and how they had been scanned before. If the same "level" of scanning is provided, existing entries will not be scanned again. If a rescan of a certain path is wanted, then the target entry of that path has to be deleted before invoking this function. Due to the implementation of class FTree, repeated delete and scan operations will not cause any heap-memory allocations or deallocations.
File scanning is a platform-dependent task and hence ALib uses one of two different implementations:
C++ std::filesystem.The fallback version using std::filesystem has the following restrictions:
0.| tree | The tree to fill. | |
| parameters | The input parameters to determine the scan process. | |
| [out] | resultPaths | An optional container to store the result paths of a scan. If nullptr is given, the result paths are not collected. See the types documentation for further information. |
| [out] | remainingStart | An optional path string. If given, on failure, it will receive the remainder of the path given with ScanParameters::StartPath starting with the first directory or file that could not be resolved or accessed. |
|
extern |
The format string used with namespace function DbgDump.
Defaults to "{:ta h{2,r} on{10,r} gn{10,r} s(IEC){10,r} dm qqq FxFa (rd{3r}' D' rf{3r}' F' re{2r}' EA' rb{2r}'BL) 'nf l}\n"
This global variable is only available with debug-compilations.