Commit 4d34cf63 authored by rswindell's avatar rswindell
Browse files

Re-use text.dat entry NoErrorLogExists for reporting DirectoryDoesNotExist and

changed FileNotThere text.dat entry to FileDoesNotExist which displays the file
path.
Now check if the directory exists before checking the available disk space
before allowing file uploads and report the correct error (using
DirectoryDoesNotExist) if the directory is missing (a common mistake).
Overhaul viewfilecontents() - wow, I can't wait to re-write all of this moldy
filebase code!
parent 73fa5016
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -274,7 +274,7 @@ int sbbs_t::exec_function(csi_t *csi)
if(!noyes(text[DeleteErrorLogQ]))
remove(str); }
else
bputs(text[NoErrorLogExists]);
bprintf(text[FileDoesNotExist],str);
for(i=1;i<=cfg.sys_nodes;i++) {
getnodedat(i,&node,0);
if(node.errors)
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -1067,7 +1067,7 @@ int sbbs_t::listfileinfo(uint dirnum, char *filespec, long mode)
case 'F': /* delete file only */
sprintf(str,"%s%s",dirpath,fname);
if(!fexistcase(str))
bputs(text[FileNotThere]);
bprintf(text[FileDoesNotExist],str);
else {
if(!noyes(text[AreYouSureQ])) {
if(remove(str))
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -202,7 +202,7 @@ enum {
,Unused156
,ErrorLogHdr
,DeleteErrorLogQ
,NoErrorLogExists
,DirectoryDoesNotExist
,ClearErrCounter
,InvalidNode
,SendingTelegramToUser
......@@ -286,7 +286,7 @@ enum {
,CloseFileRecordQ
,SysopRemoveFilePrompt
,UserRemoveFilePrompt
,FileNotThere
,FileDoesNotExist
,CouldntRemoveFile
,DeleteFileQ
,AddToOfflineDirQ
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -105,6 +105,12 @@ void sbbs_t::temp_xfer()
logch(ch,0);
switch(ch) {
case 'A': /* add to temp file */
if(!isdir(cfg.temp_dir)) {
bprintf(text[DirectoryDoesNotExist], cfg.temp_dir);
SAFEPRINTF(str,"Temp directory does not exist: %s", cfg.temp_dir);
errorlog(str);
break;
}
/* free disk space */
space=getfreediskspace(cfg.temp_dir,1024);
if(space<(ulong)cfg.min_dspace) {
......@@ -283,6 +289,13 @@ void sbbs_t::extract(uint dirnum)
if(!strcmp(cfg.dir[dirnum]->code,"TEMP"))
intmp=1;
if(!isdir(cfg.temp_dir)) {
bprintf(text[DirectoryDoesNotExist], cfg.temp_dir);
SAFEPRINTF(str,"Temp directory does not exist: %s", cfg.temp_dir);
errorlog(str);
return;
}
/* get free disk space */
space=getfreediskspace(cfg.temp_dir,1024);
if(space<(ulong)cfg.min_dspace) {
......@@ -367,8 +380,9 @@ void sbbs_t::extract(uint dirnum)
SAFECOPY(temp_uler,f.uler);
SAFECOPY(temp_file,f.name); } /* padded filename */
if(!fexistcase(path)) {
bputs(text[FileNotThere]); /* not on disk */
return; }
bprintf(text[FileDoesNotExist],path); /* not on disk */
return;
}
done=0;
while(online && !done) {
mnemonics(text[ExtractFilesPrompt]);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -283,6 +283,12 @@ bool sbbs_t::upload(uint dirnum)
else
strcpy(path,cfg.dir[dirnum]->path);
if(!isdir(path)) {
bprintf(text[DirectoryDoesNotExist], path);
SAFEPRINTF(str,"File directory does not exist: %s", path);
errorlog(str);
return(false);
}
/* get free disk space */
space=getfreediskspace(path,1024);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -110,28 +110,31 @@ void sbbs_t::viewfiles(uint dirnum, char *fspec)
/****************************************************************************/
void sbbs_t::viewfilecontents(file_t* f)
{
char str[128],cmd[128];
char tmp[512];
char cmd[128];
char path[MAX_PATH+1];
char* ext;
int i;
if(f->size<=0L) {
bputs(text[FileNotThere]);
return; }
getfilepath(&cfg, f, path);
sprintf(str,"%s%s",f->altpath > 0 && f->altpath<=cfg.altpaths
? cfg.altpath[f->altpath-1] : cfg.dir[f->dir]->path
,unpadfname(f->name,tmp));
strcpy(tmp,f->name);
truncsp(tmp);
for(i=0;i<cfg.total_fviews;i++) {
if(!stricmp(tmp+9,cfg.fview[i]->ext)
&& chk_ar(cfg.fview[i]->ar,&useron)) {
strcpy(cmd,cfg.fview[i]->cmd);
break; } }
if(i==cfg.total_fviews)
bprintf(text[NonviewableFile],tmp+9);
if(f->size<=0L) {
bprintf(text[FileDoesNotExist],path);
return;
}
if((ext=getfext(path))!=NULL) {
ext++;
for(i=0;i<cfg.total_fviews;i++) {
if(!stricmp(ext,cfg.fview[i]->ext)
&& chk_ar(cfg.fview[i]->ar,&useron)) {
strcpy(cmd,cfg.fview[i]->cmd);
break;
}
}
}
if(ext==NULL || i==cfg.total_fviews)
bprintf(text[NonviewableFile],ext);
else
if((i=external(cmdstr(cmd,str,str,NULL)
if((i=external(cmdstr(cmd,path,path,NULL)
,EX_OUTL|EX_OUTR|EX_INR))!=0)
errormsg(WHERE,ERR_EXEC,cmdstr(cmd,str,str,NULL),i);
errormsg(WHERE,ERR_EXEC,cmdstr(cmd,path,path,NULL),i);
}
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