Commit e33a88fe authored by rswindell's avatar rswindell
Browse files

Created fexistcase() function that checks for file existence, like fexist(),

but fixes filenames for all upper/lower DOS filename compatibility.
parent 1556aa0b
......@@ -72,7 +72,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
delfiles(cfg.temp_dir,ALLFILES);
sprintf(str,"%sfile/%04u.qwk",cfg.data_dir,useron.number);
if(fexist(str)) {
if(fexistcase(str)) {
for(k=0;k<cfg.total_fextrs;k++)
if(!stricmp(cfg.fextr[k]->ext,useron.tmpext)
&& chk_ar(cfg.fextr[k]->ar,&useron))
......
......@@ -550,7 +550,7 @@ void sbbs_t::qwk_sec()
if(ch=='B') { /* Bidirectional QWK and REP packet transfer */
sprintf(str,"%s%s.qwk",cfg.temp_dir,cfg.sys_id);
if(!fexist(str) && !pack_qwk(str,&msgcnt,0)) {
if(!fexistcase(str) && !pack_qwk(str,&msgcnt,0)) {
for(i=0;i<cfg.total_subs;i++)
subscan[i].ptr=sav_ptr[i];
remove(str);
......
......@@ -64,7 +64,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
return(false);
}
sprintf(str,"%sMESSAGES.DAT",cfg.temp_dir);
if(!fexist(str)) {
if(!fexistcase(str)) {
sprintf(str,"%s doesn't contain MESSAGES.DAT",packet);
errorlog(str);
return(false);
......
......@@ -83,7 +83,7 @@ bool sbbs_t::unpack_rep(char* repfile)
return(false);
}
sprintf(str,"%s%s.msg",cfg.temp_dir,cfg.sys_id);
if(!fexist(str)) {
if(!fexistcase(str)) {
bputs(text[QWKReplyNotReceived]);
logline("U!",AttemptedToUploadREPpacket);
logline(nulstr,"MSG file not received");
......@@ -407,9 +407,11 @@ bool sbbs_t::unpack_rep(char* repfile)
if(useron.rest&FLAG('Q')) { /* QWK Net Node */
sprintf(str,"%s%s.msg",cfg.temp_dir,cfg.sys_id);
remove(str);
if(fexistcase(str))
remove(str);
sprintf(str,"%s%s.rep",cfg.temp_dir,cfg.sys_id);
remove(str);
if(fexistcase(str))
remove(str);
dir=opendir(cfg.temp_dir);
while(dir!=NULL && (dirent=readdir(dir))!=NULL) { /* Extra files */
......
......@@ -143,12 +143,16 @@ bool sbbs_t::uploadfile(file_t *f)
break;
if(i<cfg.total_fextrs) {
sprintf(str,"%sFILE_ID.DIZ",cfg.temp_dir);
remove(str);
if(fexistcase(str))
remove(str);
external(cmdstr(cfg.fextr[i]->cmd,path,"FILE_ID.DIZ",NULL),EX_OUTL);
if(!fexist(str)) {
if(!fexistcase(str)) {
sprintf(str,"%sDESC.SDI",cfg.temp_dir);
remove(str);
external(cmdstr(cfg.fextr[i]->cmd,path,"DESC.SDI",NULL),EX_OUTL); }
if(fexistcase(str))
remove(str);
external(cmdstr(cfg.fextr[i]->cmd,path,"DESC.SDI",NULL),EX_OUTL);
fexistcase(str);
}
if((file=nopen(str,O_RDONLY))!=-1) {
memset(ext,0,F_EXBSIZE+1);
read(file,ext,F_EXBSIZE);
......
......@@ -383,6 +383,38 @@ BOOL DLLCALL fexist(char *filespec)
#endif
}
/****************************************************************************/
/* Fixes upper/lowercase filename for Unix file systems */
/****************************************************************************/
BOOL DLLCALL fexistcase(char *path)
{
#if defined(__unix__)
char tmp[MAX_PATH+1];
if(fexist(path))
return(TRUE);
SAFECOPY(tmp,path);
/* check for uppercase filename */
strupr(getfname(tmp));
if(fexist(path)) {
strcpy(path,tmp);
return(TRUE);
}
/* check for lowercase filename */
strlwr(getfname(tmp));
if(fexist(path)) {
strcpy(path,tmp);
return(TRUE);
}
return(FALSE);
#else
return(fexist(path));
#endif
}
/****************************************************************************/
/* Returns TRUE if the filename specified is a directory */
/****************************************************************************/
......
......@@ -163,6 +163,7 @@ extern "C" {
/* General file system wrappers for all platforms and compilers */
DLLEXPORT BOOL DLLCALL fexist(char *filespec);
DLLEXPORT BOOL DLLCALL fexistcase(char *filespec); /* fixes upr/lwr case fname */
DLLEXPORT long DLLCALL flength(char *filename);
DLLEXPORT time_t DLLCALL fdate(char *filename);
DLLEXPORT BOOL DLLCALL isdir(char *filename);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment