Skip to content

Commit 052ab7a

Browse files
committed
improve the process for deleting old files
1 parent 68ccf15 commit 052ab7a

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/configration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface ToolInfo {
1212
export const inArrays = (data: [string, FileType][], arr: [string, FileType]) => {
1313
let ignoreCase = process.platform === "win32";
1414
if (ignoreCase) {
15-
return data.some(e => e[0].toLowerCase() === arr[0] && e[1] === arr[1]);
15+
return data.some(e => e[0].toLowerCase() === arr[0].toLowerCase() && e[1] === arr[1]);
1616
}
1717
else {
1818
return data.some(e => e.every((o, i) => Object.is(arr[i], o)));

src/runcode.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export class AsmAction {
2222
private Openemu(doc: TextDocument) {
2323
let openemumsg = localize("openemu.msg", "\nMASM/TASM>>Open DOSBox:{0}", doc.fileName);
2424
this.extOutChannel.appendLine(openemumsg);
25-
DOSBox.runDosbox(this._config, undefined, doc);
25+
CleanCopy(doc.uri, this._config.workUri);
26+
DOSBox.runDosbox(this._config);
2627
}
2728
public async RunDebug(doc: TextDocument, runOrDebug: boolean) {
2829
await CleanCopy(doc.uri, this._config.workUri);
@@ -100,14 +101,32 @@ export class AsmAction {
100101
}
101102
}
102103
}
104+
const delList = [
105+
"T.exe",
106+
"T.map",
107+
"T.obj",
108+
"T.TXT",
109+
"T.TR",
110+
"TDCONFIG.TD"
111+
];
103112
async function CleanCopy(file: Uri, dir: Uri) {
104113
let fs = workspace.fs;
105114
let dirInfo = await fs.readDirectory(dir);
106-
if (inArrays(dirInfo, ["T.OBJ", FileType.File])) {
107-
await fs.delete(Uri.joinPath(dir, "./T.OBJ"), { recursive: false, useTrash: false });
108-
}
109-
if (inArrays(dirInfo, ["T.EXE", FileType.File])) {
110-
await fs.delete(Uri.joinPath(dir, "./T.EXE"), { recursive: false, useTrash: false });
111-
}
115+
//delete files to avoid this files confusing the codes
116+
delList.forEach(
117+
async (value) => {
118+
if (inArrays(dirInfo, [value, FileType.File])) {
119+
await fs.delete(Uri.joinPath(dir, value), { recursive: false, useTrash: false });
120+
}
121+
}
122+
)
112123
fs.copy(file, Uri.joinPath(dir, "./T.ASM"), { overwrite: true });
124+
}
125+
const foudFile = (data: [string, FileType][], arr: [string, FileType], ignoreCases: boolean) => {
126+
for (let i = 0; i < data.length; i++) {
127+
if (arr === data[i]) {
128+
return data[i];
129+
break;
130+
}
131+
}
113132
}

0 commit comments

Comments
 (0)