From ce21c1e9361e04391dc41463af24d5eb0c493bd1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 8 Feb 2020 00:31:56 +0100 Subject: Add is_file() function --- src/common/utils.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/common/utils.h') diff --git a/src/common/utils.h b/src/common/utils.h index a0590db7f..b160d3651 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -40,6 +40,7 @@ void WriteDump(FILE* fp, const void* buffer, size_t length); void ShowDump(const void* buffer, size_t length); void findfile(const char *p, const char *pat, void (func)(const char *, void *), void *context); +bool is_file(const char *path); bool exists(const char* filename); /// calculates the value of A / B, in percent (rounded down) -- cgit v1.2.3-70-g09d2 From 01e854b8d27e22c5dc7fb35726ec8579e7120eeb Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 8 Feb 2020 00:34:29 +0100 Subject: Define MAX_DIR_PATH for WIN32, too --- src/common/utils.c | 6 ++---- src/common/utils.h | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/common/utils.h') diff --git a/src/common/utils.c b/src/common/utils.c index 12810dd09..084080df7 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -132,7 +132,7 @@ void findfile(const char *p, const char *pat, void (func)(const char *, void *co { WIN32_FIND_DATAA FindFileData; HANDLE hFind; - char tmppath[MAX_PATH+1]; + char tmppath[MAX_DIR_PATH + 1]; const char *path = (p ==NULL)? "." : p; const char *pattern = (pat==NULL)? "" : pat; @@ -178,7 +178,7 @@ bool is_file(const char *path) { nullpo_retr(false, path); - char path_tmp[MAX_PATH + 1]; + char path_tmp[MAX_DIR_PATH + 1]; checkpath(path_tmp, path); @@ -187,8 +187,6 @@ bool is_file(const char *path) #else -#define MAX_DIR_PATH 2048 - static char *checkpath(char *path, const char *srcpath) { // just make sure the char*path is not const diff --git a/src/common/utils.h b/src/common/utils.h index b160d3651..3e0d73e40 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -31,6 +31,14 @@ /* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ #define HCACHE_KEY 'k' +#ifndef MAX_DIR_PATH +#ifdef WIN32 +#define MAX_DIR_PATH MAX_PATH +#else +#define MAX_DIR_PATH 2048 +#endif +#endif + //Caps values to min/max #define cap_value(a, min, max) (((a) >= (max)) ? (max) : ((a) <= (min)) ? (min) : (a)) -- cgit v1.2.3-70-g09d2