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 )
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();
92 v.SetLinkTarget( node.Tree<
FTree>(), symLinkDest, symLinkRealPath);
99 v.SetLinkTarget( node.Tree<
FTree>(), symLinkDest, symLinkRealPath);
137 if( node.data.custom )
142 "CustomData not deleted before destruction of class FTree.\n"
143 " First node found: {}.\n"
144 " Attached data type: {}" , path, node.data.dbgCustomType )
170 ALIB_ASSERT_ERROR( file ==
nullptr || &file->AsCursor().Tree() ==
this,
"FILES",
"Given file does not belong to this FTree." )
171 ALIB_ASSERT_ERROR( subTree ==
nullptr || subTree->IsValid() ,
"FILES",
"Invalid cursor given." )
172 ALIB_ASSERT_ERROR( subTree ==
nullptr || &subTree ->Tree() ==
this,
"FILES",
"Given cursor does not belong to this FTree." )
179 (file ? file->AsCursor().Export() : ConstCursorHandle()),
180 (subTree ? subTree-> Export() : ConstCursorHandle()),
185 listeners.back().pathPrefix << pathPrefix;
186 listeners.back().pathSubstring<< pathSubstring;
193 if( it->listener == listener
194 && it->event == event
195 && it->file == ( file ? file->AsCursor().Export() : ConstCursorHandle() )
196 && it->subTree == ( subTree ? subTree ->Export() : ConstCursorHandle() )
197 && it->fileName .Equals( fileName )
198 && it->pathPrefix .Equals( pathPrefix )
199 && it->pathSubstring.Equals( pathSubstring ) )
205 ALIB_WARNING(
"FILES",
"Listener with matching set of parameters not found with deregistration.")
218 if( it->listener == listener )
227 Log_If(cnt==0, Verbosity::Warning,
"No listener found to be removed." )
240 if( event == it->event )
244 && ( it->fileName .IsNotEmpty()
245 || it->pathPrefix .IsNotEmpty()
246 || it->pathSubstring.IsNotEmpty() ) )
249 (file.AsCursor().IsRoot() ? file.AsCursor()
250 : file.AsCursor().Parent() )
251 .AssemblePath(filePathBuffer);
253 filePath= &filePathBuffer;
256 if( ( it->file .IsValid() && ( it->file == file.AsCursor().Export() ) )
257 || ( it->subTree .IsValid() && ( file.AsCursor().Distance(
ImportCursor(it->subTree) ) >= 0 ) )
258 || ( it->fileName .IsNotEmpty() && it->fileName.Equals(file.AsCursor().Name()) )
259 || ( it->pathPrefix .IsNotEmpty() && filePath->
StartsWith(it->pathPrefix) )
260 || ( it->pathSubstring.IsNotEmpty() && filePath->
IndexOf(it->pathSubstring) >= 0 )
264 ?
"CreateNode" :
"DeleteNode" )
265 it->listener->Notify( file, event );
275 "FILES",
"Given node is not a directory." )
279 directory.GoToFirstChild();
280 while( directory.IsValid())
282 FInfo& v= *directory;
287 directory.GoToNextSibling();
295#if ALIB_DEBUG && !DOXYGEN
298 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");
307 if( startNode.IsInvalid() )
319 rit.Initialize( startNode, depth );
320 while( rit.IsValid())
322 if( includedTypes.
Test(rit.Node()->Type()))
Cursor ImportCursor(CursorHandle handle)
Cursor createCursor(baseNode &node)
void DbgSetDCSName(const char *name) const
TRecursiveIterator< false > RecursiveIterator
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)
ALIB_DLL ~FTree()
Destructor.
static ALIB_DLL void FixSums(Cursor directory)
List< MonoAllocator, ListenerRecord > listeners
The list of registered listeners.
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 int depth=(std::numeric_limits< unsigned int >::max)())
ContainerOp
Denotes standard container operations.
@ Insert
Denotes insertions.
@ Off
Switch it off, switched off, etc.
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.
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)