parent
bfc6fb04f4
commit
a4d4650a1b
34
src/xfile.cc
34
src/xfile.cc
|
@ -12,11 +12,31 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef enum XFileEnumerationEntryType {
|
||||||
|
XFILE_ENUMERATION_ENTRY_TYPE_FILE,
|
||||||
|
XFILE_ENUMERATION_ENTRY_TYPE_DIRECTORY,
|
||||||
|
XFILE_ENUMERATION_ENTRY_TYPE_DFILE,
|
||||||
|
} XFileEnumerationEntryType;
|
||||||
|
|
||||||
|
typedef struct XListEnumerationContext {
|
||||||
|
char name[COMPAT_MAX_PATH];
|
||||||
|
unsigned char type;
|
||||||
|
XList* xlist;
|
||||||
|
} XListEnumerationContext;
|
||||||
|
|
||||||
|
typedef bool(XListEnumerationHandler)(XListEnumerationContext* context);
|
||||||
|
|
||||||
|
static bool xlistEnumerate(const char* pattern, XListEnumerationHandler* handler, XList* xlist);
|
||||||
|
static int xbaseMakeDirectory(const char* path);
|
||||||
|
static void xbaseCloseAll();
|
||||||
|
static void xbaseExitHandler(void);
|
||||||
|
static bool xlistEnumerateHandler(XListEnumerationContext* context);
|
||||||
|
|
||||||
// 0x6B24D0
|
// 0x6B24D0
|
||||||
XBase* gXbaseHead;
|
static XBase* gXbaseHead;
|
||||||
|
|
||||||
// 0x6B24D4
|
// 0x6B24D4
|
||||||
bool gXbaseExitHandlerRegistered;
|
static bool gXbaseExitHandlerRegistered;
|
||||||
|
|
||||||
// 0x4DED6C
|
// 0x4DED6C
|
||||||
int xfileClose(XFile* stream)
|
int xfileClose(XFile* stream)
|
||||||
|
@ -534,7 +554,7 @@ bool xbaseOpen(const char* path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4DFB3C
|
// 0x4DFB3C
|
||||||
bool xlistEnumerate(const char* pattern, XListEnumerationHandler* handler, XList* xlist)
|
static bool xlistEnumerate(const char* pattern, XListEnumerationHandler* handler, XList* xlist)
|
||||||
{
|
{
|
||||||
assert(pattern); // "filespec", "xfile.c", 845
|
assert(pattern); // "filespec", "xfile.c", 845
|
||||||
assert(handler); // "enumfunc", "xfile.c", 846
|
assert(handler); // "enumfunc", "xfile.c", 846
|
||||||
|
@ -679,7 +699,7 @@ void xlistFree(XList* xlist)
|
||||||
// Recursively creates specified file path.
|
// Recursively creates specified file path.
|
||||||
//
|
//
|
||||||
// 0x4DFFAC
|
// 0x4DFFAC
|
||||||
int xbaseMakeDirectory(const char* filePath)
|
static int xbaseMakeDirectory(const char* filePath)
|
||||||
{
|
{
|
||||||
char workingDirectory[COMPAT_MAX_PATH];
|
char workingDirectory[COMPAT_MAX_PATH];
|
||||||
if (getcwd(workingDirectory, COMPAT_MAX_PATH) == NULL) {
|
if (getcwd(workingDirectory, COMPAT_MAX_PATH) == NULL) {
|
||||||
|
@ -750,7 +770,7 @@ int xbaseMakeDirectory(const char* filePath)
|
||||||
// NOTE: Inlined.
|
// NOTE: Inlined.
|
||||||
//
|
//
|
||||||
// 0x4E01F8
|
// 0x4E01F8
|
||||||
void xbaseCloseAll()
|
static void xbaseCloseAll()
|
||||||
{
|
{
|
||||||
XBase* curr = gXbaseHead;
|
XBase* curr = gXbaseHead;
|
||||||
gXbaseHead = NULL;
|
gXbaseHead = NULL;
|
||||||
|
@ -770,14 +790,14 @@ void xbaseCloseAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
// xbase atexit
|
// xbase atexit
|
||||||
void xbaseExitHandler(void)
|
static void xbaseExitHandler(void)
|
||||||
{
|
{
|
||||||
// NOTE: Uninline.
|
// NOTE: Uninline.
|
||||||
xbaseCloseAll();
|
xbaseCloseAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4E0278
|
// 0x4E0278
|
||||||
bool xlistEnumerateHandler(XListEnumerationContext* context)
|
static bool xlistEnumerateHandler(XListEnumerationContext* context)
|
||||||
{
|
{
|
||||||
if (context->type == XFILE_ENUMERATION_ENTRY_TYPE_DIRECTORY) {
|
if (context->type == XFILE_ENUMERATION_ENTRY_TYPE_DIRECTORY) {
|
||||||
return true;
|
return true;
|
||||||
|
|
22
src/xfile.h
22
src/xfile.h
|
@ -46,23 +46,6 @@ typedef struct XList {
|
||||||
char** fileNames;
|
char** fileNames;
|
||||||
} XList;
|
} XList;
|
||||||
|
|
||||||
typedef enum XFileEnumerationEntryType {
|
|
||||||
XFILE_ENUMERATION_ENTRY_TYPE_FILE,
|
|
||||||
XFILE_ENUMERATION_ENTRY_TYPE_DIRECTORY,
|
|
||||||
XFILE_ENUMERATION_ENTRY_TYPE_DFILE,
|
|
||||||
} XFileEnumerationEntryType;
|
|
||||||
|
|
||||||
typedef struct XListEnumerationContext {
|
|
||||||
char name[COMPAT_MAX_PATH];
|
|
||||||
unsigned char type;
|
|
||||||
XList* xlist;
|
|
||||||
} XListEnumerationContext;
|
|
||||||
|
|
||||||
typedef bool(XListEnumerationHandler)(XListEnumerationContext* context);
|
|
||||||
|
|
||||||
extern XBase* gXbaseHead;
|
|
||||||
extern bool gXbaseExitHandlerRegistered;
|
|
||||||
|
|
||||||
int xfileClose(XFile* stream);
|
int xfileClose(XFile* stream);
|
||||||
XFile* xfileOpen(const char* filename, const char* mode);
|
XFile* xfileOpen(const char* filename, const char* mode);
|
||||||
int xfilePrintFormatted(XFile* xfile, const char* format, ...);
|
int xfilePrintFormatted(XFile* xfile, const char* format, ...);
|
||||||
|
@ -80,12 +63,7 @@ int xfileEof(XFile* stream);
|
||||||
long xfileGetSize(XFile* stream);
|
long xfileGetSize(XFile* stream);
|
||||||
bool xbaseReopenAll(char* paths);
|
bool xbaseReopenAll(char* paths);
|
||||||
bool xbaseOpen(const char* path);
|
bool xbaseOpen(const char* path);
|
||||||
bool xlistEnumerate(const char* pattern, XListEnumerationHandler* handler, XList* xlist);
|
|
||||||
bool xlistInit(const char* pattern, XList* xlist);
|
bool xlistInit(const char* pattern, XList* xlist);
|
||||||
void xlistFree(XList* xlist);
|
void xlistFree(XList* xlist);
|
||||||
int xbaseMakeDirectory(const char* path);
|
|
||||||
void xbaseCloseAll();
|
|
||||||
void xbaseExitHandler(void);
|
|
||||||
bool xlistEnumerateHandler(XListEnumerationContext* context);
|
|
||||||
|
|
||||||
#endif /* XFILE_H */
|
#endif /* XFILE_H */
|
||||||
|
|
Loading…
Reference in New Issue