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

Log a file "create" error if process_edited_file() returns a negative value

I discovered that sbbs_t::editfile() (exposed as JS console.editfile) just
silently failed if it couldn't write to the destination file
(e.g. permission denied by OS).
parent 6ba59a06
Branches
Tags
No related merge requests found
...@@ -255,6 +255,7 @@ int sbbs_t::process_edited_file(const char* src, const char* dest, int mode, uns ...@@ -255,6 +255,7 @@ int sbbs_t::process_edited_file(const char* src, const char* dest, int mode, uns
return -4; return -4;
} }
len = -5;
if((fp=fopen(dest,"wb"))!=NULL) { if((fp=fopen(dest,"wb"))!=NULL) {
len=process_edited_text(buf, fp, mode, lines, maxlines); len=process_edited_text(buf, fp, mode, lines, maxlines);
fclose(fp); fclose(fp);
...@@ -1303,7 +1304,8 @@ bool sbbs_t::editfile(char *fname, uint maxlines, const char* to, const char* fr ...@@ -1303,7 +1304,8 @@ bool sbbs_t::editfile(char *fname, uint maxlines, const char* to, const char* fr
SAFEPRINTF3(str,"created or edited file: %s (%ld bytes, %u lines)" SAFEPRINTF3(str,"created or edited file: %s (%ld bytes, %u lines)"
,path, l, lines); ,path, l, lines);
logline(LOG_NOTICE,nulstr,str); logline(LOG_NOTICE,nulstr,str);
} } else if (l < 0)
errormsg(WHERE, ERR_CREATE, path, l);
rioctl(IOSM|PAUSE|ABORT); rioctl(IOSM|PAUSE|ABORT);
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment