////////////////////////////////////////////////////////////////////////////////
// MechWarrior II database.mw2 file system
// Copyright Bjoern Ganster 2007, 2008
////////////////////////////////////////////////////////////////////////////////

#ifndef Database_MW2__H
#define Database_MW2__H

#include "Archive.h"
#include "FileCache.h"

////////////////////////////////////////////////////////////////////////////////

class Database_MW2: public MWArchive {
public:
   // Constructor
   Database_MW2();

   // Destructor
   ~Database_MW2() OVERRIDE;

   // Open file
   bool open (const PathChar* PRJFN, bool readOnly = true) OVERRIDE;

   // Close file
   virtual void close();

   // Get name of entry
   bool getEntryName (size_t index, BGCPString& name) OVERRIDE;

   // Replace  file
   virtual bool replaceFile (size_t fileNum, const PathChar* srcFN);

   // Check if archive type supports file replacement
   virtual bool replaceFilePossible () const
   { return true; }

	// Read bufSize bytes from file numbered index at offset into buf
	bool getFileChunk(size_t index, size_t offset, void* buf, size_t bufSize) OVERRIDE;

private:
	FileCache fc;

	// Calculate file sizes from offset differences
	void calculateFileSizesFromOffsetDifferences();
};

#endif
