use original GetLongName code when LFN not enabled

This commit is contained in:
Wengier
2021-04-28 06:48:56 -04:00
parent 4340e6415a
commit 427fd343cd

View File

@@ -530,13 +530,28 @@ Bits DOS_Drive_Cache::GetLongName(CFileInfo* curDir, char* shortName) {
RemoveTrailingDot(shortName);
// Search long name and return array number of element
Bits res;
if (strlen(shortName))
for (Bitu i=0; i<filelist_size; i++) {
if (!strcasecmp(shortName,curDir->fileList[i]->orgname) || !strcasecmp(shortName,curDir->fileList[i]->shortname)) {
strcpy(shortName,curDir->fileList[i]->orgname);
return (Bits)i;
}
}
if (!uselfn) {
Bits low = 0;
Bits high = (Bits)(filelist_size-1);
Bits mid;
while (low<=high) {
mid = (low+high)/2;
res = strcmp(shortName,curDir->fileList[mid]->shortname);
if (res>0) low = mid+1; else
if (res<0) high = mid-1; else
{ // Found
strcpy(shortName,curDir->fileList[mid]->orgname);
return mid;
};
}
} else if (strlen(shortName)) {
for (Bitu i=0; i<filelist_size; i++) {
if (!strcasecmp(shortName,curDir->fileList[i]->orgname) || !strcasecmp(shortName,curDir->fileList[i]->shortname)) {
strcpy(shortName,curDir->fileList[i]->orgname);
return (Bits)i;
}
}
}
#ifdef WINE_DRIVE_SUPPORT
if (strlen(shortName) < 8 || shortName[4] != '~' || shortName[5] == '.' || shortName[6] == '.' || shortName[7] == '.') return -1; // not available