Pyrogenesis  trunk
vfs_lookup.h
Go to the documentation of this file.
1 /* Copyright (c) 2013 Wildfire Games
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 /*
24  * look up directories/files by traversing path components.
25  */
26 
27 #ifndef INCLUDED_VFS_LOOKUP
28 #define INCLUDED_VFS_LOOKUP
29 
30 #include "lib/file/vfs/vfs_path.h"
31 
32 class VfsFile;
33 class VfsDirectory;
34 
35 // note: VfsDirectory pointers are non-const because they may be
36 // populated during the lookup.
37 
39 {
40  // add (if they do not already exist) subdirectory components
41  // encountered in the path[name].
43 
44  // if VFS directories encountered are not already associated
45  // with a real directory, do so (creating the directories
46  // if they do not already exist).
48 
49  // don't populate the directories encountered. this makes sense
50  // when adding files from an archive, which would otherwise
51  // cause nearly every directory to be populated.
53 
54  // even create directories if they are already present, this is
55  // useful to write new files to the directory that was attached
56  // last, if the directory wasn't mounted with VFS_MOUNT_REPLACEABLE
58 };
59 
60 /**
61  * Resolve a pathname.
62  *
63  * @param pathname
64  * @param startDirectory VfsStartDirectory.
65  * @param directory is set to the last directory component that is encountered.
66  * @param pfile File is set to 0 if there is no name component, otherwise the
67  * corresponding file.
68  * @param flags @see VfsLookupFlags.
69  * @return Status (INFO::OK if all components in pathname exist).
70  *
71  * to allow noiseless file-existence queries, this does not raise warnings.
72  **/
73 extern Status vfs_Lookup(const VfsPath& pathname, VfsDirectory* startDirectory, VfsDirectory*& directory, VfsFile** pfile, size_t flags = 0);
74 
75 #endif // #ifndef INCLUDED_VFS_LOOKUP
Definition: vfs_lookup.h:47
Definition: vfs_tree.h:78
Definition: path.h:77
i64 Status
Error handling system.
Definition: status.h:171
Status vfs_Lookup(const VfsPath &pathname, VfsDirectory *startDirectory, VfsDirectory *&directory, VfsFile **pfile, size_t flags=0)
Resolve a pathname.
Definition: vfs_lookup.cpp:75
Definition: vfs_lookup.h:52
VfsLookupFlags
Definition: vfs_lookup.h:38
Definition: vfs_tree.h:37
Definition: vfs_lookup.h:42
Definition: vfs_lookup.h:57