2 * Copyright 2013 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Ingo Weinhold, ingo_weinhold@gmx.de
8 #ifndef _VIRTUAL_DIRECTORY_MANAGER_H
9 #define _VIRTUAL_DIRECTORY_MANAGER_H
28 class VirtualDirectoryManager
{
30 static VirtualDirectoryManager
* Instance();
32 bool Lock() { return fLock
.Lock(); }
33 void Unlock() { fLock
.Unlock(); }
35 status_t
ResolveDirectoryPaths(
36 const node_ref
& definitionFileNodeRef
,
37 const entry_ref
& definitionFileEntryRef
,
38 BStringList
& _directoryPaths
,
39 node_ref
* _definitionFileNodeRef
= NULL
,
40 entry_ref
* _definitionFileEntryRef
= NULL
);
42 bool GetDefinitionFileChangeTime(
43 const node_ref
& definitionFileRef
,
44 bigtime_t
& _time
) const;
46 bool GetRootDefinitionFile(
47 const node_ref
& definitionFileRef
,
48 node_ref
& _rootDefinitionFileRef
);
49 bool GetSubDirectoryDefinitionFile(
50 const node_ref
& baseDefinitionRef
,
51 const char* subDirName
,
52 entry_ref
& _entryRef
, node_ref
& _nodeRef
);
53 bool GetParentDirectoryDefinitionFile(
54 const node_ref
& subDirDefinitionRef
,
55 entry_ref
& _entryRef
, node_ref
& _nodeRef
);
57 status_t
TranslateDirectoryEntry(
58 const node_ref
& definitionFileRef
,
60 status_t
TranslateDirectoryEntry(
61 const node_ref
& definitionFileRef
,
62 entry_ref
& entryRef
, node_ref
& _nodeRef
);
64 bool DefinitionFileChanged(
65 const node_ref
& definitionFileRef
);
66 // returns whether the directory still
68 status_t
DirectoryRemoved(
69 const node_ref
& definitionFileRef
);
71 static bool GetEntry(const BStringList
& directoryPaths
,
72 const char* name
, entry_ref
* _ref
,
79 typedef std::map
<node_ref
, Info
*> NodeRefInfoMap
;
82 VirtualDirectoryManager();
84 Info
* _InfoForNodeRef(const node_ref
& nodeRef
) const;
86 bool _AddInfo(Info
* info
);
87 void _RemoveInfo(Info
* info
);
89 void _UpdateTree(RootInfo
* root
);
90 void _UpdateTree(Info
* info
);
92 void _RemoveDirectory(Info
* info
);
94 status_t
_ResolveUnknownDefinitionFile(
95 const node_ref
& definitionFileNodeRef
,
96 const entry_ref
& definitionFileEntryRef
,
98 status_t
_CreateRootInfo(
99 const node_ref
& definitionFileNodeRef
,
100 const entry_ref
& definitionFileEntryRef
,
102 status_t
_ReadSubDirectoryDefinitionFileInfo(
103 const entry_ref
& entryRef
,
104 entry_ref
& _rootDefinitionFileEntryRef
,
105 BString
& _subDirPath
);
109 NodeRefInfoMap fInfos
;
112 } // namespace BPrivate
115 #endif // _VIRTUAL_DIRECTORY_MANAGER_H