152 friend struct FTreeNodeHandler;
277 template<
typename TCustom>
282 if( node.data.custom )
285 "CustomData to delete does not match attached type.\n"
286 "Deletion has to be performed individually by this software.\n"
287 "This method must only be used if all tree nodes have the same custom data "
289 " Attached type: <{}>\n"
290 " Given type: <{}>" , &
typeid(TCustom), node.data.dbgCustomType )
292 reinterpret_cast<TCustom*
>( node.data.custom ) -> ~TCustom();
293 Pool.free( node.data.custom,
sizeof(TCustom) );
294 node.data.custom=
nullptr;
295 ALIB_DBG( node.data.dbgCustomType=
nullptr; )
360 "Event::Creation will never be invoked with this listener-registration-type." )
385 nullptr,
nullptr, fileName,
494template<
typename TLock>
524 unsigned int bufferGrowthInPercent = 200 )
525 :
Base(initialBufferSizeInKB, bufferGrowthInPercent)
548 template<
typename TRequires=
typename Base::LockType>
549 requires( !std::same_as<TRequires, void> )
552 #if ALIB_DEBUG_CRITICAL_SECTIONS
571 template<
typename TRequires=
typename Base::LockType>
572 requires std::same_as<TRequires, void>
598 node.name.storage.Allocate(
static_cast<FTree&
>(tree).Pool, node.name.key );
604 auto& pool=
static_cast<FTree&
>(tree).Pool;
606 if ( node.name.storage.Length() )
611 FInfo& value= node.data;
613 if( extendedInfo ==
nullptr )
616 if( value.IsSymbolicLink() )
619 FInfo::EISymLinkFile& ei= *
static_cast<FInfo::EISymLinkFile*
>(extendedInfo);
621 if( ei.RealTarget.Buffer() != ei.Target.Buffer()
622 && ei.RealTarget.Buffer() !=
nullptr )
623 pool().Free( ei.RealTarget.Buffer(), ei.RealTarget.Length() + 1 );
625 if( ei.Target.Buffer() !=
nullptr )
626 pool().Free( ei.Target.Buffer(), ei.Target.Length() + 1 );
629 pool().Delete(
static_cast<FInfo::EISymLinkFile*
>(extendedInfo) );
631 pool().Delete(
static_cast<FInfo::EISymLinkDir*
>(extendedInfo) );
634 ALIB_DBG( value.SetExtendedInfo(
nullptr) );
639 "FILES",
"Given node is not a directory or symbolic link but still has extendedInfo set." )
641 pool().Delete( reinterpret_cast<
FInfo::EIDirectory*>(extendedInfo) );
644 ALIB_DBG( value.SetExtendedInfo(
nullptr) );
646#include "ALib.Lang.CIMethods.H"
694 {
return static_cast<FTree&
>(Tree()); }
702 :
Cursor( pTree.Root() ) {}
761 return dotPos < 2 ? result
773 : Name().Substring( dotPos + 1 );
812 return Value().custom !=
nullptr;
823 template<
typename TCustom>
828 "Requested custom object type mismatch.\n"
829 " Attached type: <{}>\n"
830 " Given type: <{}>" , &
typeid(TCustom), Value().dbgCustomType )
832 return *
reinterpret_cast<TCustom*
>( Value().custom );
845 template<
typename TCustom,
typename... TArgs>
848 ALIB_ASSERT_ERROR( Value().custom ==
nullptr,
"FILES",
"Custom data already set." )
850 auto* custom=
GetFTree().Pool().template New<TCustom>( std::forward<TArgs>(args)... );
851 Value().custom= custom;
852ALIB_DBG(Value().dbgCustomType= &
typeid(TCustom); )
862 template<
typename TCustom>
866 GetFTree().Pool.free( Value().custom,
sizeof(TCustom) );
867 Value().custom=
nullptr;
1026#if !ALIB_SINGLE_THREADED || DOXYGEN
1027DOX_MARKER([DOX_MANUAL_ALIASES_FTREE])
1030DOX_MARKER([DOX_MANUAL_ALIASES_FTREE])
1049namespace APPENDABLES {
1106 unsigned int depth = (std::numeric_limits<unsigned int>::max)() );
TCursor & operator=(const TCursor &) noexcept=default
TCursor< true > ConstCursor
StringTree(AllocatorType &allocator, CharacterType pathSeparator)
The entry type which is embedded in each tree node.
constexpr ExtendedEntryInfo * GetExtendedInfo() const
@ DIRECTORY
Directory/folder.
ALIB_DLL FTree(MonoAllocator &allocator)
ALIB_DLL void notifyListeners(FTreeListener::Event event, File &file, SharedLock *lock, const system::PathString &filePath)
NumberFormat numberFormat
void AllocateExtendedInfo(Cursor &node, const system::PathString &symLinkDest, const system::PathString &symLinkRealPath)
OwnerAndGroupResolver ogResolver
void MonitorFilesByName(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const system::PathString &fileName)
void DeleteAllCustomData()
ALIB_DLL int MonitorStop(FTreeListener *listener)
friend class files::File
Friendship declaration.
void MonitorPath(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const FTree::Cursor &cursor)
OwnerAndGroupResolver & GetOGResolver()
NumberFormat & GetNumberFormat()
void MonitorPathSubstring(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const system::PathString &pathSubstring)
void MonitorPathPrefix(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const system::PathString &pathPrefix)
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)
StringTree< MonoAllocator, FInfo, detail::FTreeNodeHandler > base
Type alias of this classes' base class.
List< MonoAllocator, ListenerRecord > listeners
The list of registered listeners.
void Notify(FTreeListener::Event event, File &file, SharedLock *lock, const String &filePath=NULL_STRING)
void MonitorDistinctFile(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const File &file)
Path & AssemblePath(Path &target, lang::CurrentData targetData=lang::CurrentData::Clear) const
const FInfo * operator->() const
TCustom & GetCustomData()
FInfo & GetMutableFInfo()
TCustom & AttachCustomData(TArgs &&... args)
const NString & GetOwnerName() const
bool HasCustomData() const
FTree::ConstCursor ConstCursor
The constant version of type Cursor.
File & operator=(const Cursor &other)
system::PathString Extension() const
const NString & GetGroupName() const
ALIB_WARNINGS_RESTORE system::PathString Stem() const
File(const Cursor &cursor)
const Cursor & AsCursor() const
lang::Placeholder< lang::DbgCriticalSections > DbgCriticalSectionsPH
bool IsNulled() const noexcept
void ConstructT(TArgs &&... args)
TLock & GetLock() const noexcept
void Reset(TArgs &&... args)
AllocatorType & GetAllocator() noexcept
constexpr bool IsNotEmpty() const
integer LastIndexOf(TChar needle, integer startIndex=MAX_LEN) const
TString< TChar > Substring(integer regionStart, integer regionLength=MAX_LEN) const
#define IF_ALIB_THREADS(...)
#define ALIB_WARNINGS_RESTORE
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_WARNINGS_IGNORE_DOCS
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
#define ALIB_ASSERT_ERROR(cond, domain,...)
This namespace implements internals of namespace alib::files.
alib::containers::detail::StringTreeBase< MonoAllocator, FInfo, FTreeNodeHandler, Recycling::Private > TTree
A shortcut to the base class of the base class of class FTree.
void FFormat_File(const alib::Box &box, const alib::String &formatSpec, alib::NumberFormat &nf, alib::AString &target)
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.
Switch
Denotes if sth. is switched on or off.
@ On
Switch it on, switched on, etc.
@ Off
Switch it off, switched off, etc.
@ Keep
Chooses not no clear existing data.
@ Clear
Chooses to clear existing data.
strings::TString< PathCharType > PathString
The string-type used with this ALib Module.
constexpr PathString NULL_PATH
A nulled path string.
strings::TAString< PathCharType, PoolAllocator > PathStringPA
A pool-allocated string representing a path.
constexpr PathString EMPTY_PATH
An empty path string.
std::filesystem::path::value_type PathCharType
files::FInfo FInfo
Type alias in namespace alib.
threads::SharedLock SharedLock
Type alias in namespace alib.
constexpr String NULL_STRING
A nulled string of the default character type.
files::TSharedFTree< SharedLock > SharedFTree
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
files::FTree FTree
Type alias in namespace alib.
characters::wchar wchar
Type alias in namespace alib.
monomem::TPoolAllocator< MonoAllocator > PoolAllocator
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
system::Path Path
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
containers::List< TAllocator, T, TRecycling > List
Type alias in namespace alib.
typename FTreeNodeHandler::CharacterType CharacterType
HashTable< TAllocator, typename NodeKey::ValueDescriptor, typename NodeKey::Hash, typename NodeKey::EqualTo, lang::Caching::Enabled, TRecycling > nodeTable
virtual void Notify(File &file, Event event)=0
virtual ~FTreeListener()
Virtual destructor.
Event
The type of change that imposes the notification of a listener.
@ DeleteNode
A file or directory entry was deleted.
@ CreateNode
A file or directory entry was created.
Record used to manage registered listeners.
FTreeListener::Event event
The event to listen to.
system::PathStringPA fileName
If given, the file's name to listen to.
ConstCursorHandle file
If given, the files to listen to.
ConstCursorHandle subTree
If given, the path of files to listen to.
system::PathStringPA pathSubstring
(including the file name) of files to monitor.
FTreeListener * listener
The listener to register or dispose.
system::PathStringPA pathPrefix
to monitor.
TSharedFTree(size_t initialBufferSizeInKB, unsigned int bufferGrowthInPercent=200)
void DbgCriticalSections(lang::Switch onOff)
TSharedFTree()=default
Constructs an empty instance, hence a cleared automatic pointer.
TSharedFTree & operator=(const TSharedFTree &)=default
TSharedFTree(std::nullptr_t) noexcept
monomem::TSharedMonoVal< FTree, HeapAllocator, TLock > Base
Exposed shortcut to the base type.
static void FreeNode(TTree &tree, TTree::Node &node)
system::PathCharType CharacterType
static ALIB_DLL void AllocateExtendedInfo(StringTree< MonoAllocator, FInfo, detail::FTreeNodeHandler >::Cursor &node, const system::PathString &symLinkDest, const system::PathString &symLinkRealPath)
static void InitializeNode(TTree &tree, TTree::Node &node)
system::PathString NameStringType
ALIB_DLL void operator()(TAString< nchar, lang::HeapAllocator > &target, const files::File &file)
ALIB_DLL void operator()(TAString< wchar, lang::HeapAllocator > &target, const files::File &file)