Save name and state in DOS_FILE and derived classes.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@668
This commit is contained in:
parent
ed773d7c46
commit
8fd7014110
2 changed files with 23 additions and 10 deletions
|
@ -19,6 +19,7 @@
|
|||
#ifndef DOSSYSTEM_H_
|
||||
#define DOSSYSTEM_H_
|
||||
|
||||
#include <string.h>
|
||||
#include "dosbox.h"
|
||||
|
||||
#define DOS_NAMELENGTH 12
|
||||
|
@ -48,18 +49,25 @@ class DOS_DTA;
|
|||
|
||||
class DOS_File {
|
||||
public:
|
||||
virtual ~DOS_File(){};
|
||||
virtual bool Read(Bit8u * data,Bit16u * size)=0;
|
||||
virtual bool Write(Bit8u * data,Bit16u * size)=0;
|
||||
virtual bool Seek(Bit32u * pos,Bit32u type)=0;
|
||||
virtual bool Close()=0;
|
||||
virtual Bit16u GetInformation(void)=0;
|
||||
DOS_File() { name=0; };
|
||||
virtual ~DOS_File(){};
|
||||
virtual bool Read(Bit8u * data,Bit16u * size)=0;
|
||||
virtual bool Write(Bit8u * data,Bit16u * size)=0;
|
||||
virtual bool Seek(Bit32u * pos,Bit32u type)=0;
|
||||
virtual bool Close()=0;
|
||||
virtual Bit16u GetInformation(void)=0;
|
||||
virtual void SetName(const char* _name) { if (name) delete[] name; name = new char[strlen(_name)+1]; strcpy(name,_name); }
|
||||
virtual char* GetName(void) { return name; };
|
||||
virtual bool IsOpen() { return open; };
|
||||
virtual bool IsName(const char* _name) { if (!name) return false; return strcmp(name,_name)==0; };
|
||||
Bit8u type;
|
||||
Bit32u flags;
|
||||
Bit16u time;
|
||||
Bit16u date;
|
||||
Bit16u attr;
|
||||
Bit32u size;
|
||||
bool open;
|
||||
char* name;
|
||||
/* Some Device Specific Stuff */
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
class localFile : public DOS_File {
|
||||
public:
|
||||
localFile(FILE * handle,Bit16u devinfo);
|
||||
localFile(const char* name, FILE * handle,Bit16u devinfo);
|
||||
bool Read(Bit8u * data,Bit16u * size);
|
||||
bool Write(Bit8u * data,Bit16u * size);
|
||||
bool Seek(Bit32u * pos,Bit32u type);
|
||||
|
@ -53,7 +53,7 @@ bool localDrive::FileCreate(DOS_File * * file,char * name,Bit16u attributes) {
|
|||
if (!hand) return false;
|
||||
dirCache.AddEntry(newname, true);
|
||||
/* Make the 16 bit device information */
|
||||
*file=new localFile(hand,0x202);
|
||||
*file=new localFile(name,hand,0x202);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -78,7 +78,7 @@ bool localDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags) {
|
|||
FILE * hand=fopen(newname,type);
|
||||
Bit32u err=errno;
|
||||
if (!hand) return false;
|
||||
*file=new localFile(hand,0x202);
|
||||
*file=new localFile(name,hand,0x202);
|
||||
// (*file)->SetFileName(newname);
|
||||
return true;
|
||||
};
|
||||
|
@ -346,6 +346,7 @@ bool localFile::Seek(Bit32u * pos,Bit32u type) {
|
|||
|
||||
bool localFile::Close() {
|
||||
|
||||
open=false;
|
||||
fclose(fhandle);
|
||||
return true;
|
||||
}
|
||||
|
@ -355,7 +356,7 @@ Bit16u localFile::GetInformation(void) {
|
|||
}
|
||||
|
||||
|
||||
localFile::localFile(FILE * handle,Bit16u devinfo) {
|
||||
localFile::localFile(const char* _name, FILE * handle,Bit16u devinfo) {
|
||||
fhandle=handle;
|
||||
info=devinfo;
|
||||
struct stat temp_stat;
|
||||
|
@ -370,6 +371,10 @@ localFile::localFile(FILE * handle,Bit16u devinfo) {
|
|||
size=(Bit32u)temp_stat.st_size;
|
||||
attr=DOS_ATTR_ARCHIVE;
|
||||
last_action=NONE;
|
||||
|
||||
open=true;
|
||||
name=0;
|
||||
SetName(_name);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue