Skip to content

Commit

Permalink
fix #5 :can't mount path with Chinese charactors
Browse files Browse the repository at this point in the history
use box command param "-c" to transfer command for mount
  • Loading branch information
xsro committed Oct 2, 2020
1 parent e2e1148 commit f2539e6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion i18n/chs/out/runcode.i18n.json
Original file line number Diff line number Diff line change
@@ -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}"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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位",
Expand Down
5 changes: 4 additions & 1 deletion scripts/boxasm.bat
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 15 additions & 7 deletions src/DOSBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,34 @@ 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' });
}
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' });
Expand Down
7 changes: 1 addition & 6 deletions src/configration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f2539e6

Please sign in to comment.