#ifndef GAMEFS_INCLUDE_H
#define GAMEFS_INCLUDE_H

#define MAX_FILES_POINTERS 10

#include <stdio.h>
#include "PFrogConsole.h"
#include <PocketFrog/PocketFrog.h>

using namespace Frog;

class GameFileSystem
{
private:
	// puntatori di puntatori a files
	FILE **fp;

	unsigned short numAllocatedFp;
	bool fpInit[MAX_FILES_POINTERS];
	
	bool _mFileExists(const char *filename, bool deleteme);

public:
	GameFileSystem(void);
	~GameFileSystem(void);
	// apre file nel primo slot disponibile, torna l'handle o NULL
	// se non puņ aprirlo o non abbiamo altri puntatori
	int OpenFile(const char *filename, const char *mode, bool open_from_ext_res);
	bool CloseFile(int index);

	bool Exists(const char *filename);
	bool Delete(const char *filename);

	// come le funzioni C
	int FSeek(int index, int whence, long offset);
	long FTell(int index);

	int ReadBytes(int index, char *dest, int numbytes);
	int WriteBytes(int index, const char *source, int numbytes);
};

#endif
