CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
vfsobj.cxh
1/// @brief VFS object definitions
2/// @addtogroup fs_vfs
3/// @{
4#include <cx/thread/rwlock.h>
5
6struct VFSDir;
7
8/// VFS Object
9class VFS {
10 VFSDir *root; ///< Root for namespaceless paths
11
12 // Namespaces are never case sensitive even if the paths are
13 [noinit] hashtable namespaces; ///< Hashtable of string/VFSDir
14 string curdir; ///< Current working directory of the VFS
15 RWLock vfslock; ///< vfslock is for adding entries to the directory cache
16 /// vfsdlock is for operations such as mounting / unmounting / invalidating cache
17 /// that may destroy VFSDir entries and remove mounts
18 RWLock vfsdlock;
19 uint32 flags;
20
21 /// Creates a new empty VFS instance with no mounted providers
22 ///
23 /// The returned VFS contains no data sources. Use vfsMountFS() or
24 /// vfsMountProvider() to attach filesystem providers before accessing files.
25 ///
26 /// @param flags Combination of VFS configuration flags (VFS_ReadOnly, VFS_CaseSensitive, etc.)
27 /// @return New VFS instance (never NULL, call objRelease() when done)
28 ///
29 /// Example:
30 /// @code
31 /// VFS *vfs = vfsCreate(0);
32 /// vfsMountFS(vfs, _S"/", _S"c:/data");
33 /// // ... use VFS ...
34 /// objRelease(&vfs);
35 /// @endcode
36 factory create(uint32 flags);
37
38 // hmm this is a comment
39 /// Creates a VFS pre-configured with OS filesystem access
40 ///
41 /// Returns a VFS that mirrors the underlying OS filesystem. The exact
42 /// namespace configuration is platform-dependent:
43 /// - Windows: Each drive letter (c:, d:, etc.) is a separate namespace
44 /// - Unix: Single root namespace at /
45 ///
46 /// The VFS case sensitivity is configured to match the OS default:
47 /// - Windows: Case-insensitive
48 /// - Unix: Case-sensitive
49 ///
50 /// This is a convenience function equivalent to creating an empty VFS
51 /// and mounting the OS filesystem at the appropriate paths.
52 ///
53 /// @return VFS instance mirroring OS filesystem, or NULL on failure
54 ///
55 /// Example:
56 /// @code
57 /// VFS *vfs = vfsCreateFromFS();
58 /// if (vfs) {
59 /// // VFS paths now map directly to OS filesystem
60 /// VFSFile *f = vfsOpen(vfs, _S"c:/data/file.txt", FS_Read);
61 /// }
62 /// @endcode
63 [canfail] factory createFromFS();
64}
65
66class VFSMount {
67 object:ObjInst provider;
68 uint32 flags;
69
70 factory create(ObjInst *provider, uint32 flags);
71}
72
73/// @}