Skip to content
Snippets Groups Projects
Commit bd1e74b8 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add getdircase() - like fexistcase(), but for sub-directory names

parent b1ce58ad
Branches
Tags
1 merge request!455Update branch with changes from master
......@@ -577,9 +577,9 @@ bool fexist(const char *filespec)
}
/****************************************************************************/
/* Fixes upper/lowercase filename for Unix file systems */
/* Fixes upper/lowercase filename or dirname for Unix file systems */
/****************************************************************************/
bool fexistcase(char *path)
static bool getfilecase(char *path, bool dir)
{
#if defined(_WIN32)
......@@ -595,7 +595,7 @@ bool fexistcase(char *path)
_findclose(handle);
if(f.attrib&_A_SUBDIR)
if(INT_TO_BOOL(f.attrib&_A_SUBDIR) != dir)
return(false);
fname=getfname(path); /* Find filename in path */
......@@ -636,7 +636,7 @@ bool fexistcase(char *path)
}
#endif
if(glob(globme,GLOB_MARK,NULL,&glb) != 0)
if(glob(globme, dir ? GLOB_ONLYDIR : GLOB_MARK, NULL, &glb) != 0)
return(false);
if(glb.gl_pathc>0) {
......@@ -657,6 +657,16 @@ bool fexistcase(char *path)
#endif
}
bool fexistcase(char *path)
{
return getfilecase(path, false);
}
bool getdircase(char* path)
{
return getfilecase(path, true);
}
/****************************************************************************/
/* Returns true if the filename specified is a directory */
/****************************************************************************/
......
......@@ -219,6 +219,7 @@ DLLEXPORT char* getfext(const char* path);
DLLEXPORT int getfattr(const char* filename);
DLLEXPORT int getfmode(const char* filename);
DLLEXPORT uint getfilecount(const char *path);
DLLEXPORT bool getdircase(char* path);
DLLEXPORT char* getdirname(const char* path);
DLLEXPORT size_t getdirsize(const char* path, bool include_subdirs, bool subdir_only);
DLLEXPORT uint64_t getdisksize(const char* path, uint64_t unit);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment