diff --git a/include/dos_system.h b/include/dos_system.h index 594c81c9..0ef54455 100644 --- a/include/dos_system.h +++ b/include/dos_system.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_system.h,v 1.20 2004-01-12 20:25:57 finsterr Exp $ */ +/* $Id: dos_system.h,v 1.21 2004-03-04 19:49:14 qbix79 Exp $ */ #ifndef DOSSYSTEM_H_ #define DOSSYSTEM_H_ @@ -54,7 +54,7 @@ class DOS_DTA; class DOS_File { public: DOS_File():flags(0) { name=0; refCtr = 0; }; - virtual ~DOS_File(){}; + virtual ~DOS_File(){if(name) delete [] name;}; virtual bool Read(Bit8u * data,Bit16u * size)=0; virtual bool Write(Bit8u * data,Bit16u * size)=0; virtual bool Seek(Bit32u * pos,Bit32u type)=0; @@ -66,6 +66,7 @@ public: virtual bool IsName(const char* _name) { if (!name) return false; return strcmp(name,_name)==0; }; virtual void AddRef() { refCtr++; }; virtual Bits RemoveRef() { return --refCtr; }; + virtual bool UpdateDateTimeFromHost() { return true; } Bit8u type; Bit32u flags; Bit16u time; diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index a85decb5..4d313d4c 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_files.cpp,v 1.52 2004-02-02 19:20:38 qbix79 Exp $ */ +/* $Id: dos_files.cpp,v 1.53 2004-03-04 19:49:14 qbix79 Exp $ */ #include #include @@ -966,19 +966,12 @@ bool DOS_GetFileDate(Bit16u entry, Bit16u* otime, Bit16u* odate) DOS_SetError(DOSERR_INVALID_HANDLE); return false; }; - struct stat stat_block; - if (fstat(handle, &stat_block)!=0) { + if (!Files[handle]->UpdateDateTimeFromHost()) { DOS_SetError(DOSERR_INVALID_HANDLE); return false; } - struct tm *time; - if ((time=localtime(&stat_block.st_mtime))!=0) { - *otime = (time->tm_hour<<11)+(time->tm_min<<5)+(time->tm_sec/2); /* standard way. */ - *odate = ((time->tm_year-80)<<9)+((time->tm_mon+1)<<5)+(time->tm_mday); - } else { - *otime = 6; - *odate = 4; - } + *otime = Files[handle]->time; + *odate = Files[handle]->date; return true; }; diff --git a/src/dos/drive_local.cpp b/src/dos/drive_local.cpp index 9cec7b8b..a3509725 100644 --- a/src/dos/drive_local.cpp +++ b/src/dos/drive_local.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: drive_local.cpp,v 1.44 2004-01-11 16:48:32 qbix79 Exp $ */ +/* $Id: drive_local.cpp,v 1.45 2004-03-04 19:49:21 qbix79 Exp $ */ #include #include @@ -39,6 +39,7 @@ public: bool Seek(Bit32u * pos,Bit32u type); bool Close(); Bit16u GetInformation(void); + bool UpdateDateTimeFromHost(void); private: FILE * fhandle; enum { NONE,READ,WRITE } last_action; @@ -437,6 +438,21 @@ localFile::localFile(const char* _name, FILE * handle,Bit16u devinfo) { SetName(_name); } +bool localFile::UpdateDateTimeFromHost(void) { + if(!open) return false; + struct stat temp_stat; + fstat(fileno(fhandle),&temp_stat); + struct tm * ltime; + if((ltime=localtime(&temp_stat.st_mtime))!=0) { + time=DOS_PackTime(ltime->tm_hour,ltime->tm_min,ltime->tm_sec); + date=DOS_PackDate(ltime->tm_year+1900,ltime->tm_mon+1,ltime->tm_mday); + } else { + time=1;date=1; + } + return true; +} + + // ******************************************** // CDROM DRIVE // ********************************************