2002-07-27 13:08:48 +00:00
|
|
|
/*
|
2021-01-14 18:29:34 +00:00
|
|
|
* Copyright (C) 2002-2021 The DOSBox Team
|
2002-07-27 13:08:48 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-08-04 09:12:57 +00:00
|
|
|
* GNU General Public License for more details.
|
2002-07-27 13:08:48 +00:00
|
|
|
*
|
2019-01-25 14:09:58 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-07-27 13:08:48 +00:00
|
|
|
*/
|
|
|
|
|
2019-12-31 20:29:22 +01:00
|
|
|
#ifndef DOSBOX_DRIVES_H
|
|
|
|
#define DOSBOX_DRIVES_H
|
2003-12-17 21:55:42 +00:00
|
|
|
|
2019-12-31 20:29:22 +01:00
|
|
|
#include "dosbox.h"
|
2002-07-27 13:08:48 +00:00
|
|
|
|
2019-12-07 11:55:38 -08:00
|
|
|
#include <memory>
|
2020-02-23 22:28:08 -08:00
|
|
|
#include <unordered_set>
|
2019-03-25 13:49:25 +00:00
|
|
|
#include <string>
|
2019-12-07 11:55:38 -08:00
|
|
|
#include <vector>
|
2019-12-31 20:29:22 +01:00
|
|
|
|
|
|
|
#include "dos_inc.h"
|
2002-08-06 09:19:56 +00:00
|
|
|
#include "dos_system.h"
|
2002-10-19 16:23:21 +00:00
|
|
|
|
2007-11-01 12:15:34 +00:00
|
|
|
void Set_Label(char const * const input, char * const output, bool cdrom);
|
2020-01-19 21:53:42 -08:00
|
|
|
std::string To_Label(const char* name);
|
2022-03-02 20:50:02 -05:00
|
|
|
void generate_8x3(char *lfn, unsigned int k, unsigned int &i, unsigned int &t);
|
|
|
|
bool filename_not_8x3(const char *n);
|
|
|
|
bool filename_not_strict_8x3(const char *n);
|
2002-07-27 13:08:48 +00:00
|
|
|
|
2007-01-21 16:21:22 +00:00
|
|
|
class DriveManager {
|
|
|
|
public:
|
|
|
|
static void AppendDisk(int drive, DOS_Drive* disk);
|
|
|
|
static void InitializeDrive(int drive);
|
|
|
|
static int UnmountDrive(int drive);
|
|
|
|
// static void CycleDrive(bool pressed);
|
|
|
|
// static void CycleDisk(bool pressed);
|
2018-07-10 15:51:16 +00:00
|
|
|
static void CycleDisks(int drive, bool notify);
|
2007-01-21 16:21:22 +00:00
|
|
|
static void CycleAllDisks(void);
|
2022-01-27 21:34:08 -05:00
|
|
|
static char *GetDrivePosition(int drive);
|
2007-01-21 16:21:22 +00:00
|
|
|
static void Init(Section* sec);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static struct DriveInfo {
|
2019-12-31 21:45:26 +01:00
|
|
|
std::vector<DOS_Drive*> disks = {};
|
|
|
|
int currentDisk = 0;
|
2007-01-21 16:21:22 +00:00
|
|
|
} driveInfos[DOS_DRIVES];
|
|
|
|
|
|
|
|
static int currentDrive;
|
|
|
|
};
|
|
|
|
|
2002-07-27 13:08:48 +00:00
|
|
|
class localDrive : public DOS_Drive {
|
|
|
|
public:
|
2002-12-02 18:56:53 +00:00
|
|
|
localDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid);
|
2003-03-06 13:21:04 +00:00
|
|
|
virtual bool FileOpen(DOS_File * * file,char * name,Bit32u flags);
|
2006-04-17 10:45:32 +00:00
|
|
|
virtual FILE *GetSystemFilePtr(char const * const name, char const * const type);
|
|
|
|
virtual bool GetSystemFilename(char* sysName, char const * const dosName);
|
2003-03-06 13:21:04 +00:00
|
|
|
virtual bool FileCreate(DOS_File * * file,char * name,Bit16u attributes);
|
|
|
|
virtual bool FileUnlink(char * name);
|
|
|
|
virtual bool RemoveDir(char * dir);
|
|
|
|
virtual bool MakeDir(char * dir);
|
|
|
|
virtual bool TestDir(char * dir);
|
2004-04-18 14:49:50 +00:00
|
|
|
virtual bool FindFirst(char * _dir,DOS_DTA & dta,bool fcb_findfirst=false);
|
2003-03-06 13:21:04 +00:00
|
|
|
virtual bool FindNext(DOS_DTA & dta);
|
2022-01-17 16:52:42 -05:00
|
|
|
virtual bool GetFileAttr(char * name, uint16_t * attr);
|
2022-01-20 16:54:50 -05:00
|
|
|
virtual bool SetFileAttr(const char * name, const uint16_t attr);
|
2003-03-06 13:21:04 +00:00
|
|
|
virtual bool Rename(char * oldname,char * newname);
|
|
|
|
virtual bool AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters);
|
|
|
|
virtual bool FileExists(const char* name);
|
|
|
|
virtual bool FileStat(const char* name, FileStat_Block * const stat_block);
|
|
|
|
virtual Bit8u GetMediaByte(void);
|
2003-11-08 18:00:47 +00:00
|
|
|
virtual bool isRemote(void);
|
2004-11-03 23:13:55 +00:00
|
|
|
virtual bool isRemovable(void);
|
2006-06-22 13:15:07 +00:00
|
|
|
virtual Bits UnMount(void);
|
2020-07-16 11:08:46 +02:00
|
|
|
const char *GetBasedir() const { return basedir; }
|
|
|
|
|
2019-03-25 13:49:25 +00:00
|
|
|
protected:
|
2020-08-13 11:38:59 -07:00
|
|
|
char basedir[CROSS_LEN] = "";
|
2003-02-13 23:33:43 +00:00
|
|
|
struct {
|
2020-08-13 11:38:59 -07:00
|
|
|
char srch_dir[CROSS_LEN] = "";
|
2003-02-13 23:33:43 +00:00
|
|
|
} srchInfo[MAX_OPENDIRS];
|
|
|
|
|
2019-03-25 13:49:25 +00:00
|
|
|
private:
|
2020-02-23 22:28:08 -08:00
|
|
|
bool IsFirstEncounter(const std::string& filename);
|
|
|
|
std::unordered_set<std::string> write_protected_files;
|
2002-10-19 16:23:21 +00:00
|
|
|
struct {
|
|
|
|
Bit16u bytes_sector;
|
2002-12-02 18:56:53 +00:00
|
|
|
Bit8u sectors_cluster;
|
2002-10-19 16:23:21 +00:00
|
|
|
Bit16u total_clusters;
|
|
|
|
Bit16u free_clusters;
|
|
|
|
Bit8u mediaid;
|
|
|
|
} allocation;
|
2002-07-27 13:08:48 +00:00
|
|
|
};
|
|
|
|
|
2004-04-03 19:24:59 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack (1)
|
|
|
|
#endif
|
|
|
|
struct bootstrap {
|
|
|
|
Bit8u nearjmp[3];
|
|
|
|
Bit8u oemname[8];
|
|
|
|
Bit16u bytespersector;
|
|
|
|
Bit8u sectorspercluster;
|
|
|
|
Bit16u reservedsectors;
|
|
|
|
Bit8u fatcopies;
|
|
|
|
Bit16u rootdirentries;
|
|
|
|
Bit16u totalsectorcount;
|
|
|
|
Bit8u mediadescriptor;
|
|
|
|
Bit16u sectorsperfat;
|
|
|
|
Bit16u sectorspertrack;
|
|
|
|
Bit16u headcount;
|
|
|
|
/* 32-bit FAT extensions */
|
|
|
|
Bit32u hiddensectorcount;
|
|
|
|
Bit32u totalsecdword;
|
|
|
|
Bit8u bootcode[474];
|
|
|
|
Bit8u magic1; /* 0x55 */
|
|
|
|
Bit8u magic2; /* 0xaa */
|
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
struct direntry {
|
|
|
|
Bit8u entryname[11];
|
|
|
|
Bit8u attrib;
|
|
|
|
Bit8u NTRes;
|
|
|
|
Bit8u milliSecondStamp;
|
|
|
|
Bit16u crtTime;
|
|
|
|
Bit16u crtDate;
|
|
|
|
Bit16u accessDate;
|
|
|
|
Bit16u hiFirstClust;
|
|
|
|
Bit16u modTime;
|
|
|
|
Bit16u modDate;
|
|
|
|
Bit16u loFirstClust;
|
|
|
|
Bit32u entrysize;
|
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
struct partTable {
|
|
|
|
Bit8u booter[446];
|
|
|
|
struct {
|
|
|
|
Bit8u bootflag;
|
|
|
|
Bit8u beginchs[3];
|
|
|
|
Bit8u parttype;
|
|
|
|
Bit8u endchs[3];
|
|
|
|
Bit32u absSectStart;
|
|
|
|
Bit32u partSize;
|
|
|
|
} pentry[4];
|
|
|
|
Bit8u magic1; /* 0x55 */
|
|
|
|
Bit8u magic2; /* 0xaa */
|
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack ()
|
|
|
|
#endif
|
2012-12-26 16:14:19 +00:00
|
|
|
//Forward
|
|
|
|
class imageDisk;
|
2021-04-19 09:36:23 -07:00
|
|
|
class fatDrive final : public DOS_Drive {
|
2004-04-03 19:24:59 +00:00
|
|
|
public:
|
2022-01-06 05:43:55 -05:00
|
|
|
fatDrive(const char * sysFilename, Bit32u bytesector, Bit32u cylsector, Bit32u headscyl, Bit32u cylinders, Bit32u startSector, bool roflag);
|
2019-12-07 11:55:38 -08:00
|
|
|
fatDrive(const fatDrive&) = delete; // prevent copying
|
|
|
|
fatDrive& operator= (const fatDrive&) = delete; // prevent assignment
|
2004-04-03 19:24:59 +00:00
|
|
|
virtual bool FileOpen(DOS_File * * file,char * name,Bit32u flags);
|
|
|
|
virtual bool FileCreate(DOS_File * * file,char * name,Bit16u attributes);
|
|
|
|
virtual bool FileUnlink(char * name);
|
|
|
|
virtual bool RemoveDir(char * dir);
|
|
|
|
virtual bool MakeDir(char * dir);
|
|
|
|
virtual bool TestDir(char * dir);
|
2004-04-18 14:49:50 +00:00
|
|
|
virtual bool FindFirst(char * _dir,DOS_DTA & dta,bool fcb_findfirst=false);
|
2004-04-03 19:24:59 +00:00
|
|
|
virtual bool FindNext(DOS_DTA & dta);
|
2022-01-17 16:52:42 -05:00
|
|
|
virtual bool GetFileAttr(char * name, uint16_t * attr);
|
2022-01-20 16:54:50 -05:00
|
|
|
virtual bool SetFileAttr(const char * name, const uint16_t attr);
|
2004-04-03 19:24:59 +00:00
|
|
|
virtual bool Rename(char * oldname,char * newname);
|
|
|
|
virtual bool AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters);
|
|
|
|
virtual bool FileExists(const char* name);
|
|
|
|
virtual bool FileStat(const char* name, FileStat_Block * const stat_block);
|
|
|
|
virtual Bit8u GetMediaByte(void);
|
|
|
|
virtual bool isRemote(void);
|
2004-11-03 23:13:55 +00:00
|
|
|
virtual bool isRemovable(void);
|
2006-06-22 13:15:07 +00:00
|
|
|
virtual Bits UnMount(void);
|
2020-09-09 17:32:44 +00:00
|
|
|
virtual void EmptyCache(void){}
|
2004-04-03 19:24:59 +00:00
|
|
|
public:
|
2018-07-10 16:05:17 +00:00
|
|
|
Bit8u readSector(Bit32u sectnum, void * data);
|
|
|
|
Bit8u writeSector(Bit32u sectnum, void * data);
|
2004-04-03 19:24:59 +00:00
|
|
|
Bit32u getAbsoluteSectFromBytePos(Bit32u startClustNum, Bit32u bytePos);
|
|
|
|
Bit32u getSectorSize(void);
|
2018-07-10 16:05:17 +00:00
|
|
|
Bit32u getClusterSize(void);
|
2004-04-03 19:24:59 +00:00
|
|
|
Bit32u getAbsoluteSectFromChain(Bit32u startClustNum, Bit32u logicalSector);
|
|
|
|
bool allocateCluster(Bit32u useCluster, Bit32u prevCluster);
|
|
|
|
Bit32u appendCluster(Bit32u startCluster);
|
2018-07-10 16:05:17 +00:00
|
|
|
void deleteClustChain(Bit32u startCluster, Bit32u bytePos);
|
2004-04-03 19:24:59 +00:00
|
|
|
Bit32u getFirstFreeClust(void);
|
2011-05-28 20:26:12 +00:00
|
|
|
bool directoryBrowse(Bit32u dirClustNumber, direntry *useEntry, Bit32s entNum, Bit32s start=0);
|
2004-04-03 19:24:59 +00:00
|
|
|
bool directoryChange(Bit32u dirClustNumber, direntry *useEntry, Bit32s entNum);
|
2019-12-18 16:57:48 +01:00
|
|
|
std::shared_ptr<imageDisk> loadedDisk;
|
2010-01-11 10:09:46 +00:00
|
|
|
bool created_successfully;
|
2004-04-03 19:24:59 +00:00
|
|
|
private:
|
|
|
|
Bit32u getClusterValue(Bit32u clustNum);
|
|
|
|
void setClusterValue(Bit32u clustNum, Bit32u clustValue);
|
|
|
|
Bit32u getClustFirstSect(Bit32u clustNum);
|
|
|
|
bool FindNextInternal(Bit32u dirClustNumber, DOS_DTA & dta, direntry *foundEntry);
|
|
|
|
bool getDirClustNum(char * dir, Bit32u * clustNum, bool parDir);
|
2022-01-20 17:01:28 -05:00
|
|
|
bool getFileDirEntry(char const * const filename, direntry * useEntry, uint32_t * dirClust, uint32_t * subEntry, const bool dir_ok = false);
|
2004-04-03 19:24:59 +00:00
|
|
|
bool addDirectoryEntry(Bit32u dirClustNumber, direntry useEntry);
|
|
|
|
void zeroOutCluster(Bit32u clustNumber);
|
|
|
|
bool getEntryName(char *fullname, char *entname);
|
|
|
|
|
|
|
|
bootstrap bootbuffer;
|
2018-07-10 16:05:17 +00:00
|
|
|
bool absolute;
|
2022-01-06 05:43:55 -05:00
|
|
|
bool readonly;
|
2004-04-03 19:24:59 +00:00
|
|
|
Bit8u fattype;
|
|
|
|
Bit32u CountOfClusters;
|
|
|
|
Bit32u partSectOff;
|
|
|
|
Bit32u firstDataSector;
|
|
|
|
Bit32u firstRootDirSect;
|
|
|
|
|
|
|
|
Bit32u cwdDirCluster;
|
2012-12-26 16:14:19 +00:00
|
|
|
|
|
|
|
Bit8u fatSectBuffer[1024];
|
|
|
|
Bit32u curFatSect;
|
2004-04-03 19:24:59 +00:00
|
|
|
};
|
|
|
|
|
2021-04-19 09:36:23 -07:00
|
|
|
class cdromDrive final : public localDrive
|
2003-03-06 13:21:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-01-23 18:23:50 -08:00
|
|
|
cdromDrive(const char _driveLetter, const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid, int& error);
|
2003-03-06 13:21:04 +00:00
|
|
|
virtual bool FileOpen(DOS_File * * file,char * name,Bit32u flags);
|
|
|
|
virtual bool FileCreate(DOS_File * * file,char * name,Bit16u attributes);
|
|
|
|
virtual bool FileUnlink(char * name);
|
|
|
|
virtual bool RemoveDir(char * dir);
|
|
|
|
virtual bool MakeDir(char * dir);
|
|
|
|
virtual bool Rename(char * oldname,char * newname);
|
2022-01-17 16:52:42 -05:00
|
|
|
virtual bool GetFileAttr(char * name, uint16_t * attr);
|
2004-04-18 14:49:50 +00:00
|
|
|
virtual bool FindFirst(char * _dir,DOS_DTA & dta,bool fcb_findfirst=false);
|
2003-03-06 13:21:04 +00:00
|
|
|
virtual void SetDir(const char* path);
|
2003-11-08 18:00:47 +00:00
|
|
|
virtual bool isRemote(void);
|
2004-11-03 23:13:55 +00:00
|
|
|
virtual bool isRemovable(void);
|
2006-06-22 13:15:07 +00:00
|
|
|
virtual Bits UnMount(void);
|
2003-03-06 13:21:04 +00:00
|
|
|
private:
|
|
|
|
Bit8u subUnit;
|
2006-06-22 13:15:07 +00:00
|
|
|
char driveLetter;
|
2003-03-06 13:21:04 +00:00
|
|
|
};
|
2002-07-27 13:08:48 +00:00
|
|
|
|
2004-08-13 19:43:02 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack (1)
|
|
|
|
#endif
|
|
|
|
struct isoPVD {
|
|
|
|
Bit8u type;
|
|
|
|
Bit8u standardIdent[5];
|
|
|
|
Bit8u version;
|
|
|
|
Bit8u unused1;
|
|
|
|
Bit8u systemIdent[32];
|
|
|
|
Bit8u volumeIdent[32];
|
|
|
|
Bit8u unused2[8];
|
|
|
|
Bit32u volumeSpaceSizeL;
|
|
|
|
Bit32u volumeSpaceSizeM;
|
|
|
|
Bit8u unused3[32];
|
|
|
|
Bit16u volumeSetSizeL;
|
|
|
|
Bit16u volumeSetSizeM;
|
|
|
|
Bit16u volumeSeqNumberL;
|
|
|
|
Bit16u volumeSeqNumberM;
|
|
|
|
Bit16u logicBlockSizeL;
|
|
|
|
Bit16u logicBlockSizeM;
|
|
|
|
Bit32u pathTableSizeL;
|
|
|
|
Bit32u pathTableSizeM;
|
|
|
|
Bit32u locationPathTableL;
|
|
|
|
Bit32u locationOptPathTableL;
|
|
|
|
Bit32u locationPathTableM;
|
|
|
|
Bit32u locationOptPathTableM;
|
|
|
|
Bit8u rootEntry[34];
|
|
|
|
Bit32u unused4[1858];
|
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
struct isoDirEntry {
|
|
|
|
Bit8u length;
|
|
|
|
Bit8u extAttrLength;
|
|
|
|
Bit32u extentLocationL;
|
|
|
|
Bit32u extentLocationM;
|
|
|
|
Bit32u dataLengthL;
|
|
|
|
Bit32u dataLengthM;
|
|
|
|
Bit8u dateYear;
|
|
|
|
Bit8u dateMonth;
|
|
|
|
Bit8u dateDay;
|
|
|
|
Bit8u timeHour;
|
|
|
|
Bit8u timeMin;
|
|
|
|
Bit8u timeSec;
|
|
|
|
Bit8u timeZone;
|
|
|
|
Bit8u fileFlags;
|
|
|
|
Bit8u fileUnitSize;
|
|
|
|
Bit8u interleaveGapSize;
|
|
|
|
Bit16u VolumeSeqNumberL;
|
|
|
|
Bit16u VolumeSeqNumberM;
|
|
|
|
Bit8u fileIdentLength;
|
2006-11-05 17:30:54 +00:00
|
|
|
Bit8u ident[222];
|
2004-08-13 19:43:02 +00:00
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma pack ()
|
|
|
|
#endif
|
|
|
|
|
2005-09-07 19:15:09 +00:00
|
|
|
#if defined (WORDS_BIGENDIAN)
|
2004-08-13 19:43:02 +00:00
|
|
|
#define EXTENT_LOCATION(de) ((de).extentLocationM)
|
|
|
|
#define DATA_LENGTH(de) ((de).dataLengthM)
|
|
|
|
#else
|
|
|
|
#define EXTENT_LOCATION(de) ((de).extentLocationL)
|
|
|
|
#define DATA_LENGTH(de) ((de).dataLengthL)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ISO_FRAMESIZE 2048
|
2010-08-07 18:39:22 +00:00
|
|
|
#define ISO_ASSOCIATED 4
|
2004-08-13 19:43:02 +00:00
|
|
|
#define ISO_DIRECTORY 2
|
2005-03-16 20:44:56 +00:00
|
|
|
#define ISO_HIDDEN 1
|
2006-02-12 13:32:30 +00:00
|
|
|
#define ISO_MAX_FILENAME_LENGTH 37
|
2004-08-13 19:43:02 +00:00
|
|
|
#define ISO_MAXPATHNAME 256
|
|
|
|
#define ISO_FIRST_VD 16
|
2010-08-07 18:39:22 +00:00
|
|
|
#define IS_ASSOC(fileFlags) (fileFlags & ISO_ASSOCIATED)
|
2004-08-13 19:43:02 +00:00
|
|
|
#define IS_DIR(fileFlags) (fileFlags & ISO_DIRECTORY)
|
2005-03-16 20:44:56 +00:00
|
|
|
#define IS_HIDDEN(fileFlags) (fileFlags & ISO_HIDDEN)
|
2006-02-12 13:32:30 +00:00
|
|
|
#define ISO_MAX_HASH_TABLE_SIZE 100
|
2004-08-13 19:43:02 +00:00
|
|
|
|
2021-04-19 09:36:23 -07:00
|
|
|
class isoDrive final : public DOS_Drive {
|
2004-08-13 19:43:02 +00:00
|
|
|
public:
|
|
|
|
isoDrive(char driveLetter, const char* device_name, Bit8u mediaid, int &error);
|
|
|
|
~isoDrive();
|
|
|
|
virtual bool FileOpen(DOS_File **file, char *name, Bit32u flags);
|
|
|
|
virtual bool FileCreate(DOS_File **file, char *name, Bit16u attributes);
|
|
|
|
virtual bool FileUnlink(char *name);
|
|
|
|
virtual bool RemoveDir(char *dir);
|
|
|
|
virtual bool MakeDir(char *dir);
|
|
|
|
virtual bool TestDir(char *dir);
|
|
|
|
virtual bool FindFirst(char *_dir, DOS_DTA &dta, bool fcb_findfirst);
|
|
|
|
virtual bool FindNext(DOS_DTA &dta);
|
2022-01-17 16:52:42 -05:00
|
|
|
virtual bool GetFileAttr(char *name, uint16_t *attr);
|
2022-01-20 16:54:50 -05:00
|
|
|
virtual bool SetFileAttr(const char * name, const uint16_t attr);
|
2004-08-13 19:43:02 +00:00
|
|
|
virtual bool Rename(char * oldname,char * newname);
|
|
|
|
virtual bool AllocationInfo(Bit16u *bytes_sector, Bit8u *sectors_cluster, Bit16u *total_clusters, Bit16u *free_clusters);
|
|
|
|
virtual bool FileExists(const char *name);
|
|
|
|
virtual bool FileStat(const char *name, FileStat_Block *const stat_block);
|
|
|
|
virtual Bit8u GetMediaByte(void);
|
|
|
|
virtual void EmptyCache(void){}
|
|
|
|
virtual bool isRemote(void);
|
2004-11-03 23:13:55 +00:00
|
|
|
virtual bool isRemovable(void);
|
2006-06-22 13:15:07 +00:00
|
|
|
virtual Bits UnMount(void);
|
2004-08-13 19:43:02 +00:00
|
|
|
bool readSector(Bit8u *buffer, Bit32u sector);
|
2020-07-16 11:08:46 +02:00
|
|
|
virtual const char *GetLabel() { return discLabel; }
|
2007-01-21 16:21:22 +00:00
|
|
|
virtual void Activate(void);
|
2004-08-13 19:43:02 +00:00
|
|
|
private:
|
|
|
|
int readDirEntry(isoDirEntry *de, Bit8u *data);
|
|
|
|
bool loadImage();
|
|
|
|
bool lookupSingle(isoDirEntry *de, const char *name, Bit32u sectorStart, Bit32u length);
|
|
|
|
bool lookup(isoDirEntry *de, const char *path);
|
2007-01-21 16:21:22 +00:00
|
|
|
int UpdateMscdex(char driveLetter, const char* physicalPath, Bit8u& subUnit);
|
2006-02-12 13:32:30 +00:00
|
|
|
int GetDirIterator(const isoDirEntry* de);
|
|
|
|
bool GetNextDirEntry(const int dirIterator, isoDirEntry* de);
|
|
|
|
void FreeDirIterator(const int dirIterator);
|
|
|
|
bool ReadCachedSector(Bit8u** buffer, const Bit32u sector);
|
|
|
|
|
|
|
|
struct DirIterator {
|
|
|
|
bool valid;
|
2010-02-05 08:37:17 +00:00
|
|
|
bool root;
|
2006-02-12 13:32:30 +00:00
|
|
|
Bit32u currentSector;
|
|
|
|
Bit32u endSector;
|
|
|
|
Bit32u pos;
|
|
|
|
} dirIterators[MAX_OPENDIRS];
|
|
|
|
|
|
|
|
int nextFreeDirIterator;
|
|
|
|
|
|
|
|
struct SectorHashEntry {
|
|
|
|
bool valid;
|
|
|
|
Bit32u sector;
|
|
|
|
Bit8u data[ISO_FRAMESIZE];
|
|
|
|
} sectorHashEntries[ISO_MAX_HASH_TABLE_SIZE];
|
2004-08-13 19:43:02 +00:00
|
|
|
|
2015-01-08 17:23:15 +00:00
|
|
|
bool iso;
|
2007-08-22 11:54:35 +00:00
|
|
|
bool dataCD;
|
2004-08-13 19:43:02 +00:00
|
|
|
isoDirEntry rootEntry;
|
|
|
|
Bit8u mediaid;
|
2007-01-21 16:21:22 +00:00
|
|
|
char fileName[CROSS_LEN];
|
2004-08-13 19:43:02 +00:00
|
|
|
Bit8u subUnit;
|
2006-06-22 13:15:07 +00:00
|
|
|
char driveLetter;
|
2004-08-13 19:43:02 +00:00
|
|
|
char discLabel[32];
|
|
|
|
};
|
|
|
|
|
2003-03-06 13:21:04 +00:00
|
|
|
struct VFILE_Block;
|
2002-07-27 13:08:48 +00:00
|
|
|
|
2021-04-19 09:36:23 -07:00
|
|
|
class Virtual_Drive final : public DOS_Drive {
|
2002-07-27 13:08:48 +00:00
|
|
|
public:
|
|
|
|
Virtual_Drive();
|
|
|
|
bool FileOpen(DOS_File * * file,char * name,Bit32u flags);
|
|
|
|
bool FileCreate(DOS_File * * file,char * name,Bit16u attributes);
|
|
|
|
bool FileUnlink(char * name);
|
|
|
|
bool RemoveDir(char * dir);
|
|
|
|
bool MakeDir(char * dir);
|
|
|
|
bool TestDir(char * dir);
|
2004-04-18 14:49:50 +00:00
|
|
|
bool FindFirst(char * _dir,DOS_DTA & dta,bool fcb_findfirst);
|
2002-10-19 16:23:21 +00:00
|
|
|
bool FindNext(DOS_DTA & dta);
|
2022-01-17 16:52:42 -05:00
|
|
|
bool GetFileAttr(char * name, uint16_t * attr);
|
2022-01-20 16:54:50 -05:00
|
|
|
bool SetFileAttr(const char * name, const uint16_t attr);
|
2002-07-27 13:08:48 +00:00
|
|
|
bool Rename(char * oldname,char * newname);
|
2002-12-02 18:56:53 +00:00
|
|
|
bool AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters);
|
2004-11-03 23:13:55 +00:00
|
|
|
bool FileExists(const char* name);
|
|
|
|
bool FileStat(const char* name, FileStat_Block* const stat_block);
|
2002-10-19 16:23:21 +00:00
|
|
|
Bit8u GetMediaByte(void);
|
2022-03-02 20:50:02 -05:00
|
|
|
void EmptyCache(void);
|
2003-11-08 18:00:47 +00:00
|
|
|
bool isRemote(void);
|
2004-11-03 23:13:55 +00:00
|
|
|
virtual bool isRemovable(void);
|
2006-06-22 13:15:07 +00:00
|
|
|
virtual Bits UnMount(void);
|
2018-07-10 15:38:55 +00:00
|
|
|
virtual char const* GetLabel(void);
|
2002-07-27 13:08:48 +00:00
|
|
|
private:
|
2019-12-05 23:24:15 -08:00
|
|
|
Virtual_Drive(const Virtual_Drive&); // prevent copying
|
|
|
|
Virtual_Drive& operator= (const Virtual_Drive&); // prevent assignment
|
2002-07-27 13:08:48 +00:00
|
|
|
VFILE_Block * search_file;
|
|
|
|
};
|
|
|
|
|
2021-04-19 09:36:23 -07:00
|
|
|
class Overlay_Drive final : public localDrive {
|
2019-03-25 13:49:25 +00:00
|
|
|
public:
|
2020-09-04 17:53:09 +02:00
|
|
|
Overlay_Drive(const char *startdir,
|
|
|
|
const char *overlay,
|
|
|
|
uint16_t _bytes_sector,
|
|
|
|
uint8_t _sectors_cluster,
|
|
|
|
uint16_t _total_clusters,
|
|
|
|
uint16_t _free_clusters,
|
|
|
|
uint8_t _mediaid,
|
|
|
|
uint8_t &error);
|
2003-03-24 09:54:50 +00:00
|
|
|
|
2020-09-04 17:53:09 +02:00
|
|
|
virtual bool FileOpen(DOS_File **file, char *name, uint32_t flags);
|
2019-03-25 13:49:25 +00:00
|
|
|
virtual bool FileCreate(DOS_File * * file,char * name,Bit16u /*attributes*/);
|
|
|
|
virtual bool FindFirst(char * _dir,DOS_DTA & dta,bool fcb_findfirst);
|
|
|
|
virtual bool FindNext(DOS_DTA & dta);
|
|
|
|
virtual bool FileUnlink(char * name);
|
2022-01-17 16:52:42 -05:00
|
|
|
virtual bool GetFileAttr(char * name, uint16_t * attr);
|
2022-01-20 16:54:50 -05:00
|
|
|
virtual bool SetFileAttr(const char * name, const uint16_t attr);
|
2019-03-25 13:49:25 +00:00
|
|
|
virtual bool FileExists(const char* name);
|
|
|
|
virtual bool Rename(char * oldname,char * newname);
|
|
|
|
virtual bool FileStat(const char* name, FileStat_Block * const stat_block);
|
|
|
|
virtual void EmptyCache(void);
|
|
|
|
|
2020-05-13 14:05:55 +02:00
|
|
|
FILE *create_file_in_overlay(const char *dos_filename, char const *mode);
|
|
|
|
|
2019-03-25 13:49:25 +00:00
|
|
|
virtual Bits UnMount(void);
|
|
|
|
virtual bool TestDir(char * dir);
|
|
|
|
virtual bool RemoveDir(char * dir);
|
|
|
|
virtual bool MakeDir(char * dir);
|
|
|
|
private:
|
|
|
|
char overlaydir[CROSS_LEN];
|
2019-10-09 20:46:40 +00:00
|
|
|
bool Sync_leading_dirs(const char* dos_filename);
|
2019-03-25 13:49:25 +00:00
|
|
|
void add_DOSname_to_cache(const char* name);
|
|
|
|
void remove_DOSname_from_cache(const char* name);
|
2019-04-22 14:57:24 +00:00
|
|
|
void add_DOSdir_to_cache(const char* name);
|
|
|
|
void remove_DOSdir_from_cache(const char* name);
|
2019-03-25 13:49:25 +00:00
|
|
|
void update_cache(bool read_directory_contents = false);
|
2020-09-04 17:53:09 +02:00
|
|
|
|
2019-03-25 13:49:25 +00:00
|
|
|
std::vector<std::string> deleted_files_in_base; //Set is probably better, or some other solution (involving the disk).
|
2019-04-22 14:57:24 +00:00
|
|
|
std::vector<std::string> deleted_paths_in_base; //Currently only used to hide the overlay folder.
|
2019-03-25 13:49:25 +00:00
|
|
|
std::string overlap_folder;
|
2019-04-22 14:57:24 +00:00
|
|
|
void add_deleted_file(const char* name, bool create_on_disk);
|
|
|
|
void remove_deleted_file(const char* name, bool create_on_disk);
|
2019-03-25 13:49:25 +00:00
|
|
|
bool is_deleted_file(const char* name);
|
2019-04-22 14:57:24 +00:00
|
|
|
void add_deleted_path(const char* name, bool create_on_disk);
|
|
|
|
void remove_deleted_path(const char* name, bool create_on_disk);
|
2019-03-25 13:49:25 +00:00
|
|
|
bool is_deleted_path(const char* name);
|
2019-10-09 20:46:40 +00:00
|
|
|
bool check_if_leading_is_deleted(const char* name);
|
2019-03-25 13:49:25 +00:00
|
|
|
|
2019-04-22 14:57:24 +00:00
|
|
|
bool is_dir_only_in_overlay(const char* name); //cached
|
|
|
|
|
|
|
|
|
|
|
|
void remove_special_file_from_disk(const char* dosname, const char* operation);
|
|
|
|
void add_special_file_to_disk(const char* dosname, const char* operation);
|
2019-03-25 13:49:25 +00:00
|
|
|
std::string create_filename_of_special_operation(const char* dosname, const char* operation);
|
|
|
|
void convert_overlay_to_DOSname_in_base(char* dirname );
|
|
|
|
//For caching the update_cache routine.
|
|
|
|
std::vector<std::string> DOSnames_cache; //Also set is probably better.
|
2019-04-22 14:57:24 +00:00
|
|
|
std::vector<std::string> DOSdirs_cache; //Can not blindly change its type. it is important that subdirs come after the parent directory.
|
2019-03-25 13:49:25 +00:00
|
|
|
const std::string special_prefix;
|
|
|
|
};
|
2003-03-24 09:54:50 +00:00
|
|
|
|
2002-07-27 13:08:48 +00:00
|
|
|
#endif
|