#ifndef _STDFILEUTIL_H
#define _STDFILEUTIL_H

#include "types.h"

#ifdef __cplusplus
extern "C" {
#endif

#define stdFileUtil_NewFind_ADDR (0x00431740)
#define stdFileUtil_DisposeFind_ADDR (0x004317E0)
#define stdFileUtil_FindReset_ADDR (0x00431820)
#define stdFileUtil_FindNext_ADDR (0x00431850)
#define stdFileUtil_FindQuick_ADDR (0x00431910)
#define stdFileUtil_CountMatches_ADDR (0x00431A70)
#define stdFileUtil_MkDir_ADDR (0x00431BC0)
#define stdFileUtil_FileExists_ADDR (0x00431BD0)
#define stdFileUtil_RmDir_ADDR (0x00431C00)
#define stdFileUtil_DelFile_ADDR (0x00431C10)
#define stdFileUtil_Deltree_ADDR (0x00431C20)

typedef struct stdFileSearch
{
    int field_0;
    int isNotFirst;
    char path[128];
    union
    {
        intptr_t field_88;
        struct dirent **namelist;
    };
    int nFoundFiles;
} stdFileSearch;

typedef struct stdFileSearchResult
{
    char fpath[256];
    int field_100;
    int is_subdirectory;
    int time_write;
} stdFileSearchResult;

stdFileSearch* stdFileUtil_NewFind(const char *path, int mode, const char *pFilter);
int stdFileUtil_FindNext(stdFileSearch *ffData, stdFileSearchResult *pFileInfo);
void stdFileUtil_DisposeFind(stdFileSearch *ffData);
void stdFileUtil_FindReset(stdFileSearch *search);
int stdFileUtil_FindQuick(const char *pPath, int mode, const char *pFilter, stdFileSearchResult *pFileInfo);
int stdFileUtil_CountMatches(const char *pPath, int mode, const char *pFilter);
int stdFileUtil_FileExists(const char *pFilename);
void stdFileUtil_RmDir(const char *pDir);

int stdFileUtil_DelFile(char* pFilename);
int stdFileUtil_Deltree(const char* lpPathName);

#if defined(PLATFORM_POSIX) && !defined(WIN32)
int stdFileUtil_MkDir(char* path);
#else
//static int (*stdFileUtil_MkDir)(char* lpPathName) = (void*)stdFileUtil_MkDir_ADDR;
BOOL stdFileUtil_MkDir(LPCSTR lpPathName);
#endif

//static stdFileSearch* (*stdFileUtil_NewFind)(char *path, int a2, char *extension) = (void*)stdFileUtil_NewFind_ADDR;
//static int (*stdFileUtil_FindNext)(stdFileSearch *a1, stdFileSearchResult *a2) = (void*)stdFileUtil_FindNext_ADDR;
//static void (*stdFileUtil_DisposeFind)(stdFileSearch *a1) = (void*)stdFileUtil_DisposeFind_ADDR;

#ifdef __cplusplus
}
#endif

#endif // _STDFILEUTIL_H
