]> git.draconx.ca Git - upkg.git/blob - src/uobject/vfs.h
bc835a782294137018e5f6f0c3e6a8327d0bb416
[upkg.git] / src / uobject / vfs.h
1 /*
2  *  Functions for handling UObject package search paths.
3  *  Copyright (C) 2009 Nick Bowler
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef U_OBJECT_VFS_H_
19 #define U_OBJECT_VFS_H_
20
21 #include <upkg.h>
22
23 /*
24  * Insert a local package to the VFS.  A "local package" is an explicit
25  * association of a name to a file, and thus can be located outside the normal
26  * search path.  Local packages are searched before any other location.
27  *
28  * Returns a pointer to an internal copy of name on success, or NULL on
29  * failure.  The returned name must not be modified or freed.  If name is
30  * NULL, it is determined automatically from the filename.
31  */
32 const char *u_pkg_vfs_add_local(const char *name, const char *file);
33
34 /*
35  * Remove a local package from the VFS by name.
36  */
37 void u_pkg_vfs_del_local(const char *name);
38
39 /*
40  * Opens a package file by name.  First, local packages are searched for a
41  * match.  If a local match is found, the global search path is never
42  * consulted.  If no local match is found, the directories in the global search
43  * path are examined, in order.
44  *
45  * When searching the global search path, the first file found which both
46  * matches the given name and can be opened successfully is used.  A file
47  * foo.EXT matches the name if foo is equal to name (without regard to case)
48  * and EXT is one of u, utx, uax, umx or unr.  If multiple extensions
49  * are valid, they are tried in this order.
50  *
51  * Note that the particular file extension used does not make any difference
52  * as to what sort of objects can be contained in a package.
53  *
54  * Returns the opened package on success, or NULL on failure.
55  */
56 struct upkg *u_pkg_vfs_open_by_name(const char *name);
57
58 /*
59  * Initialize the UObject VFS system.  Returns 0 on success, -1 otherwise.
60  * The VFS system can be safely initialized multiple times.
61  */
62 int u_pkg_vfs_init(void);
63
64 /*
65  * Shutdown the UObject VFS system.
66  * The VFS system is only shut down when this function has been called as
67  * many times as u_pkg_vfs_init.
68  */
69 void u_pkg_vfs_exit(void);
70
71 #endif