1
0
Fork 0

drivecache removes trailing dot, if no extension is available (linux compatibility)

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@758
This commit is contained in:
Ulf Wohlers 2003-03-13 10:16:59 +00:00
parent 7ea6fa09f9
commit 469013e618
2 changed files with 20 additions and 3 deletions

View file

@ -279,8 +279,23 @@ Bit16u DOS_Drive_Cache::CreateShortNameID(CFileInfo* curDir, const char* name)
return foundNr+1;
};
bool DOS_Drive_Cache::RemoveTrailingDot(char* shortname)
// remove trailing '.' if no extension is available (Linux compatibility)
{
Bitu len = strlen(shortname);
if (len && (shortname[len-1]=='.')) {
if (len==1) return false;
if ((len==2) && (shortname[0]=='.')) return false;
shortname[len-1] = 0;
return true;
}
return false;
};
Bit16s DOS_Drive_Cache::GetLongName(CFileInfo* curDir, char* shortName)
{
// Remove dot, if no extension...
RemoveTrailingDot(shortName);
// Search long name and return array number of element
Bit16s low = 0;
Bit16s high = curDir->fileList.size()-1;
@ -381,6 +396,7 @@ void DOS_Drive_Cache::CreateShortName(CFileInfo* curDir, CFileInfo* info)
} else {
strcpy(info->shortname,tmpName);
}
RemoveTrailingDot(info->shortname);
};
DOS_Drive_Cache::CFileInfo* DOS_Drive_Cache::FindDirInfo(const char* path, char* expandedPath)

View file

@ -63,9 +63,9 @@ public:
char orgname [CROSS_LEN];
char shortname [DOS_NAMELENGTH_ASCII];
bool isDir;
Bit16u nextEntry;
Bit16u shortNr;
Bit16u compareCount;
Bitu nextEntry;
Bitu shortNr;
Bitu compareCount;
// contents
std::vector<CFileInfo*> fileList;
std::vector<CFileInfo*> longNameList;
@ -74,6 +74,7 @@ public:
private:
bool RemoveTrailingDot (char* shortname);
Bit16s GetLongName (CFileInfo* info, char* shortname);
void CreateShortName (CFileInfo* dir, CFileInfo* info);
Bit16u CreateShortNameID (CFileInfo* dir, const char* name);