diff options
author | Paul Gilbert | 2011-06-26 17:53:55 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-06-26 17:53:55 +1000 |
commit | fe9dc10964ab4dc4528cc473ef841709732fceff (patch) | |
tree | 9e4af910f13a2537a19e3237e8399365cb70c223 /engines/cge/vol.cpp | |
parent | a307d405b6ddf4cb94d57e8365327667a6291bac (diff) | |
download | scummvm-rg350-fe9dc10964ab4dc4528cc473ef841709732fceff.tar.gz scummvm-rg350-fe9dc10964ab4dc4528cc473ef841709732fceff.tar.bz2 scummvm-rg350-fe9dc10964ab4dc4528cc473ef841709732fceff.zip |
CGE: Implemented basic file access functionality
Diffstat (limited to 'engines/cge/vol.cpp')
-rw-r--r-- | engines/cge/vol.cpp | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 9b6489afab..c76914c003 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -34,23 +34,45 @@ namespace CGE { +DAT *VFILE::_Dat = NULL; +BTFILE *VFILE::_Cat = NULL; +VFILE *VFILE::_Recent = NULL; + +/*-----------------------------------------------------------------------*/ + +DAT::DAT(): #ifdef VOL_UPD -BTFILE VFILE::Cat(CAT_NAME, UPD, CRP); -VOLBASE DAT::File(DAT_NAME, UPD, CRP); + _File(DAT_NAME, UPD, CRP) #else -BTFILE VFILE::Cat(CAT_NAME, REA, CRP); -VOLBASE DAT::File(DAT_NAME, REA, CRP); + _File(DAT_NAME, REA, CRP) #endif -DAT VFILE::Dat; -VFILE *VFILE::Recent = NULL; +{ +} +/*-----------------------------------------------------------------------*/ + +void VFILE::init() { + _Dat = new DAT(); +#ifdef VOL_UPD + _Cat = new BTFILE(CAT_NAME, UPD, CRP); +#else + _Cat = new BTFILE(CAT_NAME, REA, CRP); +#endif + + _Recent = NULL; +} + +void VFILE::deinit() { + delete _Dat; + delete _Cat; +} VFILE::VFILE(const char *name, IOMODE mode) : IOBUF(mode) { if (mode == REA) { - if (Dat.File.Error || Cat.Error) + if (_Dat->_File.Error || _Cat->Error) error("Bad volume data"); - BT_KEYPACK *kp = Cat.Find(name); + BT_KEYPACK *kp = _Cat->Find(name); if (scumm_stricmp(kp->Key, name) != 0) Error = 1; EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; @@ -63,26 +85,26 @@ VFILE::VFILE(const char *name, IOMODE mode) VFILE::~VFILE(void) { - if (Recent == this) - Recent = NULL; + if (_Recent == this) + _Recent = NULL; } bool VFILE::Exist(const char *name) { - return scumm_stricmp(Cat.Find(name)->Key, name) == 0; + return scumm_stricmp(_Cat->Find(name)->Key, name) == 0; } void VFILE::ReadBuff(void) { - if (Recent != this) { - Dat.File.Seek(BufMark + Lim); - Recent = this; + if (_Recent != this) { + _Dat->_File.Seek(BufMark + Lim); + _Recent = this; } - BufMark = Dat.File.Mark(); + BufMark = _Dat->_File.Mark(); long n = EndMark - BufMark; if (n > IOBUF_SIZE) n = IOBUF_SIZE; - Lim = Dat.File.Read(Buff, (uint16) n); + Lim = _Dat->_File.Read(Buff, (uint16) n); Ptr = 0; } |