12template<
typename TLock>
148 friend struct FTreeNodeHandler;
261 template<
typename TCustom>
264 if( node.data.custom ) {
266 "CustomData to delete does not match attached type.\n"
267 "Deletion has to be performed individually by this software.\n"
268 "This method must only be used if all tree nodes have the same custom data "
270 " Attached type: <{}>\n"
271 " Given type: <{}>" , &
typeid(TCustom), node.data.dbgCustomType )
273 static_cast<TCustom*
>( node.data.custom ) -> ~TCustom();
274 Pool.free( node.data.custom,
sizeof(TCustom) );
275 node.data.custom=
nullptr;
276 ALIB_DBG( node.data.dbgCustomType=
nullptr; )
328 "Event::Creation will never be invoked with this listener-registration-type." )
346 registerListener( listener, insertOrRemove, event,
nullptr,
nullptr, fileName,
438template<
typename TLock>
467 unsigned bufferGrowthInPercent = 200 )
468 :
Base(initialBufferSizeInKB, bufferGrowthInPercent) {
490 template<
typename TRequires=
typename Base::LockType>
491 requires( !std::same_as<TRequires, void> )
493 #if ALIB_DEBUG_CRITICAL_SECTIONS
510 template<
typename TRequires=
typename Base::LockType>
511 requires std::same_as<TRequires, void>
535{ node.name.storage.Allocate(
static_cast<FTree&
>(tree).Pool, node.name.key ); }
539 auto& pool=
static_cast<FTree&
>(tree).Pool;
541 if ( node.name.storage.Length() )
548 if( extendedInfo ==
nullptr )
551 if( value.IsSymbolicLink() ) {
553 FTValue::EISymLinkFile& ei= *
static_cast<FTValue::EISymLinkFile*
>(extendedInfo);
555 if( ei.RealTarget.Length() && ei.RealTarget.Buffer() != ei.Target.Buffer() )
556 pool().Free( ei.RealTarget.Buffer(), ei.RealTarget.Length() + 1 );
558 if( ei.Target.Buffer() )
559 pool().Free( ei.Target.Buffer(), ei.Target.Length() + 1 );
562 pool().Delete(
static_cast<FTValue::EISymLinkFile*
>(extendedInfo) );
564 pool().Delete(
static_cast<FTValue::EISymLinkDir*
>(extendedInfo) );
567 ALIB_DBG( value.SetExtendedInfo(
nullptr) );
572 "FILETREE",
"Given node is not a directory or symbolic link but still has extendedInfo set." )
574 pool().Delete( static_cast<
FTValue::EIDirectory*>(extendedInfo) );
577 ALIB_DBG( value.SetExtendedInfo(
nullptr) );
579#include "ALib.Lang.CIMethods.H"
635 :
Cursor( pTree.Root() ) {}
648 bool operator==(
const FTFile &other)
const {
return node == other.node && tree == other.tree; }
693 if(handle.value && (!value.
symParent || overwrite))
722 uinteger handleValue= Value().symParent;
723 return handleValue ?
FTFile(
GetFTree().ImportCursor(FTree::CursorHandle(handleValue)))
731 uinteger handleValue= Value().symParent;
732 return handleValue ?
FTFile(
GetFTree().ImportCursor(FTree::CursorHandle(handleValue)))
742 using Cursor::IsValid;
745 using Cursor::IsInvalid;
760 return dotPos < 2 ? result
771 : Name().Substring( dotPos + 1 );
829 template<
typename TCustom>
831 ALIB_ASSERT_ERROR( Value().custom !=
nullptr,
"FILETREE",
"No custom data set." )
833 "Requested custom object type mismatch.\n"
834 " Attached type: <{}>\n"
835 " Given type: <{}>" , &
typeid(TCustom), Value().dbgCustomType )
837 return *
static_cast<TCustom*
>( Value().custom );
850 template<
typename TCustom,
typename... TArgs>
852 ALIB_ASSERT_ERROR( Value().custom ==
nullptr,
"FILETREE",
"Custom data already set." )
854 auto* custom=
GetFTree().Pool().template New<TCustom>( std::forward<TArgs>(args)... );
855 Value().custom= custom;
856 ALIB_DBG(Value().dbgCustomType= &
typeid(TCustom); )
866 template<
typename TCustom>
869 GetFTree().Pool.free( Value().custom,
sizeof(TCustom) );
870 Value().custom=
nullptr;
1035#if !ALIB_SINGLE_THREADED || DOXYGEN
1036DOX_MARKER([DOX_MANUAL_ALIASES_FTREE])
1039DOX_MARKER([DOX_MANUAL_ALIASES_FTREE])
1058namespace APPENDABLES {
1062template<
typename TChar>
1113 unsigned depth = (std::numeric_limits<unsigned int>::max)() );
1127struct hash<
alib::filetree::FTree::CursorHandle> {
1131 size_t operator()(
const alib::filetree::FTree::CursorHandle& cursorHandle)
const noexcept {
1132 return cursorHandle.value;
1138struct hash<
alib::filetree::FTree::ConstCursorHandle> {
1142 size_t operator()(
const alib::filetree::FTree::ConstCursorHandle& cursorHandle)
const noexcept {
1143 return cursorHandle.value;
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
TCursor & operator=(const TCursor &) noexcept=default
TCursor< true > ConstCursor
StringTree(AllocatorType &allocator, CharacterType pathSeparator)
const FTValue * operator->() const
strings::TAString< PathCharType > & AssembleRealPath(strings::TAString< PathCharType > &target, lang::Inclusion includeFilename) const
void ClearSymbolicParent()
const FTFile GetSymbolicParent() const
const Cursor & AsCursor() const
FTFile()=default
Defaulted default constructor.
TCustom & AttachCustomData(TArgs &&... args)
bool operator!=(const FTFile &other) const
TCustom & GetCustomData()
bool operator==(const FTFile &other) const
const NString GetOwnerName() const
bool HasCustomData() const
FTFile(const Cursor &cursor)
FTFile & operator=(const Cursor &other)
void SetSymbolicParent(FTree::CursorHandle handle, bool overwrite=false)
FTFile GetSymbolicParent()
FTValue & GetMutableFInfo()
const NString GetGroupName() const
void SetSymbolicParent(FTFile &symbolicParent, bool overwrite=false)
PathString Extension() const
FTree::ConstCursor ConstCursor
The constant version of type #".Cursor".
constexpr ExtendedEntryInfo * GetExtendedInfo() const
OwnerAndGroupResolver ogResolver
void registerListener(FTreeListener *listener, lang::ContainerOp insertOrRemove, FTreeListener::Event event, const FTFile *file, const StringTree::Cursor *subTree, const PathString &fileName, const PathString &pathPrefix, const PathString &pathSubstring)
void MonitorPathSubstring(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const PathString &pathSubstring)
FTree(MonoAllocator &allocator)
NumberFormat numberFormat
StringTree< MonoAllocator, FTValue, detail::FTreeNodeHandler > base
Type alias of this classes' base class.
NumberFormat & GetNumberFormat()
void MonitorDistinctFile(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const FTFile &file)
void notifyListeners(FTreeListener::Event event, FTFile &file, const PathString &filePath)
int MonitorStop(FTreeListener *listener)
void MonitorFilesByName(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const PathString &fileName)
const OwnerAndGroupResolver & GetOGResolver() const
void MonitorPathPrefix(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const PathString &pathPrefix)
void MonitorPath(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const FTree::Cursor &cursor)
void AllocateExtendedInfo(Cursor &node, const PathString &symLinkDest, const PathString &symLinkRealPath)
void DeleteAllCustomData()
static void FixSums(Cursor directory)
void Notify(FTreeListener::Event event, FTFile file, const PathString &filePath=NULL_PATH)
ListMA< ListenerRecord > listeners
The list of registered listeners.
const NumberFormat & GetNumberFormat() 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
@ DIRECTORY
Directory/folder.
This namespace implements internals of namespace #"alib::filetree;2".
containers::detail::StringTreeBase< MonoAllocator, FTValue, FTreeNodeHandler, Recycling::Private > TTree
A shortcut to the base class of the base class of class #"FTree".
void FFormat_File(const Box &box, const String &formatSpec, NumberFormat &nf, AString &target)
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)())
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.
Inclusion
Denotes how members of a set something should be taken into account.
@ Exclude
Chooses exclusion.
@ Include
Chooses inclusion.
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
filetree::FTValue FTValue
Type alias in namespace #"%alib".
strings::TNumberFormat< character > NumberFormat
Type alias in namespace #"%alib".
strings::TString< nchar > NString
Type alias in namespace #"%alib".
threads::SharedLock SharedLock
Type alias in namespace #"%alib".
filetree::TSharedFTree< SharedLock > SharedFTree
Type alias in namespace #"%alib".
filetree::FTree FTree
Type alias in namespace #"%alib".
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace #"%alib".
monomem::TPoolAllocator< MonoAllocator > PoolAllocator
boxing::Box Box
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
system::Path Path
Type alias in namespace #"%alib".
constexpr PathString NULL_PATH
A nulled path string.
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
strings::TAString< PathCharType, PoolAllocator > PathStringPA
A pool-allocated string representing a path.
strings::TString< PathCharType > PathString
The string-type used with this ALib Module.
lang::TBitSet< TEnum, enumops::IterableTraits< TEnum >::End, enumops::IterableTraits< TEnum >::Begin > EnumBitSet
filetree::FTFile FTFile
Type alias in namespace #"%alib".
std::filesystem::path::value_type PathCharType
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
lang::uinteger uinteger
Type alias in namespace #"%alib".
constexpr PathString EMPTY_PATH
An empty path string.
typename FTreeNodeHandler::CharacterType CharacterType
HashTable< TAllocator, typename NodeKey::ValueDescriptor, typename NodeKey::Hash, typename NodeKey::EqualTo, lang::Caching::Enabled, TRecycling > nodeTable
virtual ~FTreeListener()
Virtual destructor.
virtual void Notify(FTFile &file, Event event)=0
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 * listener
The listener to register or dispose.
PathStringPA fileName
If given, the file's name to listen to.
ConstCursorHandle subTree
If given, the path of files to listen to.
FTreeListener::Event event
The event to listen to.
ConstCursorHandle file
If given, the files to listen to.
PathStringPA pathSubstring
TSharedFTree()=default
Constructs an empty instance, hence a cleared automatic pointer.
TSharedFTree(size_t initialBufferSizeInKB, unsigned bufferGrowthInPercent=200)
TSharedFTree & operator=(const TSharedFTree &)=default
void DbgCriticalSections(lang::Switch onOff)
monomem::TSharedMonoVal< FTree, HeapAllocator, TLock > Base
Exposed shortcut to the base type.
TSharedFTree(std::nullptr_t) noexcept
PathCharType CharacterType
PathString NameStringType
static void AllocateExtendedInfo(StringTree< MonoAllocator, FTValue, FTreeNodeHandler >::Cursor &node, const PathString &symLinkDest, const PathString &symLinkRealPath)
static void FreeNode(TTree::Node &node, TTree &tree)
static void InitializeNode(TTree::Node &node, TTree &tree)
size_t operator()(const alib::filetree::FTree::ConstCursorHandle &cursorHandle) const noexcept
size_t operator()(const alib::filetree::FTree::CursorHandle &cursorHandle) const noexcept
void operator()(TAString< TChar, lang::HeapAllocator > &target, const filetree::FTFile &file)