Added EmptyCache, removed some warnings
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@713
This commit is contained in:
parent
d70b9f3c68
commit
c2f4f360ca
2 changed files with 93 additions and 4 deletions
|
@ -73,11 +73,27 @@ DOS_Drive_Cache::DOS_Drive_Cache(const char* path)
|
|||
};
|
||||
|
||||
DOS_Drive_Cache::~DOS_Drive_Cache(void)
|
||||
{
|
||||
Clear();
|
||||
};
|
||||
|
||||
void DOS_Drive_Cache::Clear(void)
|
||||
{
|
||||
delete dirBase; dirBase = 0;
|
||||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) dirSearch[i] = 0;
|
||||
};
|
||||
|
||||
void DOS_Drive_Cache::EmptyCache(void)
|
||||
{
|
||||
// Empty Cache and reinit
|
||||
Clear();
|
||||
dirBase = new CFileInfo;
|
||||
save_dir = 0;
|
||||
srchNr = 0;
|
||||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) free[i] = true;
|
||||
SetBaseDir(basePath);
|
||||
};
|
||||
|
||||
Bit16u DOS_Drive_Cache::GetFreeID(CFileInfo* dir)
|
||||
{
|
||||
for (Bit32u i=0; i<MAX_OPENDIRS; i++) if (free[i] || (dir==dirSearch[i])) return i;
|
||||
|
@ -145,6 +161,7 @@ void DOS_Drive_Cache::AddEntry(const char* path, bool checkExists)
|
|||
case DIRALPHABETICAL : std::sort(dir->outputList.begin(), dir->outputList.end(), SortByDirName); break;
|
||||
case ALPHABETICALREV : std::sort(dir->outputList.begin(), dir->outputList.end(), SortByNameRev); break;
|
||||
case DIRALPHABETICALREV : std::sort(dir->outputList.begin(), dir->outputList.end(), SortByDirNameRev); break;
|
||||
case NOSORT : break;
|
||||
};
|
||||
|
||||
Bit16s index = GetLongName(dir,file);
|
||||
|
@ -221,7 +238,6 @@ bool DOS_Drive_Cache::GetShortName(const char* fullname, char* shortname)
|
|||
char expand[CROSS_LEN] = {0};
|
||||
CFileInfo* curDir = FindDirInfo(fullname,expand);
|
||||
|
||||
Bit16s foundNr = 0;
|
||||
Bit16s low = 0;
|
||||
Bit16s high = curDir->longNameList.size()-1;
|
||||
Bit16s mid, res;
|
||||
|
@ -288,7 +304,6 @@ bool DOS_Drive_Cache::RemoveSpaces(char* str)
|
|||
{
|
||||
char* curpos = str;
|
||||
char* chkpos = str;
|
||||
Bit16s len = -1;
|
||||
while (*chkpos!=0) {
|
||||
if (*chkpos==' ') chkpos++; else *curpos++ = *chkpos++;
|
||||
}
|
||||
|
@ -517,7 +532,7 @@ bool DOS_Drive_Cache::ReadDir(Bit16u id, struct dirent* &result)
|
|||
}
|
||||
// Read complete directory
|
||||
struct dirent* tmpres;
|
||||
while (tmpres = readdir(dirp)) {
|
||||
while ((tmpres = readdir(dirp))!=NULL) {
|
||||
CreateEntry(dirSearch[id],tmpres->d_name);
|
||||
// Sort Lists - filelist has to be alphabetically sorted, even in between (for finding double file names)
|
||||
// hmpf.. bit slow probably...
|
||||
|
@ -531,6 +546,7 @@ bool DOS_Drive_Cache::ReadDir(Bit16u id, struct dirent* &result)
|
|||
case DIRALPHABETICAL : std::sort(dirSearch[id]->outputList.begin(), dirSearch[id]->outputList.end(), SortByDirName); break;
|
||||
case ALPHABETICALREV : std::sort(dirSearch[id]->outputList.begin(), dirSearch[id]->outputList.end(), SortByNameRev); break;
|
||||
case DIRALPHABETICALREV : std::sort(dirSearch[id]->outputList.begin(), dirSearch[id]->outputList.end(), SortByDirNameRev); break;
|
||||
case NOSORT : break;
|
||||
};
|
||||
// Info
|
||||
/* if (!dirp) {
|
||||
|
|
|
@ -76,7 +76,7 @@ bool localDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags) {
|
|||
dirCache.ExpandName(newname);
|
||||
|
||||
FILE * hand=fopen(newname,type);
|
||||
Bit32u err=errno;
|
||||
// Bit32u err=errno;
|
||||
if (!hand) return false;
|
||||
*file=new localFile(name,hand,0x202);
|
||||
// (*file)->SetFileName(newname);
|
||||
|
@ -382,4 +382,77 @@ localFile::localFile(const char* _name, FILE * handle,Bit16u devinfo) {
|
|||
SetName(_name);
|
||||
}
|
||||
|
||||
// ********************************************
|
||||
// CDROM DRIVE
|
||||
// ********************************************
|
||||
|
||||
int MSCDEX_AddDrive(char driveLetter, const char* physicalPath, Bit8u& subUnit);
|
||||
bool MSCDEX_HasMediaChanged(Bit8u subUnit);
|
||||
|
||||
cdromDrive::cdromDrive(const char driveLetter, const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid, int& error)
|
||||
:localDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid)
|
||||
{
|
||||
// Init mscdex
|
||||
error = MSCDEX_AddDrive(driveLetter,startdir,subUnit);
|
||||
strcpy(info,"CDRom.");
|
||||
};
|
||||
|
||||
bool cdromDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags)
|
||||
{
|
||||
if ((flags==OPEN_READWRITE) || (flags==OPEN_WRITE)) {
|
||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
}
|
||||
return localDrive::FileOpen(file,name,flags);
|
||||
};
|
||||
|
||||
bool cdromDrive::FileCreate(DOS_File * * file,char * name,Bit16u attributes)
|
||||
{
|
||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
};
|
||||
|
||||
bool cdromDrive::FileUnlink(char * name)
|
||||
{
|
||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
};
|
||||
|
||||
bool cdromDrive::RemoveDir(char * dir)
|
||||
{
|
||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
};
|
||||
|
||||
bool cdromDrive::MakeDir(char * dir)
|
||||
{
|
||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
};
|
||||
|
||||
bool cdromDrive::Rename(char * oldname,char * newname)
|
||||
{
|
||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
};
|
||||
|
||||
bool cdromDrive::GetFileAttr(char * name,Bit16u * attr)
|
||||
{
|
||||
bool result = localDrive::GetFileAttr(name,attr);
|
||||
if (result) *attr |= DOS_ATTR_READ_ONLY;
|
||||
return result;
|
||||
};
|
||||
|
||||
bool cdromDrive::FindFirst(char * _dir,DOS_DTA & dta)
|
||||
{
|
||||
// If media has changed, reInit drivecache.
|
||||
if (MSCDEX_HasMediaChanged(subUnit)) dirCache.EmptyCache();
|
||||
return localDrive::FindFirst(_dir,dta);
|
||||
};
|
||||
|
||||
void cdromDrive::SetDir(const char* path)
|
||||
{
|
||||
// If media has changed, reInit drivecache.
|
||||
if (MSCDEX_HasMediaChanged(subUnit)) dirCache.EmptyCache();
|
||||
localDrive::SetDir(path);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue