Skip to content
Snippets Groups Projects
Commit 35f6f081 authored by deuce's avatar deuce
Browse files

Add removecase() function/macro which deletes the filename in all cases

that exist.  Fix to delfiles() to delete from cwd if inpath is a zero-length
string.
parent bd21c171
No related branches found
No related tags found
No related merge requests found
......@@ -573,6 +573,33 @@ BOOL DLLCALL fexistcase(char *path)
#endif
}
#ifndef _WIN32
int removecase(char *path)
{
char inpath[MAX_PATH+1];
char fname[MAX_PATH*4+1];
char tmp[5];
char *p;
int i;
SAFECOPY(inpath,path);
p=getfname(inpath);
SAFECOPY(fname,p);
*p=0;
fname[0]=0;
p++;
for(;*p;p++) {
if(isalpha(*p))
sprintf(tmp,"[%c%c]",toupper(*p),tolower(*p));
else
sprintf(tmp,"%c",*p);
strncat(fname,tmp,MAX_PATH*4);
}
return(delfiles(inpath,fname)?-1:0);
}
#endif
#if !defined(S_ISDIR)
#define S_ISDIR(x) ((x)&S_IFDIR)
#endif
......@@ -644,7 +671,7 @@ ulong DLLCALL delfiles(char *inpath, char *spec)
glob_t g;
lastch=*lastchar(inpath);
if(!IS_PATH_DELIM(lastch))
if(!IS_PATH_DELIM(lastch) && lastch)
sprintf(path,"%s%c",inpath,PATH_DELIM);
else
strcpy(path,inpath);
......
......@@ -240,6 +240,9 @@ DLLEXPORT int DLLCALL mkdirs(const char* path);
DLLEXPORT void DLLCALL _splitpath(const char *path, char *drive, char *dir,
char *fname, char *ext);
DLLEXPORT char * DLLCALL _fullpath(char *target, const char *path, size_t size);
DLLEXPORT int DLLCALL removecase(char *path);
#else
#define removecase(x) remove(x)
#endif
#if defined(__cplusplus)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment