8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
17#if !defined ( _WIN32 )
27 import ALib.Characters.Functions;
31 import ALib.ALox.Impl;
34 import ALib.Expressions;
69 "FILES",
"Given node is not a directory or symbolic link." )
73 "FILES",
"Error in symbolic link parameter" )
79 auto pool= node.Tree<
FTree>().Pool();
91 v.SetLinkTarget( node.Tree<
FTree>(), symLinkDest, symLinkRealPath);
98 v.SetLinkTarget( node.Tree<
FTree>(), symLinkDest, symLinkRealPath);
134 if( node.data.custom ) {
138 "CustomData not deleted before destruction of class FTree.\n"
139 " First node found: {}.\n"
140 " Attached data type: {}" , path, node.data.dbgCustomType )
165 ALIB_ASSERT_ERROR( file ==
nullptr || &file->AsCursor().Tree() ==
this,
"FILES",
"Given file does not belong to this FTree." )
166 ALIB_ASSERT_ERROR( subTree ==
nullptr || subTree->IsValid() ,
"FILES",
"Invalid cursor given." )
167 ALIB_ASSERT_ERROR( subTree ==
nullptr || &subTree ->Tree() ==
this,
"FILES",
"Given cursor does not belong to this FTree." )
173 (file ? file->AsCursor().Export() : ConstCursorHandle()),
174 (subTree ? subTree-> Export() : ConstCursorHandle()),
179 listeners.back().pathPrefix << pathPrefix;
180 listeners.back().pathSubstring<< pathSubstring;
187 if( it->listener == listener
188 && it->event == event
189 && it->file == ( file ? file->AsCursor().Export() : ConstCursorHandle() )
190 && it->subTree == ( subTree ? subTree ->Export() : ConstCursorHandle() )
191 && it->fileName .Equals( fileName )
192 && it->pathPrefix .Equals( pathPrefix )
193 && it->pathSubstring.Equals( pathSubstring ) )
199 ALIB_WARNING(
"FILES",
"Listener with matching set of parameters not found with deregistration.")
211 if( it->listener == listener ) {
219 Log_If(cnt==0, Verbosity::Warning,
"No listener found to be removed." )
231 if( event == it->event ) {
234 && ( it->fileName .IsNotEmpty()
235 || it->pathPrefix .IsNotEmpty()
236 || it->pathSubstring.IsNotEmpty() ) )
239 (file.AsCursor().IsRoot() ? file.AsCursor()
240 : file.AsCursor().Parent() )
241 .AssemblePath(filePathBuffer);
243 filePath= &filePathBuffer;
246 if( ( it->file .IsValid() && ( it->file == file.AsCursor().Export() ) )
247 || ( it->subTree .IsValid() && ( file.AsCursor().Distance(
ImportCursor(it->subTree) ) >= 0 ) )
248 || ( it->fileName .IsNotEmpty() && it->fileName.Equals(file.AsCursor().Name()) )
249 || ( it->pathPrefix .IsNotEmpty() && filePath->
StartsWith(it->pathPrefix) )
250 || ( it->pathSubstring.IsNotEmpty() && filePath->
IndexOf(it->pathSubstring) >= 0 )
254 ?
"CreateNode" :
"DeleteNode" )
255 it->listener->Notify( file, event );
263 "FILES",
"Given node is not a directory." )
267 directory.GoToFirstChild();
268 while( directory.IsValid()) {
269 FInfo& v= *directory;
274 directory.GoToNextSibling();
281#if ALIB_DEBUG && !DOXYGEN
284 A_CHAR(
"{: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");
291 if( startNode.IsInvalid() )
306 if( includedTypes.
Test(stit.
Node()->Type()))
void SetMaxDepth(unsigned int newMaxDepth=(std::numeric_limits< unsigned >::max)())
void Initialize(CursorType startNode, lang::Inclusion includeStartNode)
void SetPathGeneration(lang::Switch pathGeneration)
Cursor ImportCursor(CursorHandle handle)
Cursor createCursor(baseNode &node)
void DbgSetDCSName(const char *name) const
StringTree(AllocatorType &allocator, CharacterType pathSeparator)
void ConstructRootValue(TArgs &&... args)
The entry type which is embedded in each tree node.
constexpr Types Type() const noexcept
constexpr ExtendedEntryInfo * GetExtendedInfo() const
constexpr bool IsDirectory() const noexcept
@ DIRECTORY
Directory/folder.
constexpr DirectorySums & Sums() const
ALIB_DLL FTree(MonoAllocator &allocator)
ALIB_DLL void notifyListeners(FTreeListener::Event event, File &file, SharedLock *lock, const system::PathString &filePath)
NumberFormat numberFormat
OwnerAndGroupResolver ogResolver
ALIB_DLL int MonitorStop(FTreeListener *listener)
friend class files::File
Friendship declaration.
ALIB_DLL void registerListener(FTreeListener *listener, lang::ContainerOp insertOrRemove, FTreeListener::Event event, const File *file, const StringTree::Cursor *subTree, const system::PathString &fileName, const system::PathString &pathPrefix, const system::PathString &pathSubstring)
ListMA< ListenerRecord > listeners
The list of registered listeners.
ALIB_DLL ~FTree()
Destructor.
static ALIB_DLL void FixSums(Cursor directory)
constexpr bool Test(TInterface bit) noexcept
constexpr bool IsEmpty() const
integer IndexOf(TChar needle, integer startIdx=0) const
bool StartsWith(const TString &needle) const
ALIB_DLL void ReleaseShared(ALIB_DBG_TAKE_CI)
ALIB_DLL void AcquireShared(ALIB_DBG_TAKE_CI)
#define IF_ALIB_THREADS(...)
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNING(domain,...)
#define ALIB_ERROR(domain,...)
#define ALIB_WARNINGS_ALLOW_SPARSE_ENUM_SWITCH
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define Log_SetDomain(...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_CALLER_PRUNED
This namespace implements internals of namespace alib::files.
ALIB_DLL AString & DbgDump(AString &target, FTree &tree, EnumBitSet< FInfo::Types > includedTypes=EnumBitSet< FInfo::Types >(true), FTree::Cursor startNode=FTree::Cursor(), unsigned depth=(std::numeric_limits< unsigned int >::max)())
ContainerOp
Denotes standard container operations.
@ Insert
Denotes insertions.
@ Off
Switch it off, switched off, etc.
@ Exclude
Chooses exclusion.
strings::TString< PathCharType > PathString
The string-type used with this ALib Module.
strings::TAString< PathCharType, PoolAllocator > PathStringPA
A pool-allocated string representing a path.
constexpr PathCharType DIRECTORY_SEPARATOR
The standard path separator character. Defaults to '\' on Windows OS, '/' else.
threads::SharedLock SharedLock
Type alias in namespace alib.
files::File File
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
lang::TBitSet< TEnum, enumops::IterableTraits< TEnum >::End, enumops::IterableTraits< TEnum >::Begin > EnumBitSet
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
system::Path Path
Type alias in namespace alib.
format::Formatter Formatter
Type alias in namespace alib.
files::FilesCamp FILES
The singleton instance of ALib Camp class FilesCamp.
strings::TString< character > String
Type alias in namespace alib.
containers::StringTreeIterator< TTree > StringTreeIterator
Type alias in namespace alib.
HashTable< TAllocator, typename NodeKey::ValueDescriptor, typename NodeKey::Hash, typename NodeKey::EqualTo, lang::Caching::Enabled, TRecycling > nodeTable
Recursively accumulated values for directories.
std::array< uint32_t, size_t(Types::MARKER_TYPES_END)> TypeCounters
Per-type counters.
Event
The type of change that imposes the notification of a listener.
@ CreateNode
A file or directory entry was created.
Record used to manage registered listeners.
static ALIB_DLL void AllocateExtendedInfo(StringTree< MonoAllocator, FInfo, detail::FTreeNodeHandler >::Cursor &node, const system::PathString &symLinkDest, const system::PathString &symLinkRealPath)