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


#ifndef	__NIOCFILE__
#define	__NIOCFILE__


		#include <stdio.h>
		#include "filesystem/io_handle.h"
		#include "nstring/nstring.h"


namespace GS {
	namespace IO {

//
class	CFileHandle : public Handle
{
friend	class	CFile;

		FILE		*file;

		CFileHandle(Base *);

public:

		~CFileHandle();
};

/*!
	@short	C-File I/O.
	@author	Emmanuel Julien (ejulien@nworks.fr)
*/
class	CFile : public Base
{
		String		root;

public:

		void		SetRootPath(const char *);

virtual	String		MapToAbsolute(const char *) const;
virtual	String		MapToRelative(const char *) const;

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 *);

		CFile(const char *root_path = 0);
};

	}	// IO
}	// GS


#endif	// __NIOCFILE__
