2 * Functions for handling UObject package search paths.
3 * Copyright © 2009-2011 Nick Bowler
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.
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.
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/>.
18 #ifndef U_OBJECT_VFS_H_
19 #define U_OBJECT_VFS_H_
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.
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.
32 const char *u_pkg_vfs_add_local(const char *name
, const char *file
);
35 * Remove a local package from the VFS by name.
37 void u_pkg_vfs_del_local(const char *name
);
40 * Set the global VFS search path - a LT_PATHSEP-delimited sequence of
41 * directories to be searched for packages after local packages.
43 * Returns 0 on success, or -1 on failure.
45 int u_pkg_vfs_set_search_path(const char *path
);
48 * Appends a directory to the global VFS search path. This directory will
49 * be searched after any directories already in the path.
51 * Returns 0 on success, or -1 on failure.
53 int u_pkg_vfs_add_search_dir(const char *path
);
56 * Get the global VFS search path.
58 const char *u_pkg_vfs_get_search_path(void);
61 * Opens a package file by name. First, local packages are searched for a
62 * match. If a local match is found, the global search path is never
63 * consulted. If no local match is found, the directories in the global search
64 * path are examined, in order.
66 * When searching the global search path, the first file found which both
67 * matches the given name and can be opened successfully is used. A file
68 * foo.EXT matches the name if foo is equal to name (without regard to case)
69 * and EXT is one of u, utx, uax, umx or unr. If multiple extensions
70 * are valid, they are tried in this order.
72 * Note that the particular file extension used does not make any difference
73 * as to what sort of objects can be contained in a package.
75 * Returns the opened package on success, or NULL on failure.
77 struct upkg
*u_pkg_vfs_open_by_name(const char *name
);
80 * Initialize the UObject VFS system. Returns 0 on success, -1 otherwise.
81 * The VFS system can be safely initialized multiple times.
83 int u_pkg_vfs_init(void);
86 * Shutdown the UObject VFS system.
87 * The VFS system is only shut down when this function has been called as
88 * many times as u_pkg_vfs_init.
90 void u_pkg_vfs_exit(void);