{
struct upkg_priv *priv = U_PKG_GET_PRIV(m);
int (*init_func)(GTypeModule *);
- const char *file;
- file = u_pkg_vfs_lookup(m->name);
- if (file) {
- U_PKG(m)->pkg = upkg_fopen(file);
- if (!U_PKG(m)->pkg) {
- return FALSE;
- }
- }
+ /* Ignore failure here until we get rid of native-only packages. */
+ U_PKG(m)->pkg = u_pkg_vfs_open_by_name(m->name);
priv->native = lt_dlopenext(m->name);
if (priv->native) {
#include <strings.h>
#include <uobject/vfs.h>
+#include <upkg.h>
#include <ltdl.h>
#include "avl.h"
free(item);
}
-const char *u_pkg_vfs_lookup(const char *name)
+struct upkg *u_pkg_vfs_open_by_name(const char *name)
{
struct local_pkg spec = { .name = (char *)name }, *item;
- if (!local_tree)
+ if (!initialized)
return NULL;
item = avl_find(local_tree, &spec);
- if (!item)
- return NULL;
- return item->file;
+ if (item)
+ return upkg_fopen(item->file);
+ return NULL;
}
int u_pkg_vfs_init(void)
#ifndef U_OBJECT_VFS_H_
#define U_OBJECT_VFS_H_
+#include <upkg.h>
+
/*
* Insert a local package to the VFS. A "local package" is an explicit
* association of a name to a file, and thus can be located outside the normal
void u_pkg_vfs_del_local(const char *name);
/*
- * Find a package by name in the VFS. Names are case-insensitive.
+ * Opens a package file by name. First, local packages are searched for a
+ * match. If a local match is found, the global search path is never
+ * consulted. If no local match is found, the directories in the global search
+ * path are examined, in order.
+ *
+ * When searching the global search path, the first file found which both
+ * matches the given name and can be opened successfully is used. A file
+ * foo.EXT matches the name if foo is equal to name (without regard to case)
+ * and EXT is one of u, utx, uax, umx or unr. If multiple extensions
+ * are valid, they are tried in this order.
+ *
+ * Note that the particular file extension used does not make any difference
+ * as to what sort of objects can be contained in a package.
+ *
+ * Returns the opened package on success, or NULL on failure.
*/
-const char *u_pkg_vfs_lookup(const char *name);
+struct upkg *u_pkg_vfs_open_by_name(const char *name);
/*
* Initialize the UObject VFS system. Returns 0 on success, -1 otherwise.