Fix issue introduced handling files in subdirectories ._.

This commit is contained in:
Nicholas Colclasure 2021-12-19 13:03:50 -08:00
parent 8ba5199e54
commit 61dde4cfac
2 changed files with 4 additions and 3 deletions

@ -185,7 +185,7 @@ export function getDestinationFilepath(destination: string, source: string, cwd:
return destination; return destination;
} else { } else {
// Append the filename to the directory provided. // Append the filename to the directory provided.
let t_path = removeTrailingSlash(dstDir); const t_path = removeTrailingSlash(dstDir);
const fileName = getFileName(source); const fileName = getFileName(source);
return t_path + "/" + fileName; return t_path + "/" + fileName;
} }

@ -16,7 +16,8 @@ export function cat(
terminal.error("Incorrect usage of cat command. Usage: cat [file]"); terminal.error("Incorrect usage of cat command. Usage: cat [file]");
return; return;
} }
const filename = terminal.getFilepath(args[0] + ""); const relative_filename = args[0] + "";
const filename = terminal.getFilepath(relative_filename);
if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) { if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) {
terminal.error( terminal.error(
"Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)", "Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)",
@ -39,7 +40,7 @@ export function cat(
} }
} }
} else if (filename.endsWith(".txt")) { } else if (filename.endsWith(".txt")) {
const txt = terminal.getTextFile(player, "/" + filename); const txt = terminal.getTextFile(player, relative_filename);
if (txt != null) { if (txt != null) {
txt.show(); txt.show();
return; return;