/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__NIOARCHIVE__
#define	__NIOARCHIVE__


		#include "archive/archive.h"
		#include "container/narray.h"


namespace GS {
	namespace IO {

//
struct	ArchiveHandle : public Handle
{
		size_t		cursor;
		Array <char> data;

		ArchiveHandle(Base *io) : Handle(io), cursor(0) {}
};

/*!
	@short	I/O Archive
	@author	Emmanuel Julien (ejulien@nworks.fr)
*/
class	Archive : public Base
{
		GS::Archive	archive;
		bool		connected;

public:

virtual	uint		GetCaps() const;

virtual	Handle		*Open(const char *, Mode = ModeRead);
virtual	void		Close(Handle *);

virtual	bool		Delete(const char *);

virtual	size_t		Tell(Handle *);
virtual	size_t		Seek(Handle *, ptrdiff_t offset, SeekRef = SeekCurrent);

virtual	size_t		Read(Handle *, void *, size_t);
virtual	size_t		Write(Handle *, const void *, size_t);

virtual	bool		MkDir(const char *) { return false; }

		bool		IsConnected() const { return connected; }

		Archive(const char *uri, const char *index_uri = 0);
};

	} // IO
} // GS


#endif	// __NIOARCHIVE__
