From 43d7055361ab4b0ab5b6cb64a7ba8e1aa8d7ac08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Fri, 30 Jun 2006 12:47:07 +0000 Subject: [PATCH] some fixes to the fat drive handling (thanks to h-a-l9000) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2665 --- include/dos_inc.h | 9 ++++++--- src/dos/drive_fat.cpp | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/dos_inc.h b/include/dos_inc.h index 1da5cdad..931c3094 100644 --- a/include/dos_inc.h +++ b/include/dos_inc.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_inc.h,v 1.60 2006-04-21 08:50:30 qbix79 Exp $ */ +/* $Id: dos_inc.h,v 1.61 2006-06-30 12:47:06 c2woody Exp $ */ #ifndef DOSBOX_DOS_INC_H #define DOSBOX_DOS_INC_H @@ -439,8 +439,10 @@ public: void GetSearchParams(Bit8u & _sattr,char * _spattern); void GetResult(char * _name,Bit32u & _size,Bit16u & _date,Bit16u & _time,Bit8u & _attr); - void SetDirID(Bit16u entry) { sSave(sDTA,dirID,entry); }; + void SetDirID(Bit16u entry) { sSave(sDTA,dirID,entry); }; + void SetDirIDCluster(Bit16u entry) { sSave(sDTA,dirCluster,entry); }; Bit16u GetDirID(void) { return sGet(sDTA,dirID); }; + Bit16u GetDirIDCluster(void) { return sGet(sDTA,dirCluster); }; private: #ifdef _MSC_VER #pragma pack(1) @@ -451,7 +453,8 @@ private: Bit8u sext[3]; /* The Search pattern for the extenstion */ Bit8u sattr; /* The Attributes that need to be found */ Bit16u dirID; /* custom: dir-search ID for multiple searches at the same time */ - Bit8u fill[6]; + Bit16u dirCluster; /* custom (drive_fat only): cluster number for multiple searches at the same time */ + Bit8u fill[4]; Bit8u attr; Bit16u time; Bit16u date; diff --git a/src/dos/drive_fat.cpp b/src/dos/drive_fat.cpp index c7921c0f..90d168c2 100644 --- a/src/dos/drive_fat.cpp +++ b/src/dos/drive_fat.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drive_fat.cpp,v 1.16 2006-06-22 13:15:07 qbix79 Exp $ */ +/* $Id: drive_fat.cpp,v 1.17 2006-06-30 12:47:07 c2woody Exp $ */ #include #include @@ -186,6 +186,7 @@ bool fatFile::Write(Bit8u * data, Bit16u *size) { --sizedec; sizecount++; } + if(curSectOff>0 && loadedSector) myDrive->loadedDisk->Write_AbsoluteSector(currentSector, sectorBuffer); finalizeWrite: myDrive->directoryBrowse(dirCluster, &tmpentry, dirIndex); @@ -610,6 +611,9 @@ fatDrive::fatDrive(const char *sysFilename, Bit32u bytesector, Bit32u cylsector, loadedDisk->Set_Geometry(headscyl, cylinders,cylsector, bytesector); loadedDisk->Read_Sector(0,0,1,&mbrData); + + if(mbrData.magic1!= 0x55 || mbrData.magic2!= 0xaa) LOG_MSG("Possibly invalid partition table in disk image."); + startSector = 63; int m; for(m=0;m<4;m++) { @@ -621,6 +625,8 @@ fatDrive::fatDrive(const char *sysFilename, Bit32u bytesector, Bit32u cylsector, } } + if(m==4) LOG_MSG("No good partiton found in image."); + partSectOff = startSector; } else { /* Floppy disks don't have partitions */ @@ -808,6 +814,7 @@ bool fatDrive::FindFirst(char *_dir, DOS_DTA &dta,bool fcb_findfirst) { return false; } dta.SetDirID(0); + dta.SetDirIDCluster((Bit16u)(cwdDirCluster&0xffff)); return FindNextInternal(cwdDirCluster, dta, &dummyClust); } @@ -879,7 +886,7 @@ nextfile: memcpy(extension,§buf[entryoffset].entryname[8],3); trimString(&find_name[0]); trimString(&extension[0]); - if(!(sectbuf[entryoffset].attrib & DOS_ATTR_DIRECTORY)) { + if(!(sectbuf[entryoffset].attrib & DOS_ATTR_DIRECTORY) || extension[0]!=0) { strcat(find_name, "."); strcat(find_name, extension); } @@ -900,7 +907,7 @@ nextfile: bool fatDrive::FindNext(DOS_DTA &dta) { direntry dummyClust; - return FindNextInternal(cwdDirCluster, dta, &dummyClust); + return FindNextInternal(dta.GetDirIDCluster(), dta, &dummyClust); } bool fatDrive::GetFileAttr(char *name, Bit16u *attr) { @@ -919,6 +926,7 @@ bool fatDrive::GetFileAttr(char *name, Bit16u *attr) { /* Find directory entry in parent directory */ Bit32s fileidx = 2; + if (dirClust==0) fileidx = 0; // root directory while(directoryBrowse(dirClust, &fileEntry, fileidx)) { if(memcmp(&fileEntry.entryname, &pathName[0], 11) == 0) { *attr=fileEntry.attrib; @@ -1143,6 +1151,7 @@ bool fatDrive::RemoveDir(char *dir) { Bit32u filecount = 0; /* Set to 2 to skip first 2 entries, [.] and [..] */ Bit32s fileidx = 2; + if (dirClust==0) fileidx = 0; // root directory while(directoryBrowse(dummyClust, &tmpentry, fileidx)) { /* Check for non-deleted files */ if(tmpentry.entryname[0] != 0xe5) filecount++;