Don't update the drive-label if one was specified at mount time. Be more flexible with directorie mounting (don't care about a trailing slash)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2057
This commit is contained in:
parent
49cfc19efb
commit
b2c2a02c97
3 changed files with 25 additions and 16 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_system.h,v 1.27 2004-11-03 23:13:53 qbix79 Exp $ */
|
||||
/* $Id: dos_system.h,v 1.28 2004-11-13 12:08:42 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOSSYSTEM_H_
|
||||
#define DOSSYSTEM_H_
|
||||
|
@ -127,7 +127,7 @@ public:
|
|||
void DeleteEntry (const char* path, bool ignoreLastDir = false);
|
||||
|
||||
void EmptyCache (void);
|
||||
void SetLabel (const char* name);
|
||||
void SetLabel (const char* name,bool allowupdate=true);
|
||||
char* GetLabel (void) { return label; };
|
||||
|
||||
class CFileInfo {
|
||||
|
@ -185,6 +185,7 @@ private:
|
|||
Bitu nextFreeFindFirst;
|
||||
|
||||
char label [CROSS_LEN];
|
||||
bool updatelabel;
|
||||
};
|
||||
|
||||
class DOS_No_Drive_Cache {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_programs.cpp,v 1.32 2004-10-26 18:18:22 qbix79 Exp $ */
|
||||
/* $Id: dos_programs.cpp,v 1.33 2004-11-13 12:08:43 qbix79 Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
}
|
||||
number[index]=0;sizes[count++]=atoi(number);
|
||||
|
||||
// get the drive letter
|
||||
// get the drive letter
|
||||
cmd->FindCommand(1,temp_line);
|
||||
if ((temp_line.size() > 2) || ((temp_line.size()>1) && (temp_line[1]!=':'))) goto showusage;
|
||||
drive=toupper(temp_line[0]);
|
||||
|
@ -138,6 +138,10 @@ public:
|
|||
|
||||
if (!cmd->FindCommand(2,temp_line)) goto showusage;
|
||||
if (!temp_line.size()) goto showusage;
|
||||
#if defined (WIN32)
|
||||
/* Removing trailing backslash if not root dir so stat will succeed */
|
||||
if(temp_line.size() > 3 && temp_line[temp_line.size()-1]=='\\') temp_line.erase(temp_line.size()-1,1);
|
||||
#endif
|
||||
struct stat test;
|
||||
if (stat(temp_line.c_str(),&test)) {
|
||||
WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_1"),temp_line.c_str());
|
||||
|
@ -185,8 +189,8 @@ public:
|
|||
/* Set the correct media byte in the table */
|
||||
mem_writeb(Real2Phys(dos.tables.mediaid)+drive-'A',newdrive->GetMediaByte());
|
||||
WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"),drive,newdrive->GetInfo());
|
||||
/* check if volume label is given */
|
||||
if (cmd->FindString("-label",label,true)) newdrive->dirCache.SetLabel(label.c_str());
|
||||
/* 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(),false);
|
||||
return;
|
||||
showusage:
|
||||
WriteOut(MSG_Get("PROGRAM_MOUNT_USAGE"));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: drive_cache.cpp,v 1.39 2004-10-05 19:50:03 qbix79 Exp $ */
|
||||
/* $Id: drive_cache.cpp,v 1.40 2004-11-13 12:08:43 qbix79 Exp $ */
|
||||
|
||||
#include "drives.h"
|
||||
#include "dos_inc.h"
|
||||
|
@ -69,6 +69,7 @@ DOS_Drive_Cache::DOS_Drive_Cache(void)
|
|||
nextFreeFindFirst = 0;
|
||||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) { dirSearch[i] = 0; free[i] = true; dirFindFirst[i] = 0; };
|
||||
SetDirSort(DIRALPHABETICAL);
|
||||
updatelabel = true;
|
||||
};
|
||||
|
||||
DOS_Drive_Cache::DOS_Drive_Cache(const char* path)
|
||||
|
@ -81,6 +82,7 @@ DOS_Drive_Cache::DOS_Drive_Cache(const char* path)
|
|||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) { dirSearch[i] = 0; free[i] = true; dirFindFirst[i] = 0; };
|
||||
SetDirSort(DIRALPHABETICAL);
|
||||
SetBaseDir(path);
|
||||
updatelabel = true;
|
||||
};
|
||||
|
||||
DOS_Drive_Cache::~DOS_Drive_Cache(void)
|
||||
|
@ -107,8 +109,14 @@ void DOS_Drive_Cache::EmptyCache(void)
|
|||
SetBaseDir(basePath);
|
||||
};
|
||||
|
||||
void DOS_Drive_Cache::SetLabel(const char* vname)
|
||||
void DOS_Drive_Cache::SetLabel(const char* vname,bool allowupdate)
|
||||
{
|
||||
/* allowupdate defaults to true. if mount sets a label then allowupdate is
|
||||
* false and will this function return at once after the first call.
|
||||
* The label will be set at the first call. */
|
||||
|
||||
if(!this->updatelabel) return;
|
||||
this->updatelabel = allowupdate;
|
||||
Bitu togo = 8;
|
||||
Bitu vnamePos = 0;
|
||||
Bitu labelPos = 0;
|
||||
|
@ -128,7 +136,7 @@ void DOS_Drive_Cache::SetLabel(const char* vname)
|
|||
//Remove trailing dot.
|
||||
if((labelPos > 0) && (label[labelPos-1] == '.'))
|
||||
label[labelPos-1]=0;
|
||||
// LOG(LOG_ALL,LOG_ERROR)("CACHE: Set volume label to %s",label);
|
||||
LOG(LOG_DOSMISC,LOG_NORMAL)("DIRCACHE: Set volume label to %s",label);
|
||||
};
|
||||
|
||||
Bit16u DOS_Drive_Cache::GetFreeID(CFileInfo* dir)
|
||||
|
@ -151,13 +159,9 @@ void DOS_Drive_Cache::SetBaseDir(const char* baseDir)
|
|||
char labellocal[256]={ 0 };
|
||||
char drive[4] = "C:\\";
|
||||
drive[0] = basePath[0];
|
||||
UINT type_drive=GetDriveType(drive);
|
||||
if(type_drive != DRIVE_FIXED) {
|
||||
//Only add label for non-fixed drives. (so stuff like "mount c c:\piet -t cdrom -label piet" works)
|
||||
if (GetVolumeInformation(drive,labellocal,256,NULL,NULL,NULL,NULL,0)) {
|
||||
LOG(LOG_MISC,LOG_NORMAL)("Cache: setting label for (non-fixed localdrive) to %s",labellocal);
|
||||
SetLabel(labellocal);
|
||||
}
|
||||
if (GetVolumeInformation(drive,labellocal,256,NULL,NULL,NULL,NULL,0)) {
|
||||
/* Set label and allow being updated */
|
||||
SetLabel(labellocal,true);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue