2019-11-01 18:25:42 +00:00
|
|
|
#pragma once
|
|
|
|
// Directory searching routines
|
|
|
|
|
2020-04-11 21:50:43 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include "zstring.h"
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-11-01 18:25:42 +00:00
|
|
|
// 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;
|
|
|
|
};
|
2019-11-01 18:25:42 +00:00
|
|
|
struct WinData
|
|
|
|
{
|
|
|
|
uint32_t Attribs;
|
2020-04-11 21:50:43 +00:00
|
|
|
FileTime Times[3];
|
2019-11-01 18:25:42 +00:00
|
|
|
uint32_t Size[2];
|
|
|
|
uint32_t Reserved[2];
|
|
|
|
wchar_t Name[260];
|
|
|
|
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);
|