if base dir is not found, do not check sub dirs

This commit is contained in:
Roman Fomin 2024-05-27 15:08:29 +07:00
parent 7e46bed40a
commit 0c7725ae6e
4 changed files with 17 additions and 10 deletions

View File

@ -37,14 +37,14 @@ static int FileLength(int descriptor)
return st.st_size; return st.st_size;
} }
static void W_FILE_AddDir(w_handle_t handle, const char *path, static boolean W_FILE_AddDir(w_handle_t handle, const char *path,
const char *start_marker, const char *end_marker) const char *start_marker, const char *end_marker)
{ {
int startlump = numlumps; int startlump = numlumps;
glob_t *glob; glob_t *glob;
if (!strcmp(path, ".")) if (path[0] == '.')
{ {
glob = I_StartGlob(handle.p1.base_path, "*.*", glob = I_StartGlob(handle.p1.base_path, "*.*",
GLOB_FLAG_NOCASE | GLOB_FLAG_SORTED); GLOB_FLAG_NOCASE | GLOB_FLAG_SORTED);
@ -58,7 +58,7 @@ static void W_FILE_AddDir(w_handle_t handle, const char *path,
if (!glob) if (!glob)
{ {
return; return false;
} }
while (true) while (true)
@ -103,6 +103,8 @@ static void W_FILE_AddDir(w_handle_t handle, const char *path,
{ {
W_AddMarker(end_marker); W_AddMarker(end_marker);
} }
return true;
} }
static int *descriptors = NULL; static int *descriptors = NULL;

View File

@ -25,8 +25,8 @@ typedef enum
typedef struct w_module_s typedef struct w_module_s
{ {
void (*AddDir)(w_handle_t handle, const char *path, boolean (*AddDir)(w_handle_t handle, const char *path,
const char *start_marker, const char *end_marker); const char *start_marker, const char *end_marker);
w_type_t (*Open)(const char *path, w_handle_t *handle); w_type_t (*Open)(const char *path, w_handle_t *handle);
void (*Read)(w_handle_t handle, void *dest, int size); void (*Read)(w_handle_t handle, void *dest, int size);
void (*Close)(void); void (*Close)(void);

View File

@ -129,7 +129,10 @@ static w_module_t *modules[] =
static void AddDirs(w_module_t *module, w_handle_t handle, const char *base) static void AddDirs(w_module_t *module, w_handle_t handle, const char *base)
{ {
module->AddDir(handle, base, NULL, NULL); if (!module->AddDir(handle, base, NULL, NULL))
{
return;
}
for (int i = 0; i < arrlen(subdirs); ++i) for (int i = 0; i < arrlen(subdirs); ++i)
{ {

View File

@ -101,8 +101,8 @@ static void AddWadInMem(mz_zip_archive *zip, const char *name, int index,
} }
} }
static void W_ZIP_AddDir(w_handle_t handle, const char *path, static boolean W_ZIP_AddDir(w_handle_t handle, const char *path,
const char *start_marker, const char *end_marker) const char *start_marker, const char *end_marker)
{ {
mz_zip_archive *zip = handle.p1.zip; mz_zip_archive *zip = handle.p1.zip;
@ -121,7 +121,7 @@ static void W_ZIP_AddDir(w_handle_t handle, const char *path,
if (index < 0) if (index < 0)
{ {
return; return false;
} }
++index; ++index;
@ -185,6 +185,8 @@ static void W_ZIP_AddDir(w_handle_t handle, const char *path,
{ {
W_AddMarker(end_marker); W_AddMarker(end_marker);
} }
return true;
} }
static mz_zip_archive **zips = NULL; static mz_zip_archive **zips = NULL;