From 4a8f40c92d528194f5f58209df9172b4da629b5f Mon Sep 17 00:00:00 2001 From: Ulf Wohlers Date: Tue, 30 Dec 2003 23:55:47 +0000 Subject: [PATCH] added mscdex function 0f : Get directory entry Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1511 --- src/dos/dos_mscdex.cpp | 100 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/src/dos/dos_mscdex.cpp b/src/dos/dos_mscdex.cpp index 4ed099ed..cd1c8da2 100644 --- a/src/dos/dos_mscdex.cpp +++ b/src/dos/dos_mscdex.cpp @@ -109,6 +109,7 @@ public: bool GetCopyrightName (Bit16u drive, PhysPt data); bool GetAbstractName (Bit16u drive, PhysPt data); bool GetDocumentationName(Bit16u drive, PhysPt data); + bool GetDirectoryEntry (Bit16u drive, bool copyFlag, PhysPt pathname, PhysPt buffer, Bitu& error); bool ReadVTOC (Bit16u drive, Bit16u volume, PhysPt data, Bit16u& error); bool ReadSectors (Bit16u drive, Bit32u sector, Bit16u num, PhysPt data); bool ReadSectors (Bit8u subUnit, bool raw, Bit32u sector, Bit16u num, PhysPt data); @@ -128,8 +129,10 @@ public: private: + PhysPt GetDefaultBuffer (void); + Bit16u numDrives; - + typedef struct SDriveInfo { Bit8u drive; // drive letter in dosbox Bit8u physDrive; // drive letter in system @@ -142,6 +145,7 @@ private: Bit32u volumeSize; // for media change } TDriveInfo; + PhysPt defaultBuffer; TDriveInfo dinfo[MSCDEX_MAX_DRIVES]; CDROM_Interface* cdrom[MSCDEX_MAX_DRIVES]; @@ -153,13 +157,18 @@ CMscdex::CMscdex(void) { numDrives = 0; rootDriverHeaderSeg = 0; - + defaultBuffer = 0; + memset(dinfo,0,sizeof(dinfo)); for (Bit32u i=0; i0) { + index = 0; + if (!ReadSectors(GetSubUnit(drive),false,dirEntrySector,1,defBuffer)) return false; + // Get string part + foundName = false; + useName = searchPos; + searchPos = strchr(searchPos,'\\'); + if (searchPos) { *searchPos = 0; searchPos++; } + else foundComplete = true; + + do { + entryLength = mem_readb(defBuffer+index); + if (entryLength==0) break; + nameLength = mem_readb(defBuffer+index+32); + MEM_StrCopy(defBuffer+index+33,entryName,nameLength); + if (strcmp(entryName,useName)==0) { +// LOG(LOG_MISC,LOG_ERROR)("MSCDEX: Get DirEntry : Found : %s",useName); + foundName = true; + break; + } + index += entryLength; + } while (index+33<=2048); + + if (foundName) { + // TO DO : name gefunden, Daten in den Buffer kopieren + if (foundComplete) { + if (copyFlag) E_Exit("MSCDEX: GetDirEntry: Unsupported copyflag"); + // Direct copy + MEM_BlockCopy(buffer,defBuffer+index,entryLength); + error = iso ? 1:0; + return true; + } + // directory wechseln + dirEntrySector = mem_readd(defBuffer+index+2); + dirSize = mem_readd(defBuffer+index+10); + } else { + // continue search in next sector + dirSize -= 2048; + dirEntrySector++; + } + }; + error = 2; // file not found + return false; // not found +}; + bool CMscdex::GetCurrentPos(Bit8u subUnit, TMSF& pos) { if (subUnit>=numDrives) return false; @@ -863,6 +953,12 @@ static bool MSCDEX_Handler(void) case 0x150D: /* Get drives */ mscdex->GetDrives(data); return true; + case 0x150F: { // Get directory entry + Bitu error; + bool success = mscdex->GetDirectoryEntry(reg_cl,reg_ch&1,data,PhysMake(reg_si,reg_di),error); + reg_ax = error; + CALLBACK_SCF(!success); + }; return true; case 0x1510: /* Device driver request */ mscdex->SendDriverRequest(reg_cx,data); return true;