bool isoDrive::FindFirst(char *dir, DOS_DTA &dta, bool fcb_findfirst) { isoDirEntry de; if (!lookup(&de, dir)) { DOS_SetError(DOSERR_PATH_NOT_FOUND); return false; } // get a directory iterator and save its id in the dta int dirIterator = GetDirIterator(&de); bool isRoot = (*dir == 0); dirIterators[dirIterator].root = isRoot; dta.SetDirID((Bit16u)dirIterator); Bit8u attr; char pattern[ISO_MAXPATHNAME]; dta.GetSearchParams(attr, pattern); if (attr == DOS_ATTR_VOLUME) { dta.SetResult(discLabel, 0, 0, 0, DOS_ATTR_VOLUME); return true; } else if ((attr & DOS_ATTR_VOLUME) && isRoot && !fcb_findfirst) { if (WildFileCmp(discLabel,pattern)) { // Get Volume Label (DOS_ATTR_VOLUME) and only in basedir and if it matches the searchstring dta.SetResult(discLabel, 0, 0, 0, DOS_ATTR_VOLUME); return true; } } return FindNext(dta); }
bool localDrive::FindFirst(char * _dir,DOS_DTA & dta,bool fcb_findfirst) { char tempDir[CROSS_LEN]; strcpy(tempDir,basedir); strcat(tempDir,_dir); CROSS_FILENAME(tempDir); if (allocation.mediaid==0xF0 ) { EmptyCache(); //rescan floppie-content on each findfirst } char end[2]={CROSS_FILESPLIT,0}; if (tempDir[strlen(tempDir)-1]!=CROSS_FILESPLIT) strcat(tempDir,end); Bit16u id; if (!dirCache.FindFirst(tempDir,id)) { DOS_SetError(DOSERR_PATH_NOT_FOUND); return false; } strcpy(srchInfo[id].srch_dir,tempDir); dta.SetDirID(id); Bit8u sAttr; dta.GetSearchParams(sAttr,tempDir); if (this->isRemote() && this->isRemovable()) { // cdroms behave a bit different than regular drives if (sAttr == DOS_ATTR_VOLUME) { dta.SetResult(dirCache.GetLabel(),0,0,0,DOS_ATTR_VOLUME); return true; } } else { if (sAttr == DOS_ATTR_VOLUME) { if ( strcmp(dirCache.GetLabel(), "") == 0 ) { // LOG(LOG_DOSMISC,LOG_ERROR)("DRIVELABEL REQUESTED: none present, returned NOLABEL"); // dta.SetResult("NO_LABEL",0,0,0,DOS_ATTR_VOLUME); // return true; DOS_SetError(DOSERR_NO_MORE_FILES); return false; } dta.SetResult(dirCache.GetLabel(),0,0,0,DOS_ATTR_VOLUME); return true; } else if ((sAttr & DOS_ATTR_VOLUME) && (*_dir == 0) && !fcb_findfirst) { //should check for a valid leading directory instead of 0 //exists==true if the volume label matches the searchmask and the path is valid if (WildFileCmp(dirCache.GetLabel(),tempDir)) { dta.SetResult(dirCache.GetLabel(),0,0,0,DOS_ATTR_VOLUME); return true; } } } return FindNext(dta); }
bool physfsDrive::FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst) { char tempDir[CROSS_LEN]; strcpy(tempDir,basedir); strcat(tempDir,_dir); CROSS_FILENAME(tempDir); char end[2]={CROSS_FILESPLIT,0}; if (tempDir[strlen(tempDir)-1]!=CROSS_FILESPLIT) strcat(tempDir,end); Bit16u id; if (!dirCache.FindFirst(tempDir,id)) { DOS_SetError(DOSERR_PATH_NOT_FOUND); return false; } strcpy(srchInfo[id].srch_dir,tempDir); dta.SetDirID(id); Bit8u sAttr; dta.GetSearchParams(sAttr,tempDir); if (sAttr == DOS_ATTR_VOLUME) { if ( strcmp(dirCache.GetLabel(), "") == 0 ) { LOG(LOG_DOSMISC,LOG_ERROR)("DRIVELABEL REQUESTED: none present, returned NOLABEL"); dta.SetResult("NO_LABEL",0,0,0,DOS_ATTR_VOLUME); return true; } dta.SetResult(dirCache.GetLabel(),0,0,0,DOS_ATTR_VOLUME); return true; } else if ((sAttr & DOS_ATTR_VOLUME) && (*_dir == 0) && !fcb_findfirst) { //should check for a valid leading directory instead of 0 //exists==true if the volume label matches the searchmask and the path is valid if ( strcmp(dirCache.GetLabel(), "") == 0 ) { LOG(LOG_DOSMISC,LOG_ERROR)("DRIVELABEL REQUESTED: none present, returned NOLABEL"); dta.SetResult("NO_LABEL",0,0,0,DOS_ATTR_VOLUME); return true; } if (WildFileCmp(dirCache.GetLabel(),tempDir)) { dta.SetResult(dirCache.GetLabel(),0,0,0,DOS_ATTR_VOLUME); return true; } } return FindNext(dta); }