set sensible value for flags when creating a file (avoid false error message)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3429
This commit is contained in:
parent
4a44f76516
commit
08a74bd8e9
2 changed files with 20 additions and 24 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_files.cpp,v 1.110 2009-04-26 19:13:32 harekiet Exp $ */
|
||||
/* $Id: dos_files.cpp,v 1.111 2009-06-18 18:17:54 c2woody Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -356,9 +356,8 @@ bool DOS_ReadFile(Bit16u entry,Bit8u * data,Bit16u * amount) {
|
|||
DOS_SetError(DOSERR_INVALID_HANDLE);
|
||||
return false;
|
||||
};
|
||||
//TODO maybe another code :)
|
||||
/*
|
||||
if (!(Files[handle]->flags & OPEN_READ)) {
|
||||
if ((Files[handle]->flags & 0x0f) == OPEN_WRITE)) {
|
||||
DOS_SetError(DOSERR_INVALID_HANDLE);
|
||||
return false;
|
||||
}
|
||||
|
@ -379,9 +378,8 @@ bool DOS_WriteFile(Bit16u entry,Bit8u * data,Bit16u * amount) {
|
|||
DOS_SetError(DOSERR_INVALID_HANDLE);
|
||||
return false;
|
||||
};
|
||||
//TODO maybe another code :)
|
||||
/*
|
||||
if (!(Files[handle]->flags & OPEN_WRITE)) {
|
||||
if ((Files[handle]->flags & 0x0f) == OPEN_READ)) {
|
||||
DOS_SetError(DOSERR_INVALID_HANDLE);
|
||||
return false;
|
||||
}
|
||||
|
@ -1059,7 +1057,9 @@ Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore) {
|
|||
*/
|
||||
|
||||
DOS_FCB fcb(seg,offset);
|
||||
Bit32u random;Bit16u old_block;Bit8u old_rec;
|
||||
Bit32u random;
|
||||
Bit16u old_block=0;
|
||||
Bit8u old_rec=0;
|
||||
Bit8u error=0;
|
||||
|
||||
/* Set the correct record from the random data */
|
||||
|
@ -1082,7 +1082,9 @@ Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore) {
|
|||
Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore) {
|
||||
/* see FCB_RandomRead */
|
||||
DOS_FCB fcb(seg,offset);
|
||||
Bit32u random;Bit16u old_block;Bit8u old_rec;
|
||||
Bit32u random;
|
||||
Bit16u old_block=0;
|
||||
Bit8u old_rec=0;
|
||||
Bit8u error=0;
|
||||
|
||||
/* Set the correct record from the random data */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: drive_local.cpp,v 1.80 2009-06-13 10:43:00 c2woody Exp $ */
|
||||
/* $Id: drive_local.cpp,v 1.81 2009-06-18 18:17:54 c2woody Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -74,6 +74,7 @@ bool localDrive::FileCreate(DOS_File * * file,char * name,Bit16u /*attributes*/)
|
|||
if(!existing_file) dirCache.AddEntry(newname, true);
|
||||
/* Make the 16 bit device information */
|
||||
*file=new localFile(name,hand);
|
||||
(*file)->flags=OPEN_READWRITE;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -273,8 +274,8 @@ again:
|
|||
find_size=(Bit32u) stat_block.st_size;
|
||||
struct tm *time;
|
||||
if((time=localtime(&stat_block.st_mtime))!=0){
|
||||
find_date=DOS_PackDate(time->tm_year+1900,time->tm_mon+1,time->tm_mday);
|
||||
find_time=DOS_PackTime(time->tm_hour,time->tm_min,time->tm_sec);
|
||||
find_date=DOS_PackDate((Bit16u)(time->tm_year+1900),(Bit16u)(time->tm_mon+1),(Bit16u)time->tm_mday);
|
||||
find_time=DOS_PackTime((Bit16u)time->tm_hour,(Bit16u)time->tm_min,(Bit16u)time->tm_sec);
|
||||
} else {
|
||||
find_time=6;
|
||||
find_date=4;
|
||||
|
@ -393,8 +394,8 @@ bool localDrive::FileStat(const char* name, FileStat_Block * const stat_block) {
|
|||
/* Convert the stat to a FileStat */
|
||||
struct tm *time;
|
||||
if((time=localtime(&temp_stat.st_mtime))!=0) {
|
||||
stat_block->time=DOS_PackTime(time->tm_hour,time->tm_min,time->tm_sec);
|
||||
stat_block->date=DOS_PackDate(time->tm_year+1900,time->tm_mon+1,time->tm_mday);
|
||||
stat_block->time=DOS_PackTime((Bit16u)time->tm_hour,(Bit16u)time->tm_min,(Bit16u)time->tm_sec);
|
||||
stat_block->date=DOS_PackDate((Bit16u)(time->tm_year+1900),(Bit16u)(time->tm_mon+1),(Bit16u)time->tm_mday);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
@ -511,20 +512,13 @@ Bit16u localFile::GetInformation(void) {
|
|||
|
||||
localFile::localFile(const char* _name, FILE * handle) {
|
||||
fhandle=handle;
|
||||
struct stat temp_stat;
|
||||
fstat(fileno(handle),&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;
|
||||
}
|
||||
open=true;
|
||||
UpdateDateTimeFromHost();
|
||||
|
||||
attr=DOS_ATTR_ARCHIVE;
|
||||
last_action=NONE;
|
||||
read_only_medium=false;
|
||||
|
||||
open=true;
|
||||
name=0;
|
||||
SetName(_name);
|
||||
}
|
||||
|
@ -539,8 +533,8 @@ bool localFile::UpdateDateTimeFromHost(void) {
|
|||
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);
|
||||
time=DOS_PackTime((Bit16u)ltime->tm_hour,(Bit16u)ltime->tm_min,(Bit16u)ltime->tm_sec);
|
||||
date=DOS_PackDate((Bit16u)(ltime->tm_year+1900),(Bit16u)(ltime->tm_mon+1),(Bit16u)ltime->tm_mday);
|
||||
} else {
|
||||
time=1;date=1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue