From 88ac8b2dd9e07b4d4ace4bdd7f3f304aa9474858 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 21 Jan 2020 09:02:06 +0000 Subject: [PATCH] Copy working directory when mounting an overlay. Add some more strings to language file. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4309 --- src/dos/dos_programs.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 5c93428d..26d5fdab 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -281,7 +281,7 @@ public: if (type == "overlay") { //Ensure that the base drive exists: if (!Drives[drive-'A']) { - WriteOut("No basedrive mounted yet!"); + WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_NO_BASE")); return; } } else if (Drives[drive-'A']) { @@ -422,7 +422,7 @@ public: localDrive* ldp = dynamic_cast(Drives[drive-'A']); cdromDrive* cdp = dynamic_cast(Drives[drive-'A']); if (!ldp || cdp) { - WriteOut("Basedrive not compatible"); + WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_INCOMPAT_BASE")); return; } std::string base = ldp->getBasedir(); @@ -431,20 +431,26 @@ public: //Erase old drive on success if (newdrive) { if (o_error) { - if (o_error == 1) WriteOut("No mixing of relative and absolute paths. Overlay failed."); - else if (o_error == 2) WriteOut("overlay directory can not be the same as underlying file system."); - else WriteOut("Something went wrong"); + if (o_error == 1) WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_MIXED_BASE")); + else if (o_error == 2) WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_SAME_AS_BASE")); + else WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_GENERIC_ERROR")); delete newdrive; return; } + + //Copy current directory if not marked as deleted. + if (newdrive->TestDir(ldp->curdir)) { + strcpy(newdrive->curdir,ldp->curdir); + } + delete Drives[drive-'A']; Drives[drive-'A'] = 0; } else { - WriteOut("overlaydrive construction failed."); + WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_GENERIC_ERROR")); return; } } else { - newdrive=new localDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid); + newdrive = new localDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid); } } } else { @@ -456,7 +462,7 @@ public: /* Set the correct media byte in the table */ mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*9,newdrive->GetMediaByte()); if (type != "overlay") WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),drive,newdrive->GetInfo()); - else WriteOut("Overlay %s on drive %c mounted.\n",temp_line.c_str(),drive); + else WriteOut(MSG_Get("PROGRAM_MOUNT_OVERLAY_STATUS"),temp_line.c_str(),drive); /* check if volume label is given and don't allow it to updated in the future */ if (cmd->FindString("-label",label,true)) newdrive->dirCache.SetLabel(label.c_str(),iscdrom,false); /* For hard drives set the label to DRIVELETTER_Drive. @@ -1645,6 +1651,12 @@ void DOS_SetupPrograms(void) { MSG_Add("PROGRAM_MOUNT_UMOUNT_NO_VIRTUAL","Virtual Drives can not be unMOUNTed.\n"); MSG_Add("PROGRAM_MOUNT_WARNING_WIN","\033[31;1mMounting c:\\ is NOT recommended. Please mount a (sub)directory next time.\033[0m\n"); MSG_Add("PROGRAM_MOUNT_WARNING_OTHER","\033[31;1mMounting / is NOT recommended. Please mount a (sub)directory next time.\033[0m\n"); + MSG_Add("PROGRAM_MOUNT_OVERLAY_NO_BASE","A normal directory needs to be MOUNTed first before an overlay can be added on top.\n"); + MSG_Add("PROGRAM_MOUNT_OVERLAY_INCOMPAT_BASE","The overlay is NOT compatible with the drive that is specified.\n"); + MSG_Add("PROGRAM_MOUNT_OVERLAY_MIXED_BASE","The overlay needs to be specified using the same addressing as the underlying drive. No mixing of relative and absolute paths."); + MSG_Add("PROGRAM_MOUNT_OVERLAY_SAME_AS_BASE","The overlay directory can not be the same as underlying drive.\n"); + MSG_Add("PROGRAM_MOUNT_OVERLAY_GENERIC_ERROR","Something went wrong.\n"); + MSG_Add("PROGRAM_MOUNT_OVERLAY_STATUS","Overlay %s on drive %c mounted.\n"); MSG_Add("PROGRAM_MEM_CONVEN","%10d Kb free conventional memory\n"); MSG_Add("PROGRAM_MEM_EXTEND","%10d Kb free extended memory\n");