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

Simplify the file remove/delete logic here.

parent 28142d9b
No related branches found
No related tags found
No related merge requests found
...@@ -844,39 +844,36 @@ int sbbs_t::listfileinfo(uint dirnum, const char *filespec, long mode) ...@@ -844,39 +844,36 @@ int sbbs_t::listfileinfo(uint dirnum, const char *filespec, long mode)
editfileinfo(f); editfileinfo(f);
break; break;
case 'F': /* delete file only */ case 'F': /* delete file only */
SAFEPRINTF2(str,"%s%s",dirpath,f->name); getfilepath(&cfg, f, path);
if(!fexistcase(str)) if(!fexistcase(path))
bprintf(text[FileDoesNotExist],str); bprintf(text[FileDoesNotExist], path);
else { else {
if(!noyes(text[DeleteFileQ])) { if(!noyes(text[DeleteFileQ])) {
if(remove(str)) if(remove(path) != 0) {
bprintf(text[CouldntRemoveFile],str); bprintf(text[CouldntRemoveFile], path);
else { errormsg(WHERE, ERR_REMOVE, path);
SAFEPRINTF(tmp, "deleted %s", str); } else
logline(nulstr, tmp); lprintf(LOG_NOTICE, "deleted %s", path);
}
} }
} }
break; break;
case 'R': /* remove file from database */ case 'R': /* remove file from database */
if(noyes(text[RemoveFileQ])) if(noyes(text[RemoveFileQ]))
break; break;
if(removefile(&smb, f)) { if(!removefile(&smb, f)) {
getfilepath(&cfg, f, path); errormsg(WHERE, ERR_REMOVE, f->name);
if(fexistcase(path)) { break;
if(dir_op(dirnum)) { }
if(!noyes(text[DeleteFileQ])) { getfilepath(&cfg, f, path);
if(remove(path) != 0) if(fexistcase(path)) {
errormsg(WHERE, ERR_REMOVE, path); if(dir_op(dirnum) && noyes(text[DeleteFileQ]))
else { break;
SAFEPRINTF(tmp, "deleted %s", path); if(remove(path) != 0) {
logline(nulstr,path); bprintf(text[CouldntRemoveFile], path);
} errormsg(WHERE, ERR_REMOVE, path);
} break;
}
else if(remove(path)) /* always remove if not sysop */
bprintf(text[CouldntRemoveFile],path);
} }
lprintf(LOG_NOTICE, "deleted %s", path);
} }
if(dir_op(dirnum) || useron.exempt&FLAG('R')) { if(dir_op(dirnum) || useron.exempt&FLAG('R')) {
i=cfg.lib[cfg.dir[f->dir]->lib]->offline_dir; i=cfg.lib[cfg.dir[f->dir]->lib]->offline_dir;
......
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