raze/source/common/utility/findfile.h

99 lines
2.3 KiB
C
Raw Normal View History

#pragma once
// Directory searching routines
2020-04-11 21:50:43 +00:00
#include <stdint.h>
#include "zstring.h"
enum
{
ZPATH_MAX = 260
};
2020-04-11 21:50:43 +00:00
#ifndef _WIN32
#include <dirent.h>
2020-04-11 21:50:43 +00:00
struct findstate_t
{
private:
FString path;
struct dirent **namelist;
int current;
int count;
friend void *I_FindFirst(const char *filespec, findstate_t *fileinfo);
friend int I_FindNext(void *handle, findstate_t *fileinfo);
friend const char *I_FindName(findstate_t *fileinfo);
friend int I_FindAttr(findstate_t *fileinfo);
friend int I_FindClose(void *handle);
};
int I_FindAttr (findstate_t *fileinfo);
inline const char *I_FindName(findstate_t *fileinfo)
{
return (fileinfo->namelist[fileinfo->current]->d_name);
}
#define FA_RDONLY 1
#define FA_HIDDEN 2
#define FA_SYSTEM 4
#define FA_DIREC 8
#define FA_ARCH 16
#else
// Mirror WIN32_FIND_DATAW in <winbase.h>
struct findstate_t
{
private:
2020-04-11 21:50:43 +00:00
struct FileTime
{
uint32_t lo, hi;
};
struct WinData
{
uint32_t Attribs;
2020-04-11 21:50:43 +00:00
FileTime Times[3];
uint32_t Size[2];
uint32_t Reserved[2];
wchar_t Name[ZPATH_MAX];
wchar_t AltName[14];
};
WinData FindData;
FString UTF8Name;
friend void *I_FindFirst(const char *filespec, findstate_t *fileinfo);
friend int I_FindNext(void *handle, findstate_t *fileinfo);
friend const char *I_FindName(findstate_t *fileinfo);
friend int I_FindAttr(findstate_t *fileinfo);
};
const char *I_FindName(findstate_t *fileinfo);
inline int I_FindAttr(findstate_t *fileinfo)
{
return fileinfo->FindData.Attribs;
}
#define FA_RDONLY 0x00000001
#define FA_HIDDEN 0x00000002
#define FA_SYSTEM 0x00000004
#define FA_DIREC 0x00000010
2020-04-11 21:50:43 +00:00
#define FA_ARCH 0x00000020
#endif
void *I_FindFirst (const char *filespec, findstate_t *fileinfo);
int I_FindNext (void *handle, findstate_t *fileinfo);
int I_FindClose (void *handle);
class FConfigFile;
bool D_AddFile(TArray<FString>& wadfiles, const char* file, bool check, int position, FConfigFile* config);
void D_AddWildFile(TArray<FString>& wadfiles, const char* value, const char *extension, FConfigFile* config);
void D_AddConfigFiles(TArray<FString>& wadfiles, const char* section, const char* extension, FConfigFile* config);
void D_AddDirectory(TArray<FString>& wadfiles, const char* dir, const char *filespec, FConfigFile* config);
const char* BaseFileSearch(const char* file, const char* ext, bool lookfirstinprogdir, FConfigFile* config);