@@ -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' } ) ;
0 commit comments