DOSBox-X
|
00001 /* 00002 * Copyright (C) 2002-2020 The DOSBox Team 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with this program; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 00020 #ifndef _DRIVES_H__ 00021 #define _DRIVES_H__ 00022 00023 #include <vector> 00024 #include <sys/types.h> 00025 #include "dos_system.h" 00026 #include "shell.h" /* for DOS_Shell */ 00027 00028 bool DOS_CommonFAT32FAT16DiskSpaceConv( 00029 Bit16u * bytes,Bit8u * sectors,Bit16u * clusters,Bit16u * free, 00030 const Bit32u bytes32,const Bit32u sectors32,const Bit32u clusters32,const Bit32u free32); 00031 00032 bool WildFileCmp(const char * file, const char * wild); 00033 bool LWildFileCmp(const char * file, const char * wild); 00034 void Set_Label(char const * const input, char * const output, bool cdrom); 00035 00036 class DriveManager { 00037 public: 00038 static void AppendDisk(int drive, DOS_Drive* disk); 00039 static void InitializeDrive(int drive); 00040 static int UnmountDrive(int drive); 00041 // static void CycleDrive(bool pressed); 00042 // static void CycleDisk(bool pressed); 00043 static void CycleDisks(int drive, bool notify); 00044 static void CycleAllDisks(void); 00045 static void CycleAllCDs(void); 00046 static void Init(Section* s); 00047 00048 static void SaveState( std::ostream& stream ); 00049 static void LoadState( std::istream& stream ); 00050 00051 private: 00052 static struct DriveInfo { 00053 std::vector<DOS_Drive*> disks; 00054 Bit32u currentDisk = 0; 00055 } driveInfos[DOS_DRIVES]; 00056 00057 static int currentDrive; 00058 }; 00059 00060 class localDrive : public DOS_Drive { 00061 public: 00062 localDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid, std::vector<std::string> &options); 00063 virtual bool FileOpen(DOS_File * * file,const char * name,Bit32u flags); 00064 virtual FILE *GetSystemFilePtr(char const * const name, char const * const type); 00065 virtual bool GetSystemFilename(char* sysName, char const * const dosName); 00066 virtual bool FileCreate(DOS_File * * file,const char * name,Bit16u attributes); 00067 virtual bool FileUnlink(const char * name); 00068 virtual bool RemoveDir(const char * dir); 00069 virtual bool MakeDir(const char * dir); 00070 virtual bool TestDir(const char * dir); 00071 virtual bool FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst=false); 00072 virtual bool FindNext(DOS_DTA & dta); 00073 virtual bool SetFileAttr(const char * name,Bit16u attr); 00074 virtual bool GetFileAttr(const char * name,Bit16u * attr); 00075 virtual bool GetFileAttrEx(char* name, struct stat *status); 00076 virtual unsigned long GetCompressedSize(char* name); 00077 #if defined (WIN32) 00078 virtual HANDLE CreateOpenFile(char const* const name); 00079 virtual unsigned long GetSerial(); 00080 #endif 00081 virtual bool Rename(const char * oldname,const char * newname); 00082 virtual bool AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters); 00083 virtual bool FileExists(const char* name); 00084 virtual bool FileStat(const char* name, FileStat_Block * const stat_block); 00085 virtual Bit8u GetMediaByte(void); 00086 virtual bool isRemote(void); 00087 virtual bool isRemovable(void); 00088 virtual Bits UnMount(void); 00089 virtual char const * GetLabel(){return dirCache.GetLabel();}; 00090 virtual void SetLabel(const char *label, bool iscdrom, bool updatable) { dirCache.SetLabel(label,iscdrom,updatable); }; 00091 virtual void *opendir(const char *name); 00092 virtual void closedir(void *handle); 00093 virtual bool read_directory_first(void *handle, char* entry_name, char* entry_sname, bool& is_directory); 00094 virtual bool read_directory_next(void *handle, char* entry_name, char* entry_sname, bool& is_directory); 00095 00096 virtual void EmptyCache(void) { dirCache.EmptyCache(); }; 00097 virtual void MediaChange() {}; 00098 const char* getBasedir() {return basedir;}; 00099 00100 int remote = -1; 00101 00102 protected: 00103 DOS_Drive_Cache dirCache; 00104 char basedir[CROSS_LEN]; 00105 friend void DOS_Shell::CMD_SUBST(char* args); 00106 struct { 00107 char srch_dir[CROSS_LEN]; 00108 } srchInfo[MAX_OPENDIRS] = {}; 00109 00110 struct { 00111 Bit16u bytes_sector; 00112 Bit8u sectors_cluster; 00113 Bit16u total_clusters; 00114 Bit16u free_clusters; 00115 Bit8u mediaid; 00116 } allocation; 00117 }; 00118 00119 #if 0 // nothing uses this 00120 class physfsDrive : public localDrive { 00121 private: 00122 bool isdir(const char *dir); 00123 00124 public: 00125 physfsDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid); 00126 virtual bool FileOpen(DOS_File * * file,const char * name,Bit32u flags); 00127 virtual bool FileCreate(DOS_File * * file,const char * name,Bit16u attributes); 00128 virtual bool FileUnlink(const char * name); 00129 virtual bool RemoveDir(const char * dir); 00130 virtual bool MakeDir(const char * dir); 00131 virtual bool TestDir(const char * dir); 00132 virtual bool FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst=false); 00133 virtual bool FindNext(DOS_DTA & dta); 00134 virtual bool GetFileAttr(const char * name,Bit16u * attr); 00135 virtual bool Rename(const char * oldname,const char * newname); 00136 virtual bool AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters); 00137 virtual bool FileExists(const char* name); 00138 virtual bool FileStat(const char* name, FileStat_Block * const stat_block); 00139 virtual Bit8u GetMediaByte(void); 00140 virtual bool isRemote(void); 00141 virtual bool isRemovable(void); 00142 virtual void *opendir(const char *dir); 00143 virtual void closedir(void *handle); 00144 virtual bool read_directory_first(void *handle, char* entry_name, bool& is_directory); 00145 virtual bool read_directory_next(void *handle, char* entry_name, bool& is_directory); 00146 virtual const char *GetInfo(void); 00147 virtual ~physfsDrive(void); 00148 }; 00149 #endif 00150 00151 #ifdef _MSC_VER 00152 #pragma pack (1) 00153 #endif 00154 struct FAT_BPB_MSDOS20 { 00155 Bit16u BPB_BytsPerSec; /* offset 0x00B size 0x002 Bytes per sector. Formerly bytespersector */ 00156 Bit8u BPB_SecPerClus; /* offset 0x00D size 0x001 Sectors per cluster, must be a power of 2. Formerly sectorspercluster */ 00157 Bit16u BPB_RsvdSecCnt; /* offset 0x00E size 0x002 Number of reserved sectors starting from partition, to FAT table. reservedsectors */ 00158 Bit8u BPB_NumFATs; /* offset 0x010 size 0x001 Number of FAT tables. fatcopies */ 00159 Bit16u BPB_RootEntCnt; /* offset 0x011 size 0x002 Number of 32-byte root directories (FAT12/FAT16), or 0 (FAT32). rootdirentries */ 00160 Bit16u BPB_TotSec16; /* offset 0x013 size 0x002 Total sectors of volume if count < 0x10000, or 0 if not. 0 if FAT32. totalsectorcount */ 00161 Bit8u BPB_Media; /* offset 0x015 size 0x001 Media type byte. mediadescriptor */ 00162 Bit16u BPB_FATSz16; /* offset 0x016 size 0x002 Sectors per fat (FAT12/FAT16), or 0 (FAT32). sectorsperfat */ 00163 } GCC_ATTRIBUTE(packed); /* ==> 0x018 size 0x00D total */ 00164 00165 struct FAT_BPB_MSDOS30 { 00166 Bit16u BPB_BytsPerSec; /* offset 0x00B size 0x002 Bytes per sector. Formerly bytespersector */ 00167 Bit8u BPB_SecPerClus; /* offset 0x00D size 0x001 Sectors per cluster, must be a power of 2. Formerly sectorspercluster */ 00168 Bit16u BPB_RsvdSecCnt; /* offset 0x00E size 0x002 Number of reserved sectors starting from partition, to FAT table. reservedsectors */ 00169 Bit8u BPB_NumFATs; /* offset 0x010 size 0x001 Number of FAT tables. fatcopies */ 00170 Bit16u BPB_RootEntCnt; /* offset 0x011 size 0x002 Number of 32-byte root directories (FAT12/FAT16), or 0 (FAT32). rootdirentries */ 00171 Bit16u BPB_TotSec16; /* offset 0x013 size 0x002 Total sectors of volume if count < 0x10000, or 0 if not. 0 if FAT32. totalsectorcount */ 00172 Bit8u BPB_Media; /* offset 0x015 size 0x001 Media type byte. mediadescriptor */ 00173 Bit16u BPB_FATSz16; /* offset 0x016 size 0x002 Sectors per fat (FAT12/FAT16), or 0 (FAT32). sectorsperfat */ 00174 Bit16u BPB_SecPerTrk; /* offset 0x018 size 0x002 Sectors per track. sectorspertrack */ 00175 Bit16u BPB_NumHeads; /* offset 0x01A size 0x002 Number of heads. headcount */ 00176 Bit32u BPB_HiddSec; /* offset 0x01C size 0x004 Number of hidden sectors (i.e. starting sector of partition). hiddensectorcount (MS-DOS 3.31) */ 00177 } GCC_ATTRIBUTE(packed); /* ==> 0x020 size 0x015 total */ 00178 /* ==== ADDITIONAL NOTES (Wikipedia) */ 00179 /* offset 0x01C size 0x002 Number of hidden sectors (i.e. starting sector of partition). hiddensectorcount (MS-DOS 3.0) */ 00180 /* offset 0x01E size 0x002 Total sectors including hidden (?) if BPB_TotSec16 != 0 (MS-DOS 3.20) */ 00181 00182 struct FAT_BPB_MSDOS331 { 00183 Bit16u BPB_BytsPerSec; /* offset 0x00B size 0x002 Bytes per sector. Formerly bytespersector */ 00184 Bit8u BPB_SecPerClus; /* offset 0x00D size 0x001 Sectors per cluster, must be a power of 2. Formerly sectorspercluster */ 00185 Bit16u BPB_RsvdSecCnt; /* offset 0x00E size 0x002 Number of reserved sectors starting from partition, to FAT table. reservedsectors */ 00186 Bit8u BPB_NumFATs; /* offset 0x010 size 0x001 Number of FAT tables. fatcopies */ 00187 Bit16u BPB_RootEntCnt; /* offset 0x011 size 0x002 Number of 32-byte root directories (FAT12/FAT16), or 0 (FAT32). rootdirentries */ 00188 Bit16u BPB_TotSec16; /* offset 0x013 size 0x002 Total sectors of volume if count < 0x10000, or 0 if not. 0 if FAT32. totalsectorcount */ 00189 Bit8u BPB_Media; /* offset 0x015 size 0x001 Media type byte. mediadescriptor */ 00190 Bit16u BPB_FATSz16; /* offset 0x016 size 0x002 Sectors per fat (FAT12/FAT16), or 0 (FAT32). sectorsperfat */ 00191 Bit16u BPB_SecPerTrk; /* offset 0x018 size 0x002 Sectors per track. sectorspertrack */ 00192 Bit16u BPB_NumHeads; /* offset 0x01A size 0x002 Number of heads. headcount */ 00193 Bit32u BPB_HiddSec; /* offset 0x01C size 0x004 Number of hidden sectors (i.e. starting sector of partition). hiddensectorcount (MS-DOS 3.31) */ 00194 Bit32u BPB_TotSec32; /* offset 0x020 size 0x004 Total sectors of volume if count >= 0x10000 or FAT32, or 0 if not. totalsecdword */ 00195 } GCC_ATTRIBUTE(packed); /* ==> 0x024 size 0x019 total */ 00196 00197 struct FAT_BPB_MSDOS40 { /* FAT12/FAT16 only */ 00198 Bit16u BPB_BytsPerSec; /* offset 0x00B size 0x002 Bytes per sector. Formerly bytespersector */ 00199 Bit8u BPB_SecPerClus; /* offset 0x00D size 0x001 Sectors per cluster, must be a power of 2. Formerly sectorspercluster */ 00200 Bit16u BPB_RsvdSecCnt; /* offset 0x00E size 0x002 Number of reserved sectors starting from partition, to FAT table. reservedsectors */ 00201 Bit8u BPB_NumFATs; /* offset 0x010 size 0x001 Number of FAT tables. fatcopies */ 00202 Bit16u BPB_RootEntCnt; /* offset 0x011 size 0x002 Number of 32-byte root directories (FAT12/FAT16), or 0 (FAT32). rootdirentries */ 00203 Bit16u BPB_TotSec16; /* offset 0x013 size 0x002 Total sectors of volume if count < 0x10000, or 0 if not. 0 if FAT32. totalsectorcount */ 00204 Bit8u BPB_Media; /* offset 0x015 size 0x001 Media type byte. mediadescriptor */ 00205 Bit16u BPB_FATSz16; /* offset 0x016 size 0x002 Sectors per fat (FAT12/FAT16), or 0 (FAT32). sectorsperfat */ 00206 Bit16u BPB_SecPerTrk; /* offset 0x018 size 0x002 Sectors per track. sectorspertrack */ 00207 Bit16u BPB_NumHeads; /* offset 0x01A size 0x002 Number of heads. headcount */ 00208 Bit32u BPB_HiddSec; /* offset 0x01C size 0x004 Number of hidden sectors (i.e. starting sector of partition). hiddensectorcount (MS-DOS 3.31) */ 00209 Bit32u BPB_TotSec32; /* offset 0x020 size 0x004 Total sectors of volume if count >= 0x10000 or FAT32, or 0 if not. totalsecdword */ 00210 Bit8u BPB_DrvNum; /* offset 0x024 size 0x001 Physical (INT 13h) drive number */ 00211 Bit8u BPB_Reserved1; /* offset 0x025 size 0x001 Reserved? */ 00212 Bit8u BPB_BootSig; /* offset 0x026 size 0x001 Extended boot signature. 0x29 or 0x28 to indicate following members exist. */ 00213 Bit32u BPB_VolID; /* offset 0x027 size 0x004 Volume ID, if BPB_BootSig is 0x28 or 0x29. */ 00214 Bit8u BPB_VolLab[11]; /* offset 0x02B size 0x00B Volume label, if BPB_BootSig is 0x28 or 0x29. */ 00215 Bit8u BPB_FilSysType[8]; /* offset 0x036 size 0x008 File system type, for display purposes if BPB_BootSig is 0x29. */ 00216 } GCC_ATTRIBUTE(packed); /* ==> 0x03E size 0x033 total */ 00217 00218 struct FAT_BPB_MSDOS710_FAT32 { /* FAT32 only */ 00219 Bit16u BPB_BytsPerSec; /* offset 0x00B size 0x002 Bytes per sector. Formerly bytespersector */ 00220 Bit8u BPB_SecPerClus; /* offset 0x00D size 0x001 Sectors per cluster, must be a power of 2. Formerly sectorspercluster */ 00221 Bit16u BPB_RsvdSecCnt; /* offset 0x00E size 0x002 Number of reserved sectors starting from partition, to FAT table. reservedsectors */ 00222 Bit8u BPB_NumFATs; /* offset 0x010 size 0x001 Number of FAT tables. fatcopies */ 00223 Bit16u BPB_RootEntCnt; /* offset 0x011 size 0x002 Number of 32-byte root directories (FAT12/FAT16), or 0 (FAT32). rootdirentries */ 00224 Bit16u BPB_TotSec16; /* offset 0x013 size 0x002 Total sectors of volume if count < 0x10000, or 0 if not. 0 if FAT32. totalsectorcount */ 00225 Bit8u BPB_Media; /* offset 0x015 size 0x001 Media type byte. mediadescriptor */ 00226 Bit16u BPB_FATSz16; /* offset 0x016 size 0x002 Sectors per fat (FAT12/FAT16), or 0 (FAT32). sectorsperfat */ 00227 Bit16u BPB_SecPerTrk; /* offset 0x018 size 0x002 Sectors per track. sectorspertrack */ 00228 Bit16u BPB_NumHeads; /* offset 0x01A size 0x002 Number of heads. headcount */ 00229 Bit32u BPB_HiddSec; /* offset 0x01C size 0x004 Number of hidden sectors (i.e. starting sector of partition). hiddensectorcount (MS-DOS 3.31) */ 00230 Bit32u BPB_TotSec32; /* offset 0x020 size 0x004 Total sectors of volume if count >= 0x10000 or FAT32, or 0 if not. totalsecdword */ 00231 Bit32u BPB_FATSz32; /* offset 0x024 size 0x004 Sectors per fat (FAT32). */ 00232 Bit16u BPB_ExtFlags; /* offset 0x028 size 0x002 Bitfield: [7:7] 1=one fat active 0=mirrored [3:0]=active FAT if mirroring disabled */ 00233 Bit16u BPB_FSVer; /* offset 0x02A size 0x002 Version number. Only 0.0 is defined now. Do not mount if newer version beyond what we support */ 00234 Bit32u BPB_RootClus; /* offset 0x02C size 0x004 Starting cluster number of the root directory (FAT32) */ 00235 Bit16u BPB_FSInfo; /* offset 0x030 size 0x002 Sector number in volume of FAT32 FSInfo structure in reserved area */ 00236 Bit16u BPB_BkBootSec; /* offset 0x032 size 0x002 Sector number in volume of FAT32 backup boot sector */ 00237 Bit8u BPB_Reserved[12]; /* offset 0x034 size 0x00C Reserved for future expansion */ 00238 Bit8u BS_DrvNum; /* offset 0x040 size 0x001 BPB_DrvNum but moved for FAT32 */ 00239 Bit8u BS_Reserved1; /* offset 0x041 size 0x001 BPB_Reserved1 but moved for FAT32 */ 00240 Bit8u BS_BootSig; /* offset 0x042 size 0x001 Extended boot signature. 0x29 or 0x28 to indicate following members exist. */ 00241 Bit32u BS_VolID; /* offset 0x043 size 0x004 Volume ID, if BPB_BootSig is 0x28 or 0x29. */ 00242 Bit8u BS_VolLab[11]; /* offset 0x047 size 0x00B Volume label, if BPB_BootSig is 0x28 or 0x29. */ 00243 Bit8u BS_FilSysType[8]; /* offset 0x052 size 0x008 File system type, for display purposes if BPB_BootSig is 0x29. */ 00244 } GCC_ATTRIBUTE(packed); /* ==> 0x05A size 0x04F total */ 00245 00246 typedef struct FAT_BPB_MSDOS40 FAT_BPB_MSDOS; /* what we use internally */ 00247 typedef struct FAT_BPB_MSDOS710_FAT32 FAT32_BPB_MSDOS; /* what we use internally */ 00248 00249 struct FAT_BootSector { 00250 /* --------- Common fields: Amalgam of Wikipedia documentation with names from Microsoft's FAT32 whitepaper */ 00251 Bit8u BS_jmpBoot[3]; /* offset 0x000 size 0x003 Jump instruction to boot code. Formerly nearjmp[3] */ 00252 Bit8u BS_OEMName[8]; /* offset 0x003 size 0x008 OEM string. Formerly oemname[8] */ 00253 /* --------- BIOS Parameter Block (converted in place from existing DOSBox-X code) */ 00254 union bpb_union_t { 00255 struct FAT_BPB_MSDOS20 v20; /* offset 0x00B size 0x00D MS-DOS 2.0 BPB */ 00256 struct FAT_BPB_MSDOS30 v30; /* offset 0x00B size 0x015 MS-DOS 3.0 BPB */ 00257 struct FAT_BPB_MSDOS331 v331; /* offset 0x00B size 0x019 MS-DOS 3.31 BPB */ 00258 struct FAT_BPB_MSDOS40 v40; /* offset 0x00B size 0x039 MS-DOS 4.0 BPB (FAT12/FAT16) */ 00259 struct FAT_BPB_MSDOS710_FAT32 v710_32;/* offset 0x00B size 0x04F MS-DOS 7.10 BPB (FAT32) */ 00260 00261 FAT_BPB_MSDOS v; /* offset 0x00B ... */ 00262 FAT32_BPB_MSDOS v32; /* offset 0x00B ... */ 00263 00264 inline bool is_fat32(void) const { 00265 return (v.BPB_RootEntCnt == 0 && v.BPB_TotSec16 == 0 && v.BPB_FATSz16 == 0); /* all fields are "must be set to 0" for FAT32 */ 00266 } 00267 } bpb; 00268 /* --------- The rest of the sector ---------- */ 00269 Bit8u bootcode[512 - 2/*magic*/ - sizeof(bpb_union_t) - 8/*OEM*/ - 3/*JMP*/]; 00270 Bit8u magic1; /* 0x55 */ 00271 Bit8u magic2; /* 0xaa */ 00272 #ifndef SECTOR_SIZE_MAX 00273 # pragma warning SECTOR_SIZE_MAX not defined 00274 #endif 00275 #if SECTOR_SIZE_MAX > 512 00276 Bit8u extra[SECTOR_SIZE_MAX - 512]; 00277 #endif 00278 } GCC_ATTRIBUTE(packed); 00279 static_assert(offsetof(FAT_BootSector,bpb.v20) == 0x00B,"Oops"); 00280 static_assert(offsetof(FAT_BootSector,bpb.v30) == 0x00B,"Oops"); 00281 static_assert(offsetof(FAT_BootSector,bpb.v331) == 0x00B,"Oops"); 00282 static_assert(offsetof(FAT_BootSector,bpb.v40) == 0x00B,"Oops"); 00283 static_assert(offsetof(FAT_BootSector,bpb.v) == 0x00B,"Oops"); 00284 static_assert(offsetof(FAT_BootSector,bpb.v20.BPB_TotSec16) == 0x013,"Oops"); 00285 static_assert(offsetof(FAT_BootSector,bpb.v30.BPB_TotSec16) == 0x013,"Oops"); 00286 static_assert(offsetof(FAT_BootSector,bpb.v331.BPB_TotSec16) == 0x013,"Oops"); 00287 static_assert(offsetof(FAT_BootSector,bpb.v40.BPB_TotSec16) == 0x013,"Oops"); 00288 static_assert(offsetof(FAT_BootSector,bpb.v.BPB_TotSec16) == 0x013,"Oops"); 00289 static_assert(offsetof(FAT_BootSector,bpb.v331.BPB_TotSec32) == 0x020,"Oops"); 00290 static_assert(offsetof(FAT_BootSector,bpb.v30.BPB_HiddSec) == 0x01C,"Oops"); 00291 static_assert(offsetof(FAT_BootSector,bpb.v40.BPB_TotSec32) == 0x020,"Oops"); 00292 static_assert(offsetof(FAT_BootSector,bpb.v40.BPB_VolLab) == 0x02B,"Oops"); 00293 static_assert(offsetof(FAT_BootSector,bpb.v710_32.BS_FilSysType) == 0x052,"Oops"); 00294 static_assert(sizeof(FAT_BootSector) == SECTOR_SIZE_MAX,"Oops"); 00295 static_assert(offsetof(FAT_BootSector,bpb.v331.BPB_TotSec32) == 0x020,"Oops"); 00296 static_assert(offsetof(FAT_BootSector,bpb.v40.BPB_TotSec32) == 0x020,"Oops"); 00297 static_assert(offsetof(FAT_BootSector,bpb.v710_32.BPB_TotSec32) == 0x020,"Oops"); 00298 static_assert(sizeof(FAT_BootSector::bpb.v20) == 0x00D,"Oops"); 00299 static_assert(sizeof(FAT_BootSector::bpb.v30) == 0x015,"Oops"); 00300 static_assert(sizeof(FAT_BootSector::bpb.v331) == 0x019,"Oops"); 00301 static_assert(sizeof(FAT_BootSector::bpb.v40) == 0x033,"Oops"); 00302 static_assert(sizeof(FAT_BootSector::bpb.v710_32) == 0x04F,"Oops"); 00303 00304 struct direntry { 00305 Bit8u entryname[11]; 00306 Bit8u attrib; 00307 Bit8u NTRes; 00308 Bit8u milliSecondStamp; 00309 Bit16u crtTime; // <- NTS: This field did not appear until MS-DOS 7.0 (Windows 95) 00310 Bit16u crtDate; // <- NTS: This field did not appear until MS-DOS 7.0 (Windows 95) 00311 Bit16u accessDate; // <- NTS: This field did not appear until MS-DOS 7.0 (Windows 95) 00312 Bit16u hiFirstClust; // <- NTS: FAT32 only! 00313 Bit16u modTime; 00314 Bit16u modDate; 00315 Bit16u loFirstClust; 00316 Bit32u entrysize; 00317 00318 inline Bit32u Cluster32(void) const { 00319 return ((Bit32u)hiFirstClust << (Bit32u)16) + loFirstClust; 00320 } 00321 inline void SetCluster32(const Bit32u v) { 00322 loFirstClust = (Bit16u)v; 00323 hiFirstClust = (Bit16u)(v >> (Bit32u)16); 00324 } 00325 } GCC_ATTRIBUTE(packed); 00326 00327 struct direntry_lfn { 00328 Bit8u LDIR_Ord; /* 0x00 Long filename ordinal (1 to 63). bit 6 (0x40) is set if the last entry, which normally comes first in the directory */ 00329 Bit16u LDIR_Name1[5]; /* 0x01 first 5 chars */ 00330 Bit8u attrib; /* 0x0B */ 00331 Bit8u LDIR_Type; /* 0x0C zero to indicate a LFN */ 00332 Bit8u LDIR_Chksum; /* 0x0D checksum */ 00333 Bit16u LDIR_Name2[6]; /* 0x0E next 6 chars */ 00334 Bit16u LDIR_FstClusLO; /* 0x1A zero (loFirstClust) */ 00335 Bit16u LDIR_Name3[2]; /* 0x1C next 2 chars */ 00336 } GCC_ATTRIBUTE(packed); 00337 static_assert(sizeof(direntry_lfn) == 0x20,"Oops"); 00338 static_assert(offsetof(direntry_lfn,LDIR_Name3) == 0x1C,"Oops"); 00339 00340 #define MAX_DIRENTS_PER_SECTOR (SECTOR_SIZE_MAX / sizeof(direntry)) 00341 00342 struct partTable { 00343 Bit8u booter[446]; 00344 struct { 00345 Bit8u bootflag; 00346 Bit8u beginchs[3]; 00347 Bit8u parttype; 00348 Bit8u endchs[3]; 00349 Bit32u absSectStart; 00350 Bit32u partSize; 00351 } pentry[4]; 00352 Bit8u magic1; /* 0x55 */ 00353 Bit8u magic2; /* 0xaa */ 00354 #ifndef SECTOR_SIZE_MAX 00355 # pragma warning SECTOR_SIZE_MAX not defined 00356 #endif 00357 #if SECTOR_SIZE_MAX > 512 00358 Bit8u extra[SECTOR_SIZE_MAX - 512]; 00359 #endif 00360 } GCC_ATTRIBUTE(packed); 00361 00362 #ifdef _MSC_VER 00363 #pragma pack () 00364 #endif 00365 //Forward 00366 class imageDisk; 00367 class fatDrive : public DOS_Drive { 00368 public: 00369 fatDrive(const char * sysFilename, Bit32u bytesector, Bit32u cylsector, Bit32u headscyl, Bit32u cylinders, std::vector<std::string> &options); 00370 fatDrive(imageDisk *sourceLoadedDisk, std::vector<std::string> &options); 00371 void fatDriveInit(const char *sysFilename, Bit32u bytesector, Bit32u cylsector, Bit32u headscyl, Bit32u cylinders, Bit64u filesize, const std::vector<std::string> &options); 00372 virtual ~fatDrive(); 00373 virtual bool FileOpen(DOS_File * * file,const char * name,Bit32u flags); 00374 virtual bool FileCreate(DOS_File * * file,const char * name,Bit16u attributes); 00375 virtual bool FileUnlink(const char * name); 00376 virtual bool RemoveDir(const char * dir); 00377 virtual bool MakeDir(const char * dir); 00378 virtual bool TestDir(const char * dir); 00379 virtual bool FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst=false); 00380 virtual bool FindNext(DOS_DTA & dta); 00381 virtual bool SetFileAttr(const char * name,Bit16u attr); 00382 virtual bool GetFileAttr(const char * name,Bit16u * attr); 00383 virtual bool GetFileAttrEx(char* name, struct stat *status); 00384 virtual unsigned long GetCompressedSize(char* name); 00385 #if defined (WIN32) 00386 virtual HANDLE CreateOpenFile(char const* const name); 00387 #endif 00388 virtual unsigned long GetSerial(); 00389 virtual bool Rename(const char * oldname,const char * newname); 00390 virtual bool AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters); 00391 virtual bool AllocationInfo32(Bit32u * _bytes_sector,Bit32u * _sectors_cluster,Bit32u * _total_clusters,Bit32u * _free_clusters); 00392 virtual bool FileExists(const char* name); 00393 virtual bool FileStat(const char* name, FileStat_Block * const stat_block); 00394 virtual Bit8u GetMediaByte(void); 00395 virtual bool isRemote(void); 00396 virtual bool isRemovable(void); 00397 virtual Bits UnMount(void); 00398 public: 00399 Bit8u readSector(Bit32u sectnum, void * data); 00400 Bit8u writeSector(Bit32u sectnum, void * data); 00401 Bit32u getAbsoluteSectFromBytePos(Bit32u startClustNum, Bit32u bytePos); 00402 Bit32u getSectorSize(void); 00403 Bit32u getClusterSize(void); 00404 Bit32u getAbsoluteSectFromChain(Bit32u startClustNum, Bit32u logicalSector); 00405 bool allocateCluster(Bit32u useCluster, Bit32u prevCluster); 00406 Bit32u appendCluster(Bit32u startCluster); 00407 void deleteClustChain(Bit32u startCluster, Bit32u bytePos); 00408 Bit32u getFirstFreeClust(void); 00409 bool directoryBrowse(Bit32u dirClustNumber, direntry *useEntry, Bit32s entNum, Bit32s start=0); 00410 bool directoryChange(Bit32u dirClustNumber, const direntry *useEntry, Bit32s entNum); 00411 const FAT_BootSector::bpb_union_t &GetBPB(void); 00412 void SetBPB(const FAT_BootSector::bpb_union_t &bpb); 00413 imageDisk *loadedDisk = NULL; 00414 uint8_t req_ver_major = 0,req_ver_minor = 0; 00415 bool created_successfully = true; 00416 private: 00417 char* Generate_SFN(const char *path, const char *name); 00418 Bit32u getClusterValue(Bit32u clustNum); 00419 void setClusterValue(Bit32u clustNum, Bit32u clustValue); 00420 Bit32u getClustFirstSect(Bit32u clustNum); 00421 bool FindNextInternal(Bit32u dirClustNumber, DOS_DTA & dta, direntry *foundEntry); 00422 bool getDirClustNum(const char * dir, Bit32u * clustNum, bool parDir); 00423 bool getFileDirEntry(char const * const filename, direntry * useEntry, Bit32u * dirClust, Bit32u * subEntry,bool dirOk=false); 00424 bool addDirectoryEntry(Bit32u dirClustNumber, const direntry& useEntry,const char *lfn=NULL); 00425 void zeroOutCluster(Bit32u clustNumber); 00426 bool getEntryName(const char *fullname, char *entname); 00427 friend void DOS_Shell::CMD_SUBST(char* args); 00428 struct { 00429 char srch_dir[CROSS_LEN]; 00430 } srchInfo[MAX_OPENDIRS] = {}; 00431 00432 /* directory entry range of LFN entries after FindNextInternal(), needed by 00433 * filesystem code such as RemoveDir() which needs to delete the dirent AND 00434 * the LFNs. Range is dirPos_start inclusive to dirPos_end exclusive. 00435 * If start == end then there are no LFNs. 00436 * 00437 * Removal of entries: 00438 * for (x=start;x < end;x++) ... */ 00439 struct lfnRange_t { 00440 Bit16u dirPos_start; 00441 Bit16u dirPos_end; 00442 00443 void clear(void) { 00444 dirPos_start = dirPos_end = 0; 00445 } 00446 bool empty(void) const { 00447 return dirPos_start == dirPos_end; 00448 } 00449 } lfnRange = {0,0}; 00450 00451 struct { 00452 Bit16u bytes_sector; 00453 Bit8u sectors_cluster; 00454 Bit16u total_clusters; 00455 Bit16u free_clusters; 00456 Bit8u mediaid; 00457 } allocation = {}; 00458 00459 FAT_BootSector::bpb_union_t BPB = {}; // BPB in effect (translated from on-disk BPB as needed) 00460 bool absolute = false; 00461 Bit8u fattype = 0; 00462 Bit32u CountOfClusters = 0; 00463 Bit32u partSectOff = 0; 00464 Bit32u partSectSize = 0; 00465 Bit32u firstDataSector = 0; 00466 Bit32u firstRootDirSect = 0; 00467 00468 Bit32u cwdDirCluster = 0; 00469 00470 Bit8u fatSectBuffer[SECTOR_SIZE_MAX * 2] = {}; 00471 Bit32u curFatSect = 0; 00472 00473 DOS_Drive_Cache labelCache; 00474 public: 00475 /* the driver code must use THESE functions to read the disk, not directly from the disk drive, 00476 * in order to support a drive with a smaller sector size than the FAT filesystem's "sector". 00477 * 00478 * It is very common for instance to have PC-98 HDI images formatted with 256 bytes/sector at 00479 * the disk level and a FAT filesystem marked as having 1024 bytes/sector. */ 00480 virtual Bit8u Read_AbsoluteSector(Bit32u sectnum, void * data); 00481 virtual Bit8u Write_AbsoluteSector(Bit32u sectnum, void * data); 00482 virtual Bit32u getSectSize(void); 00483 Bit32u sector_size = 0; 00484 00485 // INT 25h/INT 26h 00486 virtual Bit32u GetSectorCount(void); 00487 virtual Bit32u GetSectorSize(void); 00488 virtual Bit8u Read_AbsoluteSector_INT25(Bit32u sectnum, void * data); 00489 virtual Bit8u Write_AbsoluteSector_INT25(Bit32u sectnum, void * data); 00490 virtual void UpdateDPB(unsigned char dos_drive); 00491 00492 virtual char const * GetLabel(){return labelCache.GetLabel();}; 00493 virtual void SetLabel(const char *label, bool iscdrom, bool updatable); 00494 virtual void UpdateBootVolumeLabel(const char *label); 00495 virtual Bit32u GetPartitionOffset(void); 00496 virtual Bit32u GetFirstClusterOffset(void); 00497 virtual Bit32u GetHighestClusterNumber(void); 00498 }; 00499 00500 PhysPt DOS_Get_DPB(unsigned int dos_drive); 00501 00502 class cdromDrive : public localDrive 00503 { 00504 public: 00505 cdromDrive(const char driveLetter, const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid, int& error, std::vector<std::string> &options); 00506 virtual bool FileOpen(DOS_File * * file,const char * name,Bit32u flags); 00507 virtual bool FileCreate(DOS_File * * file,const char * name,Bit16u attributes); 00508 virtual bool FileUnlink(const char * name); 00509 virtual bool RemoveDir(const char * dir); 00510 virtual bool MakeDir(const char * dir); 00511 virtual bool Rename(const char * oldname,const char * newname); 00512 virtual bool GetFileAttr(const char * name,Bit16u * attr); 00513 virtual bool GetFileAttrEx(char* name, struct stat *status); 00514 virtual unsigned long GetCompressedSize(char* name); 00515 #if defined (WIN32) 00516 virtual HANDLE CreateOpenFile(char const* const name); 00517 virtual unsigned long GetSerial(); 00518 #endif 00519 virtual bool FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst=false); 00520 virtual void SetDir(const char* path); 00521 virtual bool isRemote(void); 00522 virtual bool isRemovable(void);virtual Bits UnMount(void); 00523 private: 00524 Bit8u subUnit; char driveLetter; 00525 }; 00526 00527 #if 0 // nothing uses this 00528 class physfscdromDrive : public physfsDrive 00529 { 00530 public: 00531 physfscdromDrive(const char driveLetter, const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid, int& error); 00532 virtual bool FileOpen(DOS_File * * file,const char * name,Bit32u flags); 00533 virtual bool FileCreate(DOS_File * * file,const char * name,Bit16u attributes); 00534 virtual bool FileUnlink(const char * name); 00535 virtual bool RemoveDir(const char * dir); 00536 virtual bool MakeDir(const char * dir); 00537 virtual bool Rename(const char * oldname,const char * newname); 00538 virtual bool GetFileAttr(const char * name,Bit16u * attr); 00539 virtual bool FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst=false); 00540 virtual void SetDir(const char* path); 00541 virtual bool isRemote(void); 00542 virtual bool isRemovable(void); 00543 virtual Bits UnMount(void); 00544 virtual const char *GetInfo(void); 00545 private: 00546 Bit8u subUnit; 00547 char driveLetter; 00548 }; 00549 #endif 00550 00551 #ifdef _MSC_VER 00552 #pragma pack (1) 00553 #endif 00554 struct isoPVD { 00555 Bit8u type; 00556 Bit8u standardIdent[5]; 00557 Bit8u version; 00558 Bit8u unused1; 00559 Bit8u systemIdent[32]; 00560 Bit8u volumeIdent[32]; 00561 Bit8u unused2[8]; 00562 Bit32u volumeSpaceSizeL; 00563 Bit32u volumeSpaceSizeM; 00564 Bit8u unused3[32]; 00565 Bit16u volumeSetSizeL; 00566 Bit16u volumeSetSizeM; 00567 Bit16u volumeSeqNumberL; 00568 Bit16u volumeSeqNumberM; 00569 Bit16u logicBlockSizeL; 00570 Bit16u logicBlockSizeM; 00571 Bit32u pathTableSizeL; 00572 Bit32u pathTableSizeM; 00573 Bit32u locationPathTableL; 00574 Bit32u locationOptPathTableL; 00575 Bit32u locationPathTableM; 00576 Bit32u locationOptPathTableM; 00577 Bit8u rootEntry[34]; 00578 Bit32u unused4[1858]; 00579 } GCC_ATTRIBUTE(packed); 00580 00581 struct isoDirEntry { 00582 Bit8u length; 00583 Bit8u extAttrLength; 00584 Bit32u extentLocationL; 00585 Bit32u extentLocationM; 00586 Bit32u dataLengthL; 00587 Bit32u dataLengthM; 00588 Bit8u dateYear; 00589 Bit8u dateMonth; 00590 Bit8u dateDay; 00591 Bit8u timeHour; 00592 Bit8u timeMin; 00593 Bit8u timeSec; 00594 Bit8u timeZone; 00595 Bit8u fileFlags; 00596 Bit8u fileUnitSize; 00597 Bit8u interleaveGapSize; 00598 Bit16u VolumeSeqNumberL; 00599 Bit16u VolumeSeqNumberM; 00600 Bit8u fileIdentLength; 00601 Bit8u ident[222]; 00602 } GCC_ATTRIBUTE(packed); 00603 00604 #ifdef _MSC_VER 00605 #pragma pack () 00606 #endif 00607 00608 #if defined (WORDS_BIGENDIAN) 00609 #define EXTENT_LOCATION(de) ((de).extentLocationM) 00610 #define DATA_LENGTH(de) ((de).dataLengthM) 00611 #else 00612 #define EXTENT_LOCATION(de) ((de).extentLocationL) 00613 #define DATA_LENGTH(de) ((de).dataLengthL) 00614 #endif 00615 00616 #define ISO_FRAMESIZE 2048u 00617 #define ISO_ASSOCIATED 4u 00618 #define ISO_DIRECTORY 2u 00619 #define ISO_HIDDEN 1u 00620 #define ISO_MAX_FILENAME_LENGTH 37u 00621 #define ISO_MAXPATHNAME 256u 00622 #define ISO_FIRST_VD 16u 00623 #define IS_ASSOC(fileFlags) (fileFlags & ISO_ASSOCIATED) 00624 #define IS_DIR(fileFlags) (fileFlags & ISO_DIRECTORY) 00625 #define IS_HIDDEN(fileFlags) (fileFlags & ISO_HIDDEN) 00626 #define ISO_MAX_HASH_TABLE_SIZE 100u 00627 00628 class isoDrive : public DOS_Drive { 00629 public: 00630 isoDrive(char driveLetter, const char* fileName, Bit8u mediaid, int &error); 00631 ~isoDrive(); 00632 virtual bool FileOpen(DOS_File **file, const char *name, Bit32u flags); 00633 virtual bool FileCreate(DOS_File **file, const char *name, Bit16u attributes); 00634 virtual bool FileUnlink(const char *name); 00635 virtual bool RemoveDir(const char *dir); 00636 virtual bool MakeDir(const char *dir); 00637 virtual bool TestDir(const char *dir); 00638 virtual bool FindFirst(const char *dir, DOS_DTA &dta, bool fcb_findfirst); 00639 virtual bool FindNext(DOS_DTA &dta); 00640 virtual bool SetFileAttr(const char *name,Bit16u attr); 00641 virtual bool GetFileAttr(const char *name, Bit16u *attr); 00642 virtual bool GetFileAttrEx(char* name, struct stat *status); 00643 virtual unsigned long GetCompressedSize(char* name); 00644 #if defined (WIN32) 00645 virtual HANDLE CreateOpenFile(char const* const name); 00646 #endif 00647 virtual bool Rename(const char * oldname,const char * newname); 00648 virtual bool AllocationInfo(Bit16u *bytes_sector, Bit8u *sectors_cluster, Bit16u *total_clusters, Bit16u *free_clusters); 00649 virtual bool FileExists(const char *name); 00650 virtual bool FileStat(const char *name, FileStat_Block *const stat_block); 00651 virtual Bit8u GetMediaByte(void); 00652 virtual void EmptyCache(void){} 00653 virtual void MediaChange(); 00654 virtual bool isRemote(void); 00655 virtual bool isRemovable(void); 00656 virtual Bits UnMount(void); 00657 bool readSector(Bit8u *buffer, Bit32u sector); 00658 virtual char const* GetLabel(void) {return discLabel;}; 00659 virtual void Activate(void); 00660 private: 00661 int readDirEntry(isoDirEntry* de, const Bit8u* data); 00662 bool loadImage(); 00663 bool lookupSingle(isoDirEntry *de, const char *name, Bit32u sectorStart, Bit32u length); 00664 bool lookup(isoDirEntry *de, const char *path); 00665 int UpdateMscdex(char driveLetter, const char* path, Bit8u& subUnit); 00666 int GetDirIterator(const isoDirEntry* de); 00667 bool GetNextDirEntry(const int dirIteratorHandle, isoDirEntry* de); 00668 void FreeDirIterator(const int dirIterator); 00669 bool ReadCachedSector(Bit8u** buffer, const Bit32u sector); 00670 void GetLongName(const char* ident, char* lfindName); 00671 00672 struct DirIterator { 00673 bool valid; 00674 bool root; 00675 Bit32u currentSector; 00676 Bit32u endSector; 00677 Bit32u pos; 00678 } dirIterators[MAX_OPENDIRS]; 00679 00680 int nextFreeDirIterator; 00681 00682 struct SectorHashEntry { 00683 bool valid; 00684 Bit32u sector; 00685 Bit8u data[ISO_FRAMESIZE]; 00686 } sectorHashEntries[ISO_MAX_HASH_TABLE_SIZE]; 00687 00688 bool iso = false; 00689 bool dataCD = false; 00690 isoDirEntry rootEntry; 00691 Bit8u mediaid = 0; 00692 char fileName[CROSS_LEN]; 00693 Bit8u subUnit = 0; 00694 char driveLetter = '\0'; 00695 char discLabel[32]; 00696 }; 00697 00698 struct VFILE_Block; 00699 00700 class Virtual_Drive: public DOS_Drive { 00701 public: 00702 Virtual_Drive(); 00703 bool FileOpen(DOS_File * * file,const char * name,Bit32u flags); 00704 bool FileCreate(DOS_File * * file,const char * name,Bit16u attributes); 00705 bool FileUnlink(const char * name); 00706 bool RemoveDir(const char * dir); 00707 bool MakeDir(const char * dir); 00708 bool TestDir(const char * dir); 00709 bool FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst); 00710 bool FindNext(DOS_DTA & dta); 00711 bool SetFileAttr(const char * name,Bit16u attr); 00712 bool GetFileAttr(const char * name,Bit16u * attr); 00713 bool GetFileAttrEx(char* name, struct stat *status); 00714 unsigned long GetCompressedSize(char* name); 00715 #if defined (WIN32) 00716 HANDLE CreateOpenFile(char const* const name); 00717 #endif 00718 bool Rename(const char * oldname,const char * newname); 00719 bool AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters); 00720 bool FileExists(const char* name); 00721 bool FileStat(const char* name, FileStat_Block* const stat_block); 00722 virtual void MediaChange() {} 00723 Bit8u GetMediaByte(void); 00724 void EmptyCache(void){} 00725 bool isRemote(void); 00726 virtual bool isRemovable(void); 00727 virtual Bits UnMount(void); 00728 virtual char const* GetLabel(void); 00729 private: 00730 VFILE_Block* search_file = 0; 00731 }; 00732 00733 class Overlay_Drive: public localDrive { 00734 public: 00735 Overlay_Drive(const char * startdir,const char* overlay, Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid,Bit8u &error, std::vector<std::string> &options); 00736 00737 virtual bool FileOpen(DOS_File * * file,const char * name,Bit32u flags); 00738 virtual bool FileCreate(DOS_File * * file,const char * name,Bit16u /*attributes*/); 00739 virtual bool FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst); 00740 virtual bool FindNext(DOS_DTA & dta); 00741 virtual bool FileUnlink(const char * name); 00742 virtual bool SetFileAttr(const char * name,Bit16u attr); 00743 virtual bool GetFileAttr(const char * name,Bit16u * attr); 00744 virtual bool FileExists(const char* name); 00745 virtual bool Rename(const char * oldname,const char * newname); 00746 virtual bool FileStat(const char* name, FileStat_Block * const stat_block); 00747 virtual void EmptyCache(void); 00748 00749 FILE* create_file_in_overlay(const char* dos_filename, char const* mode); 00750 virtual Bits UnMount(void); 00751 virtual bool TestDir(const char * dir); 00752 virtual bool RemoveDir(const char * dir); 00753 virtual bool MakeDir(const char * dir); 00754 bool ovlnocachedir = false; 00755 bool ovlreadonly = false; 00756 private: 00757 char overlaydir[CROSS_LEN]; 00758 bool optimize_cache_v1; 00759 bool Sync_leading_dirs(const char* dos_filename); 00760 void add_DOSname_to_cache(const char* name); 00761 void remove_DOSname_from_cache(const char* name); 00762 void add_DOSdir_to_cache(const char* name, const char* sname); 00763 void remove_DOSdir_from_cache(const char* name); 00764 void update_cache(bool read_directory_contents = false); 00765 00766 std::vector<std::string> deleted_files_in_base; //Set is probably better, or some other solution (involving the disk). 00767 std::vector<std::string> deleted_paths_in_base; //Currently only used to hide the overlay folder. 00768 std::string overlap_folder; 00769 void add_deleted_file(const char* name, bool create_on_disk); 00770 void remove_deleted_file(const char* name, bool create_on_disk); 00771 bool is_deleted_file(const char* name); 00772 void add_deleted_path(const char* name, bool create_on_disk); 00773 void remove_deleted_path(const char* name, bool create_on_disk); 00774 bool is_deleted_path(const char* name); 00775 bool check_if_leading_is_deleted(const char* name); 00776 00777 bool is_dir_only_in_overlay(const char* name); //cached 00778 00779 00780 void remove_special_file_from_disk(const char* dosname, const char* operation); 00781 void add_special_file_to_disk(const char* dosname, const char* operation); 00782 std::string create_filename_of_special_operation(const char* dosname, const char* operation); 00783 void convert_overlay_to_DOSname_in_base(char* dirname ); 00784 //For caching the update_cache routine. 00785 std::vector<std::string> DOSnames_cache; //Also set is probably better. 00786 std::vector<std::string> DOSdirs_cache; //Can not blindly change its type. it is important that subdirs come after the parent directory. 00787 const std::string special_prefix; 00788 }; 00789 00790 /* No LFN filefind in progress (SFN call). This index is out of range and meant to indicate no LFN call in progress. */ 00791 #define LFN_FILEFIND_NONE 258 00792 /* FAT image handle */ 00793 #define LFN_FILEFIND_IMG 256 00794 /* Internal handle */ 00795 #define LFN_FILEFIND_INTERNAL 255 00796 /* Highest valid handle */ 00797 #define LFN_FILEFIND_MAX 255 00798 00799 #endif