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
|
|
|
|
2022-12-12 01:32:10 -08:00
|
|
|
void Set_Label(const char* const input, char* const output, bool cdrom);
|
2020-01-19 21:53:42 -08:00
|
|
|
std::string To_Label(const char* name);
|
2022-03-14 23:43:07 -04:00
|
|
|
std::string generate_8x3(const char *lfn, const unsigned int num, const bool start = false);
|
2022-03-02 20:50:02 -05:00
|
|
|
bool filename_not_8x3(const char *n);
|
|
|
|
bool filename_not_strict_8x3(const char *n);
|
2022-03-15 14:39:38 -04:00
|
|
|
char *VFILE_Generate_8x3(const char *name, const unsigned int onpos);
|
2022-03-28 23:15:41 -07:00
|
|
|
void VFILE_Register(const char *name,
|
|
|
|
const uint8_t *data,
|
|
|
|
const uint32_t size,
|
|
|
|
const char *dir);
|
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:
|
2022-04-13 13:53:59 -04:00
|
|
|
localDrive(const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid);
|
|
|
|
virtual bool FileOpen(DOS_File * * file,char * name,uint32_t flags);
|
2022-12-12 01:32:10 -08:00
|
|
|
virtual FILE* GetSystemFilePtr(const char* const name, const char* const type);
|
|
|
|
virtual bool GetSystemFilename(char* sysName, const char* const dosName);
|
|
|
|
virtual bool FileCreate(DOS_File** file, char* name, uint16_t 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 = false);
|
|
|
|
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);
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual bool AllocationInfo(uint16_t * _bytes_sector,uint8_t * _sectors_cluster,uint16_t * _total_clusters,uint16_t * _free_clusters);
|
2003-03-06 13:21:04 +00:00
|
|
|
virtual bool FileExists(const char* name);
|
|
|
|
virtual bool FileStat(const char* name, FileStat_Block * const stat_block);
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual uint8_t 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 {
|
2022-04-13 13:53:59 -04:00
|
|
|
uint16_t bytes_sector;
|
|
|
|
uint8_t sectors_cluster;
|
|
|
|
uint16_t total_clusters;
|
|
|
|
uint16_t free_clusters;
|
|
|
|
uint8_t mediaid;
|
2002-10-19 16:23:21 +00:00
|
|
|
} 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 {
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t nearjmp[3];
|
|
|
|
uint8_t oemname[8];
|
|
|
|
uint16_t bytespersector;
|
|
|
|
uint8_t sectorspercluster;
|
|
|
|
uint16_t reservedsectors;
|
|
|
|
uint8_t fatcopies;
|
|
|
|
uint16_t rootdirentries;
|
|
|
|
uint16_t totalsectorcount;
|
|
|
|
uint8_t mediadescriptor;
|
|
|
|
uint16_t sectorsperfat;
|
|
|
|
uint16_t sectorspertrack;
|
|
|
|
uint16_t headcount;
|
2004-04-03 19:24:59 +00:00
|
|
|
/* 32-bit FAT extensions */
|
2022-04-13 13:53:59 -04:00
|
|
|
uint32_t hiddensectorcount;
|
|
|
|
uint32_t totalsecdword;
|
|
|
|
uint8_t bootcode[474];
|
|
|
|
uint8_t magic1; /* 0x55 */
|
|
|
|
uint8_t magic2; /* 0xaa */
|
2004-04-03 19:24:59 +00:00
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
struct direntry {
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t entryname[11];
|
|
|
|
uint8_t attrib;
|
|
|
|
uint8_t NTRes;
|
|
|
|
uint8_t milliSecondStamp;
|
|
|
|
uint16_t crtTime;
|
|
|
|
uint16_t crtDate;
|
|
|
|
uint16_t accessDate;
|
|
|
|
uint16_t hiFirstClust;
|
|
|
|
uint16_t modTime;
|
|
|
|
uint16_t modDate;
|
|
|
|
uint16_t loFirstClust;
|
|
|
|
uint32_t entrysize;
|
2004-04-03 19:24:59 +00:00
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
struct partTable {
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t booter[446];
|
2004-04-03 19:24:59 +00:00
|
|
|
struct {
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t bootflag;
|
|
|
|
uint8_t beginchs[3];
|
|
|
|
uint8_t parttype;
|
|
|
|
uint8_t endchs[3];
|
|
|
|
uint32_t absSectStart;
|
|
|
|
uint32_t partSize;
|
2004-04-03 19:24:59 +00:00
|
|
|
} pentry[4];
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t magic1; /* 0x55 */
|
|
|
|
uint8_t magic2; /* 0xaa */
|
2004-04-03 19:24:59 +00:00
|
|
|
} 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-04-13 13:53:59 -04:00
|
|
|
fatDrive(const char * sysFilename, uint32_t bytesector, uint32_t cylsector, uint32_t headscyl, uint32_t cylinders, uint32_t startSector, bool roflag);
|
2019-12-07 11:55:38 -08:00
|
|
|
fatDrive(const fatDrive&) = delete; // prevent copying
|
|
|
|
fatDrive& operator= (const fatDrive&) = delete; // prevent assignment
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual bool FileOpen(DOS_File * * file,char * name,uint32_t flags);
|
|
|
|
virtual bool FileCreate(DOS_File * * file,char * name,uint16_t attributes);
|
2004-04-03 19:24:59 +00:00
|
|
|
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);
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual bool AllocationInfo(uint16_t * _bytes_sector,uint8_t * _sectors_cluster,uint16_t * _total_clusters,uint16_t * _free_clusters);
|
2004-04-03 19:24:59 +00:00
|
|
|
virtual bool FileExists(const char* name);
|
|
|
|
virtual bool FileStat(const char* name, FileStat_Block * const stat_block);
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual uint8_t GetMediaByte(void);
|
2004-04-03 19:24:59 +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-09-09 17:32:44 +00:00
|
|
|
virtual void EmptyCache(void){}
|
2004-04-03 19:24:59 +00:00
|
|
|
public:
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t readSector(uint32_t sectnum, void * data);
|
|
|
|
uint8_t writeSector(uint32_t sectnum, void * data);
|
|
|
|
uint32_t getAbsoluteSectFromBytePos(uint32_t startClustNum, uint32_t bytePos);
|
2022-05-28 17:39:15 -07:00
|
|
|
uint32_t getSectorCount();
|
2022-04-13 13:53:59 -04:00
|
|
|
uint32_t getSectorSize(void);
|
|
|
|
uint32_t getClusterSize(void);
|
|
|
|
uint32_t getAbsoluteSectFromChain(uint32_t startClustNum, uint32_t logicalSector);
|
|
|
|
bool allocateCluster(uint32_t useCluster, uint32_t prevCluster);
|
|
|
|
uint32_t appendCluster(uint32_t startCluster);
|
|
|
|
void deleteClustChain(uint32_t startCluster, uint32_t bytePos);
|
|
|
|
uint32_t getFirstFreeClust(void);
|
|
|
|
bool directoryBrowse(uint32_t dirClustNumber, direntry *useEntry, int32_t entNum, int32_t start=0);
|
|
|
|
bool directoryChange(uint32_t dirClustNumber, direntry *useEntry, int32_t 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;
|
2022-05-28 17:39:15 -07:00
|
|
|
uint32_t partSectOff;
|
|
|
|
|
2004-04-03 19:24:59 +00:00
|
|
|
private:
|
2022-04-13 13:53:59 -04:00
|
|
|
uint32_t getClusterValue(uint32_t clustNum);
|
|
|
|
void setClusterValue(uint32_t clustNum, uint32_t clustValue);
|
|
|
|
uint32_t getClustFirstSect(uint32_t clustNum);
|
|
|
|
bool FindNextInternal(uint32_t dirClustNumber, DOS_DTA & dta, direntry *foundEntry);
|
|
|
|
bool getDirClustNum(char * dir, uint32_t * clustNum, bool parDir);
|
2022-12-12 01:32:10 -08:00
|
|
|
bool getFileDirEntry(const char* const filename, direntry* useEntry,
|
|
|
|
uint32_t* dirClust, uint32_t* subEntry,
|
|
|
|
const bool dir_ok = false);
|
2022-04-13 13:53:59 -04:00
|
|
|
bool addDirectoryEntry(uint32_t dirClustNumber, direntry useEntry);
|
|
|
|
void zeroOutCluster(uint32_t clustNumber);
|
2004-04-03 19:24:59 +00:00
|
|
|
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;
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t fattype;
|
|
|
|
uint32_t CountOfClusters;
|
|
|
|
uint32_t firstDataSector;
|
|
|
|
uint32_t firstRootDirSect;
|
2004-04-03 19:24:59 +00:00
|
|
|
|
2022-04-13 13:53:59 -04:00
|
|
|
uint32_t cwdDirCluster;
|
2012-12-26 16:14:19 +00:00
|
|
|
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t fatSectBuffer[1024];
|
|
|
|
uint32_t 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:
|
2022-04-13 13:53:59 -04:00
|
|
|
cdromDrive(const char _driveLetter, const char * startdir,uint16_t _bytes_sector,uint8_t _sectors_cluster,uint16_t _total_clusters,uint16_t _free_clusters,uint8_t _mediaid, int& error);
|
|
|
|
virtual bool FileOpen(DOS_File * * file,char * name,uint32_t flags);
|
|
|
|
virtual bool FileCreate(DOS_File * * file,char * name,uint16_t attributes);
|
2003-03-06 13:21:04 +00:00
|
|
|
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:
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t 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 {
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t standardIdent[5];
|
|
|
|
uint8_t version;
|
|
|
|
uint8_t unused1;
|
|
|
|
uint8_t systemIdent[32];
|
|
|
|
uint8_t volumeIdent[32];
|
|
|
|
uint8_t unused2[8];
|
|
|
|
uint32_t volumeSpaceSizeL;
|
|
|
|
uint32_t volumeSpaceSizeM;
|
|
|
|
uint8_t unused3[32];
|
|
|
|
uint16_t volumeSetSizeL;
|
|
|
|
uint16_t volumeSetSizeM;
|
|
|
|
uint16_t volumeSeqNumberL;
|
|
|
|
uint16_t volumeSeqNumberM;
|
|
|
|
uint16_t logicBlockSizeL;
|
|
|
|
uint16_t logicBlockSizeM;
|
|
|
|
uint32_t pathTableSizeL;
|
|
|
|
uint32_t pathTableSizeM;
|
|
|
|
uint32_t locationPathTableL;
|
|
|
|
uint32_t locationOptPathTableL;
|
|
|
|
uint32_t locationPathTableM;
|
|
|
|
uint32_t locationOptPathTableM;
|
|
|
|
uint8_t rootEntry[34];
|
|
|
|
uint32_t unused4[1858];
|
2004-08-13 19:43:02 +00:00
|
|
|
} GCC_ATTRIBUTE(packed);
|
|
|
|
|
|
|
|
struct isoDirEntry {
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t length;
|
|
|
|
uint8_t extAttrLength;
|
|
|
|
uint32_t extentLocationL;
|
|
|
|
uint32_t extentLocationM;
|
|
|
|
uint32_t dataLengthL;
|
|
|
|
uint32_t dataLengthM;
|
|
|
|
uint8_t dateYear;
|
|
|
|
uint8_t dateMonth;
|
|
|
|
uint8_t dateDay;
|
|
|
|
uint8_t timeHour;
|
|
|
|
uint8_t timeMin;
|
|
|
|
uint8_t timeSec;
|
|
|
|
uint8_t timeZone;
|
|
|
|
uint8_t fileFlags;
|
|
|
|
uint8_t fileUnitSize;
|
|
|
|
uint8_t interleaveGapSize;
|
|
|
|
uint16_t VolumeSeqNumberL;
|
|
|
|
uint16_t VolumeSeqNumberM;
|
|
|
|
uint8_t fileIdentLength;
|
|
|
|
uint8_t 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:
|
2022-04-13 13:53:59 -04:00
|
|
|
isoDrive(char driveLetter, const char* device_name, uint8_t mediaid, int &error);
|
2004-08-13 19:43:02 +00:00
|
|
|
~isoDrive();
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual bool FileOpen(DOS_File **file, char *name, uint32_t flags);
|
|
|
|
virtual bool FileCreate(DOS_File **file, char *name, uint16_t attributes);
|
2004-08-13 19:43:02 +00:00
|
|
|
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);
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual bool AllocationInfo(uint16_t *bytes_sector, uint8_t *sectors_cluster, uint16_t *total_clusters, uint16_t *free_clusters);
|
2004-08-13 19:43:02 +00:00
|
|
|
virtual bool FileExists(const char *name);
|
|
|
|
virtual bool FileStat(const char *name, FileStat_Block *const stat_block);
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual uint8_t GetMediaByte(void);
|
2004-08-13 19:43:02 +00:00
|
|
|
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);
|
2022-04-13 13:53:59 -04:00
|
|
|
bool readSector(uint8_t *buffer, uint32_t 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:
|
2022-04-13 13:53:59 -04:00
|
|
|
int readDirEntry(isoDirEntry *de, uint8_t *data);
|
2004-08-13 19:43:02 +00:00
|
|
|
bool loadImage();
|
2022-04-13 13:53:59 -04:00
|
|
|
bool lookupSingle(isoDirEntry *de, const char *name, uint32_t sectorStart, uint32_t length);
|
2004-08-13 19:43:02 +00:00
|
|
|
bool lookup(isoDirEntry *de, const char *path);
|
2022-04-13 13:53:59 -04:00
|
|
|
int UpdateMscdex(char driveLetter, const char* physicalPath, uint8_t& 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);
|
2022-04-13 13:53:59 -04:00
|
|
|
bool ReadCachedSector(uint8_t** buffer, const uint32_t sector);
|
2006-02-12 13:32:30 +00:00
|
|
|
|
|
|
|
struct DirIterator {
|
|
|
|
bool valid;
|
2010-02-05 08:37:17 +00:00
|
|
|
bool root;
|
2022-04-13 13:53:59 -04:00
|
|
|
uint32_t currentSector;
|
|
|
|
uint32_t endSector;
|
|
|
|
uint32_t pos;
|
2006-02-12 13:32:30 +00:00
|
|
|
} dirIterators[MAX_OPENDIRS];
|
|
|
|
|
|
|
|
int nextFreeDirIterator;
|
|
|
|
|
|
|
|
struct SectorHashEntry {
|
|
|
|
bool valid;
|
2022-04-13 13:53:59 -04:00
|
|
|
uint32_t sector;
|
|
|
|
uint8_t data[ISO_FRAMESIZE];
|
2006-02-12 13:32:30 +00:00
|
|
|
} 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;
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t mediaid;
|
2007-01-21 16:21:22 +00:00
|
|
|
char fileName[CROSS_LEN];
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t subUnit;
|
2006-06-22 13:15:07 +00:00
|
|
|
char driveLetter;
|
2004-08-13 19:43:02 +00:00
|
|
|
char discLabel[32];
|
|
|
|
};
|
|
|
|
|
2022-12-12 01:06:26 -08:00
|
|
|
class VFILE_Block;
|
|
|
|
using vfile_block_t = std::shared_ptr<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();
|
2022-04-13 13:53:59 -04:00
|
|
|
bool FileOpen(DOS_File * * file,char * name,uint32_t flags);
|
|
|
|
bool FileCreate(DOS_File * * file,char * name,uint16_t attributes);
|
2002-07-27 13:08:48 +00:00
|
|
|
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);
|
2022-04-13 13:53:59 -04:00
|
|
|
bool AllocationInfo(uint16_t * _bytes_sector,uint8_t * _sectors_cluster,uint16_t * _total_clusters,uint16_t * _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);
|
2022-04-13 13:53:59 -04:00
|
|
|
uint8_t GetMediaByte();
|
2022-03-15 14:39:38 -04:00
|
|
|
void EmptyCache();
|
|
|
|
bool isRemote();
|
|
|
|
virtual bool isRemovable();
|
|
|
|
virtual Bits UnMount();
|
2022-12-12 01:32:10 -08:00
|
|
|
virtual const char* GetLabel();
|
|
|
|
|
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
|
2022-12-12 01:06:26 -08:00
|
|
|
vfile_block_t search_file;
|
2002-07-27 13:08:48 +00:00
|
|
|
};
|
|
|
|
|
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);
|
2022-04-13 13:53:59 -04:00
|
|
|
virtual bool FileCreate(DOS_File * * file,char * name,uint16_t /*attributes*/);
|
2019-03-25 13:49:25 +00:00
|
|
|
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);
|
|
|
|
|
2022-12-12 01:32:10 -08:00
|
|
|
FILE* create_file_in_overlay(const char* dos_filename, const char* mode);
|
2020-05-13 14:05:55 +02:00
|
|
|
|
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
|