Skip to content

Commit f2539e6

Browse files
committed
fix #5 :can't mount path with Chinese charactors
use box command param "-c" to transfer command for mount
1 parent e2e1148 commit f2539e6

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### 0.3.1
66

77
- [x] dosbox更新到0.74-3
8-
- [ ] 修复中文用户名下无法工作的问题[#5](https://github.com/xsro/masm-tasm/issues/5)
8+
- [x] 修复Dosbox无法挂载带有中文的路径的问题[#5](https://github.com/xsro/masm-tasm/issues/5)
99

1010
### 0.3.0
1111

i18n/chs/out/runcode.i18n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"openemu.msg": "MASM/TASM>>打开DOSBox:{0}",
2+
"openemu.msg": "\nMASM/TASM>>打开DOSBox:{0}",
33
"run.msg": "\n{0}({1})>>运行:{2}",
44
"debug.msg": "\n{0}({1})>>调试:{2}"
55
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "MASM/TASM",
44
"publisher": "xsro",
55
"description": "DOS汇编语言开发环境和语法支持,win下安装即用,自带DOSBox.exe和TASM/MASM工具",
6-
"version": "0.3.1-beta.2",
6+
"version": "0.3.1",
77
"keywords": [
88
"dosbox",
99
"16位",

scripts/boxasm.bat

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
::this batch file will be used in dosbox by vscode extension
12
@echo off
3+
24
if exist T.exe del T.exe
35
if exist T.OBJ del T.OBJ
46
if "%1"=="MASM" goto MASM
@@ -35,7 +37,8 @@ exit
3537
:run
3638
T.EXE
3739
echo (END)
38-
echo The symbol "(END)" means there is the END of your program
40+
echo ----------------------------------------------------------
41+
echo The symbol "(END)" means there is the END of your program's output
3942
if "%3"=="p" pause
4043
if "%3"=="k" goto end
4144
exit

src/DOSBox.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,34 @@ export class DOSBox {
1515
* @param diag 如果有则诊断输出信息
1616
*/
1717
public openDOSBox(conf: Config, more?: string, doc?: TextDocument, diag?: AssemblerDiag) {
18-
let boxcommand = ' ';
19-
if (more) {
20-
let boxparam = more.replace(/\n/g, '"-c "');
21-
boxcommand = '-c "' + boxparam + '"';
22-
}
18+
let boxcmd: string = '@echo off\n';
19+
//mount the necessary path
20+
boxcmd += `mount c \\\"${conf.path}\\\"\nmount d \\\"${conf.workpath}\\\"\nmount x \\\"${conf.batchpath}\\\"\n`;
21+
//switch to the working space and add path\
22+
boxcmd += "d:\nset PATH=%%PATH%%;c:\\tasm;c:\\masm\n";
23+
if (doc) { boxcmd += "echo Your file has been copied as D:\\T.ASM\n"; };
24+
boxcmd += "@echo on";
25+
//add extra commands
26+
if (more) { boxcmd += "\n" + more; }
27+
//change string to needed form as dosbox parameter
28+
boxcmd = boxcmd.replace(/\n/g, '" -c "');
29+
let boxcommand = '-c "' + boxcmd + '"';
30+
//command for open dosbox
2331
let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" ';
32+
//exec command by terminal
2433
if (process.platform === 'win32') {
2534
if (doc) { command = 'del/Q T*.* & copy "' + doc.fileName + '" "T.ASM" & ' + command; }
2635
execSync(command + boxcommand, { cwd: conf.workpath, shell: 'cmd.exe' });
2736
}
2837
else {
2938
if (doc) { command = 'rm -f [Tt]*.*;cp "' + doc.fileName + '" T.ASM;' + command; }
3039
execSync(command + boxcommand, { cwd: conf.workpath });
31-
3240
}
3341
if (diag && doc) { this.BOXdiag(conf, diag, doc); }
3442
}
3543
public BoxOpenCurrentFolder(conf: Config, doc: TextDocument) {
3644
let folderpath: string = Uri.joinPath(doc.uri, '../').fsPath;
37-
let Ecmd: string = '-noautoexec -c "mount e \\\"' + folderpath + '\\\"" -c "mount c \\\"' + conf.path + '\\\"" -c "set PATH=%%PATH%%;c:\masm;c:\\tasm"-c "e:"';
45+
let Ecmd: string = '-noautoexec -c "mount e \\\"' + folderpath + '\\\"" -c "mount c \\\"' + conf.path + '\\\"" -c "set PATH=%%PATH%%;c:\\masm;c:\\tasm" -c "e:"';
3846
let command = conf.OpenDosbox + ' -conf "' + conf.dosboxconfuri.fsPath + '" ';
3947
if (process.platform === 'win32') {
4048
execSync(command + Ecmd, { cwd: conf.workpath, shell: 'cmd.exe' });

src/configration.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,7 @@ export class Config {
144144
let configContent = `[sdl]
145145
windowresolution=${conf.resolution}
146146
output=opengl
147-
[autoexec]
148-
mount c "${conf.path}"
149-
mount d "${conf.workpath}"
150-
mount x "${conf.batchpath}"
151-
d:
152-
set PATH=%PATH%;c:\\tasm;c:\\masm`;
147+
`;
153148
if (autoExec) { configContent = configContent + '\n' + autoExec; }
154149
this.writefile(configUri, configContent);
155150
}

0 commit comments

Comments
 (0)