Deleting a file without ext print a normal error msg.

This commit is contained in:
Olivier Gagnon 2021-05-17 18:09:47 -04:00
parent b9c292f7cf
commit afc1347d3a
3 changed files with 12 additions and 2 deletions

@ -258,5 +258,6 @@ export const CONSTANTS: IMap<any> = {
* Fix some ram not displayed as 0.00GB
* Fix error message throw undefined variable error
* City hall now has some generic text if you can't create a corp yet.
* Deleting a file without extension now returns an appropriate error message.
`,
}

@ -181,6 +181,7 @@ export class BaseServer {
* @returns {IReturnStatus} Return status object indicating whether or not file was deleted
*/
removeFile(fn: string): IReturnStatus {
console.log(`removing ${fn}`);
if (fn.endsWith(".exe") || fn.match(/^.+\.exe-\d+(?:\.\d*)?%-INC$/) != null) {
for (let i = 0; i < this.programs.length; ++i) {
if (this.programs[i] === fn) {

@ -1313,9 +1313,17 @@ let Terminal = {
}
// Check programs
let delTarget = Terminal.getFilepath(commandArray[1]);
let delTarget, status;
try {
delTarget = Terminal.getFilepath(commandArray[1]);
status = s.removeFile(delTarget);
} catch(err) {
status = {
res: false,
msg: 'No such file exists'
};
}
const status = s.removeFile(delTarget);
if (!status.res) {
postError(status.msg);
}