Removed dta check from findfirst in drive_cache.
Caching now 2048 searches per drive. Clearing all when full. Changed dta to reflect specs better. Changed fcb to reflect specs better. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1766
This commit is contained in:
parent
5e144aa1d6
commit
ed0fa42631
4 changed files with 48 additions and 51 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_inc.h,v 1.39 2004-04-03 19:19:29 canadacow Exp $ */
|
||||
/* $Id: dos_inc.h,v 1.40 2004-04-13 12:08:43 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOS_H_
|
||||
#define DOS_H_
|
||||
|
@ -428,9 +428,9 @@ private:
|
|||
#endif
|
||||
struct sDTA {
|
||||
Bit8u sdrive; /* The Drive the search is taking place */
|
||||
Bit8u sattr; /* The Attributes that need to be found */
|
||||
Bit8u sname[8]; /* The Search pattern for the filename */
|
||||
Bit8u sext[3]; /* The Search pattern for the extenstion */
|
||||
Bit8u sattr; /* The Attributes that need to be found */
|
||||
Bit16u dirID; /* custom: dir-search ID for multiple searches at the same time */
|
||||
Bit8u fill[6];
|
||||
Bit8u attr;
|
||||
|
@ -477,8 +477,11 @@ private:
|
|||
Bit16u date;
|
||||
Bit16u time;
|
||||
/* Reserved Block should be 8 bytes */
|
||||
Bit8u sft_entries;
|
||||
Bit8u share_attributes;
|
||||
Bit8u extra_info;
|
||||
Bit8u file_handle;
|
||||
Bit8u reserved[7];
|
||||
Bit8u reserved[4];
|
||||
/* end */
|
||||
Bit8u cur_rec; /* Current record in current block */
|
||||
Bit32u rndm; /* Current relative record number */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_system.h,v 1.21 2004-03-04 19:49:14 qbix79 Exp $ */
|
||||
/* $Id: dos_system.h,v 1.22 2004-04-13 12:08:43 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOSSYSTEM_H_
|
||||
#define DOSSYSTEM_H_
|
||||
|
@ -86,8 +86,8 @@ public:
|
|||
Bit8u fhandle;
|
||||
};
|
||||
|
||||
#define MAX_OPENDIRS 16
|
||||
|
||||
#define MAX_OPENDIRS 2048
|
||||
//Can be high as it's only storage (16 bit variable)
|
||||
class DOS_Drive_Cache {
|
||||
public:
|
||||
DOS_Drive_Cache (void);
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
char* GetExpandName (const char* path);
|
||||
bool GetShortName (const char* fullname, char* shortname);
|
||||
|
||||
bool FindFirst (char* path, Bitu dtaAddress, Bitu& id);
|
||||
bool FindFirst (char* path, Bitu& id);
|
||||
bool FindNext (Bitu id, char* &result);
|
||||
|
||||
void CacheOut (const char* path, bool ignoreLastDir = false);
|
||||
|
@ -120,21 +120,19 @@ public:
|
|||
public:
|
||||
CFileInfo(void) {
|
||||
orgname[0] = shortname[0] = 0;
|
||||
nextEntry = shortNr = compareCount = 0;
|
||||
nextEntry = shortNr = 0;
|
||||
isDir = false;
|
||||
}
|
||||
~CFileInfo(void) {
|
||||
for (Bit32u i=0; i<fileList.size(); i++) delete fileList[i];
|
||||
fileList.clear();
|
||||
longNameList.clear();
|
||||
compareCount = 0;
|
||||
};
|
||||
char orgname [CROSS_LEN];
|
||||
char shortname [DOS_NAMELENGTH_ASCII];
|
||||
bool isDir;
|
||||
Bitu nextEntry;
|
||||
Bitu shortNr;
|
||||
Bitu compareCount;
|
||||
// contents
|
||||
std::vector<CFileInfo*> fileList;
|
||||
std::vector<CFileInfo*> longNameList;
|
||||
|
@ -143,18 +141,18 @@ public:
|
|||
private:
|
||||
|
||||
bool RemoveTrailingDot (char* shortname);
|
||||
Bits GetLongName (CFileInfo* info, char* shortname);
|
||||
Bits GetLongName (CFileInfo* info, char* shortname);
|
||||
void CreateShortName (CFileInfo* dir, CFileInfo* info);
|
||||
Bit16u CreateShortNameID (CFileInfo* dir, const char* name);
|
||||
int CompareShortname (const char* compareName, const char* shortName);
|
||||
bool SetResult (CFileInfo* dir, char * &result, Bit16u entryNr);
|
||||
bool IsCachedIn (CFileInfo* dir);
|
||||
CFileInfo* FindDirInfo (const char* path, char* expandedPath);
|
||||
int CompareShortname (const char* compareName, const char* shortName);
|
||||
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, const char* path, Bit16u& id);
|
||||
void CreateEntry (CFileInfo* dir, const char* name);
|
||||
Bit16u GetFreeID (CFileInfo* dir);
|
||||
void Clear (void);
|
||||
bool OpenDir (CFileInfo* dir, const char* path, Bit16u& id);
|
||||
void CreateEntry (CFileInfo* dir, const char* name);
|
||||
Bit16u GetFreeID (CFileInfo* dir);
|
||||
void Clear (void);
|
||||
|
||||
CFileInfo* dirBase;
|
||||
char dirPath [CROSS_LEN];
|
||||
|
@ -170,6 +168,7 @@ private:
|
|||
char dirSearchName [MAX_OPENDIRS];
|
||||
bool free [MAX_OPENDIRS];
|
||||
CFileInfo* dirFindFirst [MAX_OPENDIRS];
|
||||
Bitu nextFreeFindFirst;
|
||||
|
||||
char label [CROSS_LEN];
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: drive_cache.cpp,v 1.33 2004-03-03 12:40:59 qbix79 Exp $ */
|
||||
/* $Id: drive_cache.cpp,v 1.34 2004-04-13 12:08:43 qbix79 Exp $ */
|
||||
|
||||
#include "drives.h"
|
||||
#include "dos_inc.h"
|
||||
|
@ -62,20 +62,22 @@ bool SortByDirNameRev(DOS_Drive_Cache::CFileInfo* const &a, DOS_Drive_Cache::CFi
|
|||
|
||||
DOS_Drive_Cache::DOS_Drive_Cache(void)
|
||||
{
|
||||
dirBase = new CFileInfo;
|
||||
save_dir = 0;
|
||||
srchNr = 0;
|
||||
label[0] = 0;
|
||||
dirBase = new CFileInfo;
|
||||
save_dir = 0;
|
||||
srchNr = 0;
|
||||
label[0] = 0;
|
||||
nextFreeFindFirst = 0;
|
||||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) { dirSearch[i] = 0; free[i] = true; dirFindFirst[i] = 0; };
|
||||
SetDirSort(DIRALPHABETICAL);
|
||||
};
|
||||
|
||||
DOS_Drive_Cache::DOS_Drive_Cache(const char* path)
|
||||
{
|
||||
dirBase = new CFileInfo;
|
||||
save_dir = 0;
|
||||
srchNr = 0;
|
||||
label[0] = 0;
|
||||
dirBase = new CFileInfo;
|
||||
save_dir = 0;
|
||||
srchNr = 0;
|
||||
label[0] = 0;
|
||||
nextFreeFindFirst = 0;
|
||||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) { dirSearch[i] = 0; free[i] = true; dirFindFirst[i] = 0; };
|
||||
SetDirSort(DIRALPHABETICAL);
|
||||
SetBaseDir(path);
|
||||
|
@ -90,6 +92,7 @@ DOS_Drive_Cache::~DOS_Drive_Cache(void)
|
|||
void DOS_Drive_Cache::Clear(void)
|
||||
{
|
||||
delete dirBase; dirBase = 0;
|
||||
nextFreeFindFirst = 0;
|
||||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) dirSearch[i] = 0;
|
||||
};
|
||||
|
||||
|
@ -431,8 +434,6 @@ void DOS_Drive_Cache::CreateShortName(CFileInfo* curDir, CFileInfo* info)
|
|||
// Copy number
|
||||
strcat(info->shortname,"~");
|
||||
strcat(info->shortname,buffer);
|
||||
// Create compare Count
|
||||
// info->compareCount = tocopy;
|
||||
// Add (and cut) Extension, if available
|
||||
if (pos) {
|
||||
// Step to last extension...
|
||||
|
@ -635,35 +636,29 @@ bool DOS_Drive_Cache::SetResult(CFileInfo* dir, char* &result, Bit16u entryNr)
|
|||
};
|
||||
|
||||
// FindFirst / FindNext
|
||||
bool DOS_Drive_Cache::FindFirst(char* path, Bitu dtaAddress, Bitu& id)
|
||||
bool DOS_Drive_Cache::FindFirst(char* path, Bitu& id)
|
||||
{
|
||||
Bit16u dirID;
|
||||
Bitu dirFindFirstID = 0xffff;
|
||||
Bitu dirFindFirstID = this->nextFreeFindFirst++; //increase it for the next search
|
||||
|
||||
// Cache directory in
|
||||
if (!OpenDir(path,dirID)) return false;
|
||||
// Seacrh if dta was already used before
|
||||
for (Bitu n=0; n<MAX_OPENDIRS; n++) {
|
||||
if (dirFindFirst[n]) {
|
||||
if (dirFindFirst[n]->compareCount == dtaAddress) {
|
||||
// Reuse old dta
|
||||
dirFindFirstID = n; break;
|
||||
}
|
||||
} else if (dirFindFirstID==0xffff) {
|
||||
dirFindFirstID = n;
|
||||
}
|
||||
}
|
||||
if (dirFindFirstID==0xffff) {
|
||||
|
||||
if (dirFindFirstID == MAX_OPENDIRS) {
|
||||
// no free slot found...
|
||||
LOG(LOG_MISC,LOG_ERROR)("DIRCACHE: FindFirst/Next failure : All slots full.");
|
||||
// always use first then
|
||||
LOG(LOG_MISC,LOG_ERROR)("DIRCACHE: FindFirst/Next: All slots full. Resetting");
|
||||
// Clear the internal list then.
|
||||
dirFindFirstID = 0;
|
||||
this->nextFreeFindFirst = 1; //the next free one after this search
|
||||
for(Bitu n=0; n<MAX_OPENDIRS;n++) {
|
||||
// Clear and reuse slot
|
||||
delete dirFindFirst[n];
|
||||
dirFindFirst[n]=0;
|
||||
}
|
||||
|
||||
}
|
||||
// Clear and reuse slot
|
||||
delete dirFindFirst[dirFindFirstID];
|
||||
dirFindFirst[dirFindFirstID] = new CFileInfo();
|
||||
dirFindFirst[dirFindFirstID]-> nextEntry = 0;
|
||||
dirFindFirst[dirFindFirstID]-> compareCount = dtaAddress;
|
||||
|
||||
// Copy entries to use with FindNext
|
||||
for (Bitu i=0; i<dirSearch[dirID]->fileList.size(); i++) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: drive_local.cpp,v 1.46 2004-04-03 19:23:06 canadacow Exp $ */
|
||||
/* $Id: drive_local.cpp,v 1.47 2004-04-13 12:08:43 qbix79 Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -142,7 +142,7 @@ bool localDrive::FindFirst(char * _dir,DOS_DTA & dta) {
|
|||
if (tempDir[strlen(tempDir)-1]!=CROSS_FILESPLIT) strcat(tempDir,end);
|
||||
|
||||
Bitu id;
|
||||
if (!dirCache.FindFirst(tempDir,(Bitu)dos.dta,id))
|
||||
if (!dirCache.FindFirst(tempDir,id))
|
||||
{
|
||||
DOS_SetError(DOSERR_PATH_NOT_FOUND);
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue