Fixes for not using dirent structure as a result
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@788
This commit is contained in:
parent
2f759c0050
commit
d4b640d29e
3 changed files with 26 additions and 18 deletions
|
@ -106,7 +106,7 @@ void DOS_Drive_Cache::SetBaseDir(const char* baseDir)
|
|||
Bit16u id;
|
||||
strcpy(basePath,baseDir);
|
||||
if (OpenDir(baseDir,id)) {
|
||||
struct dirent* result;
|
||||
char * result;
|
||||
ReadDir(id,result);
|
||||
};
|
||||
};
|
||||
|
@ -427,7 +427,7 @@ DOS_Drive_Cache::CFileInfo* DOS_Drive_Cache::FindDirInfo(const char* path, char*
|
|||
strcpy(work,basePath);
|
||||
if (OpenDir(curDir,work,id)) {
|
||||
char buffer[CROSS_LEN];
|
||||
struct dirent* result;
|
||||
char * result;
|
||||
strcpy(buffer,dirPath);
|
||||
ReadDir(id,result);
|
||||
strcpy(dirPath,buffer);
|
||||
|
@ -460,7 +460,7 @@ DOS_Drive_Cache::CFileInfo* DOS_Drive_Cache::FindDirInfo(const char* path, char*
|
|||
if (!IsCachedIn(curDir)) {
|
||||
if (OpenDir(curDir,work,id)) {
|
||||
char buffer[CROSS_LEN];
|
||||
struct dirent* result;
|
||||
char * result;
|
||||
strcpy(buffer,dirPath);
|
||||
ReadDir(id,result);
|
||||
strcpy(dirPath,buffer);
|
||||
|
@ -534,7 +534,7 @@ void DOS_Drive_Cache::CreateEntry(CFileInfo* dir, const char* name)
|
|||
dir->outputList.push_back(info);
|
||||
};
|
||||
|
||||
bool DOS_Drive_Cache::ReadDir(Bit16u id, struct dirent* &result)
|
||||
bool DOS_Drive_Cache::ReadDir(Bit16u id, char* &result)
|
||||
{
|
||||
// shouldnt happen...
|
||||
if (id>MAX_OPENDIRS) return false;
|
||||
|
@ -579,15 +579,15 @@ bool DOS_Drive_Cache::ReadDir(Bit16u id, struct dirent* &result)
|
|||
return false;
|
||||
};
|
||||
|
||||
bool DOS_Drive_Cache::SetResult(CFileInfo* dir, struct dirent* &result, Bit16u entryNr)
|
||||
bool DOS_Drive_Cache::SetResult(CFileInfo* dir, char* &result, Bit16u entryNr)
|
||||
{
|
||||
static struct dirent res;
|
||||
static char res[CROSS_LEN];
|
||||
|
||||
result = &res;
|
||||
result = res;
|
||||
if (entryNr>=dir->outputList.size()) return false;
|
||||
CFileInfo* info = dir->outputList[entryNr];
|
||||
// copy filename, short version
|
||||
strcpy(result->d_name,info->shortname);
|
||||
strcpy(res,info->shortname);
|
||||
// Set to next Entry
|
||||
dir->nextEntry = entryNr+1;
|
||||
return true;
|
||||
|
@ -615,10 +615,16 @@ bool DOS_No_Drive_Cache::OpenDir(const char* path, Bit16u& id)
|
|||
return true;
|
||||
};
|
||||
|
||||
bool DOS_No_Drive_Cache::ReadDir(Bit16u id, struct dirent* &result)
|
||||
bool DOS_No_Drive_Cache::ReadDir(Bit16u id, char* &result)
|
||||
{
|
||||
|
||||
static char res[CROSS_LEN];
|
||||
dirent * ent;
|
||||
|
||||
if (!srch_opendir) return false;
|
||||
if ((result=readdir(srch_opendir))==NULL) {
|
||||
if ((ent=readdir(srch_opendir))==NULL) {
|
||||
strcpy(res,ent->d_name);
|
||||
result=res;
|
||||
closedir(srch_opendir);
|
||||
srch_opendir=NULL;
|
||||
return false;
|
||||
|
|
|
@ -115,7 +115,7 @@ bool localDrive::FindFirst(char * _dir,DOS_DTA & dta) {
|
|||
|
||||
bool localDrive::FindNext(DOS_DTA & dta) {
|
||||
|
||||
struct dirent* dir_ent;
|
||||
char * dir_ent;
|
||||
struct stat stat_block;
|
||||
char full_name[CROSS_LEN];
|
||||
|
||||
|
@ -131,10 +131,10 @@ again:
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!WildFileCmp(dir_ent->d_name,srch_pattern)) goto again;
|
||||
if(!WildFileCmp(dir_ent,srch_pattern)) goto again;
|
||||
|
||||
strcpy(full_name,srchInfo[id].srch_dir);
|
||||
strcat(full_name,dir_ent->d_name);
|
||||
strcat(full_name,dir_ent);
|
||||
if (stat(dirCache.GetExpandName(full_name),&stat_block)!=0) {
|
||||
goto again;
|
||||
}
|
||||
|
@ -150,8 +150,8 @@ again:
|
|||
/*file is okay, setup everything to be copied in DTA Block */
|
||||
char find_name[DOS_NAMELENGTH_ASCII];Bit16u find_date,find_time;Bit32u find_size;
|
||||
|
||||
if(strlen(dir_ent->d_name)<DOS_NAMELENGTH_ASCII){
|
||||
strcpy(find_name,dir_ent->d_name);
|
||||
if(strlen(dir_ent)<DOS_NAMELENGTH_ASCII){
|
||||
strcpy(find_name,dir_ent);
|
||||
upcase(find_name);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
void SetBaseDir (const char* path);
|
||||
void SetDirSort (TDirSort sort) { sortDirType = sort; };
|
||||
bool OpenDir (const char* path, Bit16u& id);
|
||||
bool ReadDir (Bit16u id, struct dirent* &result);
|
||||
bool ReadDir (Bit16u id, char* &result);
|
||||
|
||||
void ExpandName (char* path);
|
||||
char* GetExpandName (const char* path);
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
Bit16s GetLongName (CFileInfo* info, char* shortname);
|
||||
void CreateShortName (CFileInfo* dir, CFileInfo* info);
|
||||
Bit16u CreateShortNameID (CFileInfo* dir, const char* name);
|
||||
bool SetResult (CFileInfo* dir, struct dirent* &result, Bit16u entryNr);
|
||||
bool SetResult (CFileInfo* dir, char * &result, Bit16u entryNr);
|
||||
bool IsCachedIn (CFileInfo* dir);
|
||||
CFileInfo* FindDirInfo (const char* path, char* expandedPath);
|
||||
bool RemoveSpaces (char* str);
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
void SetBaseDir (const char* path);
|
||||
void SetDirSort (TDirSort sort) {};
|
||||
bool OpenDir (const char* path, Bit16u& id);
|
||||
bool ReadDir (Bit16u id, struct dirent* &result);
|
||||
bool ReadDir (Bit16u id, char * &result);
|
||||
|
||||
void ExpandName (char* path) {};
|
||||
char* GetExpandName (const char* path) { return (char*)path; };
|
||||
|
@ -212,4 +212,6 @@ private:
|
|||
VFILE_Block * search_file;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue