From f2539e6444c92fdeb8fed1412758622e49d077f6 Mon Sep 17 00:00:00 2001 From: "lc@kun'sASUS" Date: Fri, 2 Oct 2020 23:04:10 +0800 Subject: [PATCH] fix #5 :can't mount path with Chinese charactors use box command param "-c" to transfer command for mount --- CHANGELOG.md | 2 +- i18n/chs/out/runcode.i18n.json | 2 +- package.json | 2 +- scripts/boxasm.bat | 5 ++++- src/DOSBox.ts | 22 +++++++++++++++------- src/configration.ts | 7 +------ 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a71795..a30f04b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### 0.3.1 - [x] dosbox更新到0.74-3 -- [ ] 修复中文用户名下无法工作的问题[#5](https://github.com/xsro/masm-tasm/issues/5) +- [x] 修复Dosbox无法挂载带有中文的路径的问题[#5](https://github.com/xsro/masm-tasm/issues/5) ### 0.3.0 diff --git a/i18n/chs/out/runcode.i18n.json b/i18n/chs/out/runcode.i18n.json index 695f7cf..111f20d 100644 --- a/i18n/chs/out/runcode.i18n.json +++ b/i18n/chs/out/runcode.i18n.json @@ -1,5 +1,5 @@ { - "openemu.msg": "MASM/TASM>>打开DOSBox:{0}", + "openemu.msg": "\nMASM/TASM>>打开DOSBox:{0}", "run.msg": "\n{0}({1})>>运行:{2}", "debug.msg": "\n{0}({1})>>调试:{2}" } \ No newline at end of file diff --git a/package.json b/package.json index 256ce72..753b63a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "MASM/TASM", "publisher": "xsro", "description": "DOS汇编语言开发环境和语法支持,win下安装即用,自带DOSBox.exe和TASM/MASM工具", - "version": "0.3.1-beta.2", + "version": "0.3.1", "keywords": [ "dosbox", "16位", diff --git a/scripts/boxasm.bat b/scripts/boxasm.bat index 0a4ccc4..c07144c 100644 --- a/scripts/boxasm.bat +++ b/scripts/boxasm.bat @@ -1,4 +1,6 @@ +::this batch file will be used in dosbox by vscode extension @echo off + if exist T.exe del T.exe if exist T.OBJ del T.OBJ if "%1"=="MASM" goto MASM @@ -35,7 +37,8 @@ exit :run T.EXE echo (END) -echo The symbol "(END)" means there is the END of your program +echo ---------------------------------------------------------- +echo The symbol "(END)" means there is the END of your program's output if "%3"=="p" pause if "%3"=="k" goto end exit diff --git a/src/DOSBox.ts b/src/DOSBox.ts index a4a4437..8b9f4c6 100644 --- a/src/DOSBox.ts +++ b/src/DOSBox.ts @@ -15,12 +15,21 @@ export class DOSBox { * @param diag 如果有则诊断输出信息 */ public openDOSBox(conf: Config, more?: string, doc?: TextDocument, diag?: AssemblerDiag) { - let boxcommand = ' '; - if (more) { - let boxparam = more.replace(/\n/g, '"-c "'); - boxcommand = '-c "' + boxparam + '"'; - } + let boxcmd: string = '@echo off\n'; + //mount the necessary path + boxcmd += `mount c \\\"${conf.path}\\\"\nmount d \\\"${conf.workpath}\\\"\nmount x \\\"${conf.batchpath}\\\"\n`; + //switch to the working space and add path\ + boxcmd += "d:\nset PATH=%%PATH%%;c:\\tasm;c:\\masm\n"; + if (doc) { boxcmd += "echo Your file has been copied as D:\\T.ASM\n"; }; + boxcmd += "@echo on"; + //add extra commands + if (more) { boxcmd += "\n" + more; } + //change string to needed form as dosbox parameter + boxcmd = boxcmd.replace(/\n/g, '" -c "'); + let boxcommand = '-c "' + boxcmd + '"'; + //command for open dosbox let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" '; + //exec command by terminal if (process.platform === 'win32') { if (doc) { command = 'del/Q T*.* & copy "' + doc.fileName + '" "T.ASM" & ' + command; } execSync(command + boxcommand, { cwd: conf.workpath, shell: 'cmd.exe' }); @@ -28,13 +37,12 @@ export class DOSBox { else { if (doc) { command = 'rm -f [Tt]*.*;cp "' + doc.fileName + '" T.ASM;' + command; } execSync(command + boxcommand, { cwd: conf.workpath }); - } if (diag && doc) { this.BOXdiag(conf, diag, doc); } } public BoxOpenCurrentFolder(conf: Config, doc: TextDocument) { let folderpath: string = Uri.joinPath(doc.uri, '../').fsPath; - let Ecmd: string = '-noautoexec -c "mount e \\\"' + folderpath + '\\\"" -c "mount c \\\"' + conf.path + '\\\"" -c "set PATH=%%PATH%%;c:\masm;c:\\tasm"-c "e:"'; + let Ecmd: string = '-noautoexec -c "mount e \\\"' + folderpath + '\\\"" -c "mount c \\\"' + conf.path + '\\\"" -c "set PATH=%%PATH%%;c:\\masm;c:\\tasm" -c "e:"'; let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" '; if (process.platform === 'win32') { execSync(command + Ecmd, { cwd: conf.workpath, shell: 'cmd.exe' }); diff --git a/src/configration.ts b/src/configration.ts index 0257554..bf7cbf5 100644 --- a/src/configration.ts +++ b/src/configration.ts @@ -144,12 +144,7 @@ export class Config { let configContent = `[sdl] windowresolution=${conf.resolution} output=opengl -[autoexec] -mount c "${conf.path}" -mount d "${conf.workpath}" -mount x "${conf.batchpath}" -d: -set PATH=%PATH%;c:\\tasm;c:\\masm`; +`; if (autoExec) { configContent = configContent + '\n' + autoExec; } this.writefile(configUri, configContent); }