diff --git a/include/dos_system.h b/include/dos_system.h index c7bc88bd..dc0a3604 100644 --- a/include/dos_system.h +++ b/include/dos_system.h @@ -19,8 +19,11 @@ #ifndef DOSSYSTEM_H_ #define DOSSYSTEM_H_ -#include #include "dosbox.h" +#include "cross.h" +#include +#include +#include #define DOS_NAMELENGTH 12 #define DOS_NAMELENGTH_ASCII (DOS_NAMELENGTH+1) @@ -78,6 +81,115 @@ public: Bit8u fhandle; }; +#define MAX_OPENDIRS 16 + +class DOS_Drive_Cache { +public: + DOS_Drive_Cache (void); + DOS_Drive_Cache (const char* path); + ~DOS_Drive_Cache (void); + + typedef enum TDirSort { NOSORT, ALPHABETICAL, DIRALPHABETICAL, ALPHABETICALREV, DIRALPHABETICALREV }; + + void SetBaseDir (const char* path); + void SetDirSort (TDirSort sort) { sortDirType = sort; }; + bool OpenDir (const char* path, Bit16u& id); + bool ReadDir (Bit16u id, char* &result); + + void ExpandName (char* path); + char* GetExpandName (const char* path); + bool GetShortName (const char* fullname, char* shortname); + + void CacheOut (const char* path, bool ignoreLastDir = false); + void AddEntry (const char* path, bool checkExist = false); + void DeleteEntry (const char* path, bool ignoreLastDir = false); + + void EmptyCache (void); + + class CFileInfo { + public: + ~CFileInfo(void) { + for (Bit32u i=0; i fileList; + std::vector longNameList; + std::vector outputList; + }; + +private: + + bool RemoveTrailingDot (char* shortname); + Bit16s GetLongName (CFileInfo* info, char* shortname); + void CreateShortName (CFileInfo* dir, CFileInfo* info); + Bit16u CreateShortNameID (CFileInfo* dir, const char* name); + bool SetResult (CFileInfo* dir, char * &result, Bit16u entryNr); + bool IsCachedIn (CFileInfo* dir); + CFileInfo* FindDirInfo (const char* path, char* expandedPath); + bool RemoveSpaces (char* str); + bool OpenDir (CFileInfo* dir, char* path, Bit16u& id); + void CreateEntry (CFileInfo* dir, const char* name); + Bit16u GetFreeID (CFileInfo* dir); + void Clear (void); + + + CFileInfo* dirBase; + char dirPath [CROSS_LEN]; + char basePath [CROSS_LEN]; + bool dirFirstTime; + TDirSort sortDirType; + CFileInfo* save_dir; + char save_path [CROSS_LEN]; + char save_expanded [CROSS_LEN]; + + Bit16u srchNr; + CFileInfo* dirSearch [MAX_OPENDIRS]; + char dirSearchName [MAX_OPENDIRS]; + bool free [MAX_OPENDIRS]; + +}; + +class DOS_No_Drive_Cache { +public: + DOS_No_Drive_Cache (void) {}; + DOS_No_Drive_Cache (const char* path); + ~DOS_No_Drive_Cache (void) {}; + + typedef enum TDirSort { NOSORT, ALPHABETICAL, DIRALPHABETICAL, ALPHABETICALREV, DIRALPHABETICALREV }; + + void SetBaseDir (const char* path); + void SetDirSort (TDirSort sort) {}; + bool OpenDir (const char* path, Bit16u& id); + bool ReadDir (Bit16u id, char * &result); + + void ExpandName (char* path) {}; + char* GetExpandName (const char* path) { return (char*)path; }; + bool GetShortName (const char* fullname, char* shortname) { return false; }; + + void CacheOut (const char* path, bool ignoreLastDir = false) {}; + void AddEntry (const char* path, bool checkExists = false) {}; + void DeleteEntry (const char* path, bool ignoreLastDir = false) {}; + + void SetCurrentEntry (Bit16u entry) {}; + Bit16u GetCurrentEntry (void) { return 0; }; + + void EmptyCache (void) {}; + +public: + char basePath [CROSS_LEN]; + char dirPath [CROSS_LEN]; + DIR* srch_opendir; +}; + class DOS_Drive { public: DOS_Drive(); @@ -97,9 +209,12 @@ public: virtual bool FileStat(const char* name, FileStat_Block * const stat_block)=0; virtual Bit8u GetMediaByte(void)=0; virtual void SetDir(const char* path) { strcpy(curdir,path); }; + virtual void EmptyCache(void) { dirCache.EmptyCache(); }; char * GetInfo(void); char curdir[DOS_PATHLENGTH]; char info[256]; + + DOS_Drive_Cache dirCache; }; enum { OPEN_READ=0,OPEN_WRITE=1,OPEN_READWRITE=2 }; diff --git a/src/dos/drives.h b/src/dos/drives.h index 23ba9b7c..db882261 100644 --- a/src/dos/drives.h +++ b/src/dos/drives.h @@ -20,122 +20,10 @@ #define _DRIVES_H__ #include -#include -#include #include "dos_system.h" -#include "cross.h" - -#define MAX_OPENDIRS 16 bool WildFileCmp(const char * file, const char * wild); -class DOS_Drive_Cache { -public: - DOS_Drive_Cache (void); - DOS_Drive_Cache (const char* path); - ~DOS_Drive_Cache (void); - - typedef enum TDirSort { NOSORT, ALPHABETICAL, DIRALPHABETICAL, ALPHABETICALREV, DIRALPHABETICALREV }; - - void SetBaseDir (const char* path); - void SetDirSort (TDirSort sort) { sortDirType = sort; }; - bool OpenDir (const char* path, Bit16u& id); - bool ReadDir (Bit16u id, char* &result); - - void ExpandName (char* path); - char* GetExpandName (const char* path); - bool GetShortName (const char* fullname, char* shortname); - - void CacheOut (const char* path, bool ignoreLastDir = false); - void AddEntry (const char* path, bool checkExist = false); - void DeleteEntry (const char* path, bool ignoreLastDir = false); - - void EmptyCache (void); - - class CFileInfo { - public: - ~CFileInfo(void) { - for (Bit32u i=0; i fileList; - std::vector longNameList; - std::vector outputList; - }; - -private: - - bool RemoveTrailingDot (char* shortname); - Bit16s GetLongName (CFileInfo* info, char* shortname); - void CreateShortName (CFileInfo* dir, CFileInfo* info); - Bit16u CreateShortNameID (CFileInfo* dir, const char* name); - bool SetResult (CFileInfo* dir, char * &result, Bit16u entryNr); - bool IsCachedIn (CFileInfo* dir); - CFileInfo* FindDirInfo (const char* path, char* expandedPath); - bool RemoveSpaces (char* str); - bool OpenDir (CFileInfo* dir, char* path, Bit16u& id); - void CreateEntry (CFileInfo* dir, const char* name); - Bit16u GetFreeID (CFileInfo* dir); - void Clear (void); - - - CFileInfo* dirBase; - char dirPath [CROSS_LEN]; - char basePath [CROSS_LEN]; - bool dirFirstTime; - TDirSort sortDirType; - CFileInfo* save_dir; - char save_path [CROSS_LEN]; - char save_expanded [CROSS_LEN]; - - Bit16u srchNr; - CFileInfo* dirSearch [MAX_OPENDIRS]; - char dirSearchName [MAX_OPENDIRS]; - bool free [MAX_OPENDIRS]; - -}; - -class DOS_No_Drive_Cache { -public: - DOS_No_Drive_Cache (void) {}; - DOS_No_Drive_Cache (const char* path); - ~DOS_No_Drive_Cache (void) {}; - - typedef enum TDirSort { NOSORT, ALPHABETICAL, DIRALPHABETICAL, ALPHABETICALREV, DIRALPHABETICALREV }; - - void SetBaseDir (const char* path); - void SetDirSort (TDirSort sort) {}; - bool OpenDir (const char* path, Bit16u& id); - bool ReadDir (Bit16u id, char * &result); - - void ExpandName (char* path) {}; - char* GetExpandName (const char* path) { return (char*)path; }; - bool GetShortName (const char* fullname, char* shortname) { return false; }; - - void CacheOut (const char* path, bool ignoreLastDir = false) {}; - void AddEntry (const char* path, bool checkExists = false) {}; - void DeleteEntry (const char* path, bool ignoreLastDir = false) {}; - - void SetCurrentEntry (Bit16u entry) {}; - Bit16u GetCurrentEntry (void) { return 0; }; - - void EmptyCache (void) {}; - -public: - char basePath [CROSS_LEN]; - char dirPath [CROSS_LEN]; - DIR* srch_opendir; -}; - class localDrive : public DOS_Drive { public: localDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid); @@ -154,8 +42,6 @@ public: virtual bool FileStat(const char* name, FileStat_Block * const stat_block); virtual Bit8u GetMediaByte(void); - DOS_Drive_Cache dirCache; - private: char basedir[CROSS_LEN];