Skip to content

Commit

Permalink
Fix adding quotes to filenames for IMGMOUNT
Browse files Browse the repository at this point in the history
  • Loading branch information
maron2000 committed Jan 25, 2025
1 parent c58e898 commit 2d7e750
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
17 changes: 6 additions & 11 deletions src/dos/dos_programs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "dosbox.h"
#include <stdlib.h>
#include <string.h>
#include <regex>
#include <ctype.h>
#include <math.h>
#include <algorithm>
Expand Down Expand Up @@ -680,21 +681,15 @@ void MenuBrowseImageFile(char drive, bool arc, bool boot, bool multiple) {
const char *lFilterPatterns[] = {"*.ima","*.img","*.vhd","*.fdi","*.hdi","*.nfd","*.nhd","*.d88","*.hdm","*.xdf","*.iso","*.cue","*.bin","*.chd","*.mdf","*.gog","*.ins","*.ccd","*.inst","*.IMA","*.IMG","*.VHD","*.FDI","*.HDI","*.NFD","*.NHD","*.D88","*.HDM","*.XDF","*.ISO","*.CUE","*.BIN","*.CHD","*.MDF","*.GOG","*.INS","*.CCD","*.INST"};
const char *lFilterDescription = "Disk/CD image files";
lTheOpenFileName = tinyfd_openFileDialog(((multiple?"Select image file(s) for Drive ":"Select an image file for Drive ")+str+":").c_str(),"", sizeof(lFilterPatterns) / sizeof(lFilterPatterns[0]),lFilterPatterns,lFilterDescription,multiple?1:0);
if (lTheOpenFileName) fname = GetNewStr(lTheOpenFileName);
if (lTheOpenFileName) fname = "\"" + GetNewStr(lTheOpenFileName) + "\"";
if (multiple&&fname.size()) {
files += "\"";
for (size_t i=0; i<fname.size(); i++)
files += fname[i]=='|'?"\" \"":std::string(1,fname[i]);
files += "\" ";
files = std::regex_replace(fname, std::regex("\\|"), "\" \"");
}
while (multiple&&lTheOpenFileName&&systemmessagebox("Mount image files","Do you want to mount more image file(s)?","yesno", "question", 1)) {
lTheOpenFileName = tinyfd_openFileDialog(("Select image file(s) for Drive "+str+":").c_str(),"", sizeof(lFilterPatterns) / sizeof(lFilterPatterns[0]),lFilterPatterns,lFilterDescription,multiple?1:0);
if (lTheOpenFileName) {
fname = GetNewStr(lTheOpenFileName);
files += "\"";
for (size_t i=0; i<fname.size(); i++)
files += fname[i]=='|'?"\" \"":std::string(1,fname[i]);
files += "\" ";
fname = "\"" + GetNewStr(lTheOpenFileName) + "\"";
files = files + " " + std::regex_replace(fname, std::regex("\\|"), "\" \"");
}
}
}
Expand Down Expand Up @@ -756,7 +751,7 @@ void MenuBrowseImageFile(char drive, bool arc, bool boot, bool multiple) {
systemmessagebox("Error",drive_warn.c_str(),"ok","error", 1);
return;
} else if (multiple) {
systemmessagebox("Information",("Mounted disk images to Drive "+std::string(1,drive)+(dos.loaded_codepage==437?":\n"+files:".")+(mountiro[drive-'A']?"\n(Read-only mode)":"")).c_str(),"ok","info", 1);
systemmessagebox("Information",("Mounted disk images to Drive "+std::string(1,drive)+(dos.loaded_codepage==437?":\n"+files:".")+(mountiro[drive-'A']?"\n(Read-only mode)":"")).c_str(),"ok","info", 1);
} else if (lTheOpenFileName) {
systemmessagebox("Information",(std::string(arc?"Mounted archive":"Mounted disk image")+" to Drive "+std::string(1,drive)+":\n"+std::string(lTheOpenFileName)+(arc||mountiro[drive-'A']?"\n(Read-only mode)":"")).c_str(),"ok","info", 1);
}
Expand Down
6 changes: 5 additions & 1 deletion src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,12 +1085,16 @@ bool warn_on_mem_write = false;

bool systemmessagebox(char const * aTitle, char const * aMessage, char const * aDialogType, char const * aIconType, int aDefaultButton) {
#if !defined(HX_DOS)
if(!aMessage) aMessage = "";
std::string lDialogString(aMessage);
std::replace(lDialogString.begin(), lDialogString.end(), '\"', ' ');

bool fs=sdl.desktop.fullscreen;
if (fs) GFX_SwitchFullScreen();
MAPPER_ReleaseAllKeys();
GFX_LosingFocus();
GFX_ReleaseMouse();
bool ret=tinyfd_messageBox(aTitle, aMessage, aDialogType, aIconType, aDefaultButton);
bool ret=tinyfd_messageBox(aTitle, lDialogString.c_str(), aDialogType, aIconType, aDefaultButton);
MAPPER_ReleaseAllKeys();
GFX_LosingFocus();
if (fs&&!sdl.desktop.fullscreen) GFX_SwitchFullScreen();
Expand Down

0 comments on commit 2d7e750

Please sign in to comment.