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

Simplify the file remove/delete logic here.

parent 90bf6cd5
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2209 passed
...@@ -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)) {
errormsg(WHERE, ERR_REMOVE, f->name);
break;
}
getfilepath(&cfg, f, path); getfilepath(&cfg, f, path);
if(fexistcase(path)) { if(fexistcase(path)) {
if(dir_op(dirnum)) { if(dir_op(dirnum) && noyes(text[DeleteFileQ]))
if(!noyes(text[DeleteFileQ])) { break;
if(remove(path) != 0) if(remove(path) != 0) {
errormsg(WHERE, ERR_REMOVE, path);
else {
SAFEPRINTF(tmp, "deleted %s", path);
logline(nulstr,path);
}
}
}
else if(remove(path)) /* always remove if not sysop */
bprintf(text[CouldntRemoveFile], path); bprintf(text[CouldntRemoveFile], path);
errormsg(WHERE, ERR_REMOVE, path);
break;
} }
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.
Please register or to comment