Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
vfs_lookup.h
Go to the documentation of this file.
1/* Copyright (C) 2021 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
31
32class VfsFile;
33class 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].
42 // If subdirectores do not exist on disk, they will be created.
44
45 // Don't populate the directories encountered. This makes sense
46 // when adding files from an archive, which would otherwise
47 // cause nearly every directory to be populated.
49
50 // Perform a 'real path' lookup.
51 // Because the VFS maps multiple 'disk paths' to a single tree of paths,
52 // the 'real directory' of a VFS directory at any given time may be almost anything,
53 // in particular not its real parent directory on disk.
54 // To make writing predictable, we'll return a path relative to the 'disk path' of the
55 // highest priority subdirectory found in the lookup path.
56 // See test_vfs_real_paths.h for examples of this behaviour.
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 **/
73extern Status vfs_Lookup(const VfsPath& pathname, VfsDirectory* startDirectory, VfsDirectory*& directory, VfsFile** pfile, size_t flags = 0);
74
75#endif // #ifndef INCLUDED_VFS_LOOKUP
Definition: path.h:80
Definition: vfs_tree.h:79
Definition: vfs_tree.h:38
i64 Status
Error handling system.
Definition: status.h:173
VfsLookupFlags
Definition: vfs_lookup.h:39
@ VFS_LOOKUP_SKIP_POPULATE
Definition: vfs_lookup.h:48
@ VFS_LOOKUP_REAL_PATH
Definition: vfs_lookup.h:57
@ VFS_LOOKUP_ADD
Definition: vfs_lookup.h:43
Status vfs_Lookup(const VfsPath &pathname, VfsDirectory *startDirectory, VfsDirectory *&directory, VfsFile **pfile, size_t flags=0)
Resolve a pathname.
Definition: vfs_lookup.cpp:73