////////////////////////////////////////////////////////////////////////////////
// ZFSF.h
// Interstate '76 file system
// Copyright Bjoern Ganster
// Developed since 2022
////////////////////////////////////////////////////////////////////////////////

#pragma once

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

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

	// Destructor
	~ZFSF() OVERRIDE;

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

	// Close file
	void close() OVERRIDE;

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

	// Get size of entry, 0: directory or error
	size_t getFileSize(size_t index) OVERRIDE;

	// Get offset of file start inside prj file
	size_t getFileOffset(size_t index) OVERRIDE;

	// 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:
	// Object used for reading data from the archive file
	FileCache mFC;

	// Table of contents for main directory
	// prefer to use native structs that are interpreted on demand over storing all data in additional data structures ...
	MemoryBlock mTOC; 
};
