151 friend struct FTreeNodeHandler;
266 template<
typename TCustom>
269 if( node.data.custom ) {
271 "CustomData to delete does not match attached type.\n"
272 "Deletion has to be performed individually by this software.\n"
273 "This method must only be used if all tree nodes have the same custom data "
275 " Attached type: <{}>\n"
276 " Given type: <{}>" , &
typeid(TCustom), node.data.dbgCustomType )
278 reinterpret_cast<TCustom*
>( node.data.custom ) -> ~TCustom();
279 Pool.free( node.data.custom,
sizeof(TCustom) );
280 node.data.custom=
nullptr;
281 ALIB_DBG( node.data.dbgCustomType=
nullptr; )
333 "Event::Creation will never be invoked with this listener-registration-type." )
357 nullptr,
nullptr, fileName,
463template<
typename TLock>
493 unsigned bufferGrowthInPercent = 200 )
494 :
Base(initialBufferSizeInKB, bufferGrowthInPercent) {
516 template<
typename TRequires=
typename Base::LockType>
517 requires( !std::same_as<TRequires, void> )
519 #if ALIB_DEBUG_CRITICAL_SECTIONS
536 template<
typename TRequires=
typename Base::LockType>
537 requires std::same_as<TRequires, void>
561{ node.name.storage.Allocate(
static_cast<FTree&
>(tree).Pool, node.name.key ); }
565 auto& pool=
static_cast<FTree&
>(tree).Pool;
567 if ( node.name.storage.Length() )
572 FInfo& value= node.data;
574 if( extendedInfo ==
nullptr )
577 if( value.IsSymbolicLink() ) {
579 FInfo::EISymLinkFile& ei= *
static_cast<FInfo::EISymLinkFile*
>(extendedInfo);
581 if( ei.RealTarget.Buffer() != ei.Target.Buffer()
582 && ei.RealTarget.Buffer() !=
nullptr )
583 pool().Free( ei.RealTarget.Buffer(), ei.RealTarget.Length() + 1 );
585 if( ei.Target.Buffer() !=
nullptr )
586 pool().Free( ei.Target.Buffer(), ei.Target.Length() + 1 );
589 pool().Delete(
static_cast<FInfo::EISymLinkFile*
>(extendedInfo) );
591 pool().Delete(
static_cast<FInfo::EISymLinkDir*
>(extendedInfo) );
594 ALIB_DBG( value.SetExtendedInfo(
nullptr) );
599 "FILES",
"Given node is not a directory or symbolic link but still has extendedInfo set." )
601 pool().Delete( reinterpret_cast<
FInfo::EIDirectory*>(extendedInfo) );
604 ALIB_DBG( value.SetExtendedInfo(
nullptr) );
606#include "ALib.Lang.CIMethods.H"
662 :
Cursor( pTree.Root() ) {}
676 return node == other.node
677 && tree == other.tree;
720 FInfo& value= Value();
721 if(handle.value && (!value.
symParent || overwrite))
737 return Value().symParent != 0;
745 uinteger handleValue= Value().symParent;
746 return handleValue ?
File(
GetFTree().ImportCursor(FTree::CursorHandle(handleValue)))
754 uinteger handleValue= Value().symParent;
755 return handleValue ?
File(
GetFTree().ImportCursor(FTree::CursorHandle(handleValue)))
773 return dotPos < 2 ? result
784 : Name().Substring( dotPos + 1 );
842 template<
typename TCustom>
846 "Requested custom object type mismatch.\n"
847 " Attached type: <{}>\n"
848 " Given type: <{}>" , &
typeid(TCustom), Value().dbgCustomType )
850 return *
reinterpret_cast<TCustom*
>( Value().custom );
863 template<
typename TCustom,
typename... TArgs>
865 ALIB_ASSERT_ERROR( Value().custom ==
nullptr,
"FILES",
"Custom data already set." )
867 auto* custom=
GetFTree().Pool().template New<TCustom>( std::forward<TArgs>(args)... );
868 Value().custom= custom;
869 ALIB_DBG(Value().dbgCustomType= &
typeid(TCustom); )
879 template<
typename TCustom>
882 GetFTree().Pool.free( Value().custom,
sizeof(TCustom) );
883 Value().custom=
nullptr;
1045#if !ALIB_SINGLE_THREADED || DOXYGEN
1046DOX_MARKER([DOX_MANUAL_ALIASES_FTREE])
1049DOX_MARKER([DOX_MANUAL_ALIASES_FTREE])
1068namespace APPENDABLES {
1123 unsigned depth = (std::numeric_limits<unsigned int>::max)() );
1139struct hash<
alib::files::FTree::CursorHandle> {
1143 size_t operator()(
const alib::files::FTree::CursorHandle& cursorHandle)
const noexcept {
1144 return cursorHandle.value;
1150struct hash<
alib::files::FTree::ConstCursorHandle> {
1154 size_t operator()(
const alib::files::FTree::ConstCursorHandle& cursorHandle)
const noexcept {
1155 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)
The entry type which is embedded in each tree node.
constexpr ExtendedEntryInfo * GetExtendedInfo() const
@ DIRECTORY
Directory/folder.
FTree(MonoAllocator &allocator)
void Notify(FTreeListener::Event event, const File &file, const String &filePath=NULL_STRING)
NumberFormat numberFormat
void AllocateExtendedInfo(Cursor &node, const system::PathString &symLinkDest, const system::PathString &symLinkRealPath)
OwnerAndGroupResolver ogResolver
void notifyListeners(FTreeListener::Event event, const File &file, const system::PathString &filePath)
void MonitorFilesByName(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const system::PathString &fileName)
const OwnerAndGroupResolver & GetOGResolver() const
void DeleteAllCustomData()
int MonitorStop(FTreeListener *listener)
void MonitorPath(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const FTree::Cursor &cursor)
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)
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.
static void FixSums(Cursor directory)
StringTree< MonoAllocator, FInfo, detail::FTreeNodeHandler > base
Type alias of this classes' base class.
const NumberFormat & GetNumberFormat() const
void MonitorDistinctFile(lang::ContainerOp insertOrRemove, FTreeListener *listener, FTreeListener::Event event, const File &file)
const FInfo * operator->() const
TCustom & GetCustomData()
FInfo & GetMutableFInfo()
TCustom & AttachCustomData(TArgs &&... args)
bool operator!=(const File &other) const
const NString & GetOwnerName() const
bool HasCustomData() const
FTree::ConstCursor ConstCursor
The constant version of type #".Cursor".
File()=default
Defaulted default constructor.
File & operator=(const Cursor &other)
const File GetSymbolicParent() const
system::PathString Extension() const
const NString & GetGroupName() const
void SetSymbolicParent(FTree::CursorHandle handle, bool overwrite=false)
void SetSymbolicParent(File &symbolicParent, bool overwrite=false)
strings::TAString< system::PathCharType > & AssembleRealPath(strings::TAString< system::PathCharType > &target, lang::Inclusion includeFilename) const
bool operator==(const File &other) const
File(const Cursor &cursor)
const Cursor & AsCursor() const
system::PathString Stem() 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
This namespace implements internals of namespace #"alib::files;2".
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 Box &box, const String &formatSpec, NumberFormat &nf, AString &target)
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.
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.
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
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
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.
constexpr String NULL_STRING
A nulled string of the default character type.
files::File File
Type alias in namespace alib.
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace alib.
files::FInfo FInfo
Type alias in namespace alib.
monomem::TPoolAllocator< MonoAllocator > PoolAllocator
boxing::Box Box
Type alias in namespace alib.
files::TSharedFTree< SharedLock > SharedFTree
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
system::Path Path
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
files::FTree FTree
Type alias in namespace alib.
lang::TBitSet< TEnum, enumops::IterableTraits< TEnum >::End, enumops::IterableTraits< TEnum >::Begin > EnumBitSet
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
lang::uinteger uinteger
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(const 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
FTreeListener * listener
The listener to register or dispose.
system::PathStringPA pathPrefix
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.
TSharedFTree(size_t initialBufferSizeInKB, unsigned bufferGrowthInPercent=200)
system::PathCharType CharacterType
system::PathString NameStringType
static void InitializeNode(TTree::Node &node, TTree &tree)
static void FreeNode(TTree::Node &node, TTree &tree)
static void AllocateExtendedInfo(StringTree< MonoAllocator, FInfo, detail::FTreeNodeHandler >::Cursor &node, const system::PathString &symLinkDest, const system::PathString &symLinkRealPath)
size_t operator()(const alib::files::FTree::ConstCursorHandle &cursorHandle) const noexcept
size_t operator()(const alib::files::FTree::CursorHandle &cursorHandle) const noexcept
void operator()(TAString< TChar, lang::HeapAllocator > &target, const files::File &file)