/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/include/sgx/filesystem/device.hpp

*/

#ifndef SGX_FILESYSTEM_DEVICE_HPP
#define SGX_FILESYSTEM_DEVICE_HPP	1

class CSGXFileEntry;
class CSGXDeviceBlock;

class CSGXDeviceBlockState
{
public:
    typedef enum { eSeekFromBegin=0, eSeekFromCurrent, eSeekFromEnd} tSeekFrom;

    virtual ~CSGXDeviceBlockState() {}

    virtual tMEM_SIZE   read(tBYTE *pDest, tMEM_SIZE size)			{ SGX_UNUSED(pDest); SGX_UNUSED(size); return 0; }
	virtual tBOOL 		readLine(sgxString &line);
    virtual tMEM_SIZE   write(const tBYTE *pDest, tMEM_SIZE size)   { SGX_UNUSED(pDest); SGX_UNUSED(size); return 0; }
    virtual tBOOL       seek(tINT32 offset, tSeekFrom from)			{ SGX_UNUSED(offset); SGX_UNUSED(from); return 0; }
    virtual tDISC_SIZE  getSeekPos() const							{ return 0; }
    virtual tDISC_SIZE  getSeekPosition() const						{ return getSeekPos(); }    
	virtual tBOOL 		isEOF()	const								{ return getSeekPos() >= getFileSize(); }

	virtual tBOOL		getFileModifiedDate(UTCDate &date) const	{ SGX_UNUSED(date); return FALSE; }
    virtual tDISC_SIZE  getFileSize() const							{ return 0; }

};

class CSGXDevice
{
public:
	CSGXDevice() {}
    virtual ~CSGXDevice() {}

    virtual tBOOL    mountDirectory(CSGXFileEntry *pEntry, const sgxString &rootmount, tBOOL recursive=FALSE) { SGX_UNUSED(pEntry); SGX_UNUSED(rootmount); SGX_UNUSED(recursive); return false; }

    virtual CSGXDeviceBlockState *open(CSGXDeviceBlock *pBlk, const sgxString &access) { SGX_UNUSED(pBlk); SGX_UNUSED(access); return false; }
    virtual tBOOL          close(CSGXDeviceBlockState *pState) { delete pState; return TRUE; }

	virtual CSGXFileEntry *addNewFile(CSGXFileEntry *pNewEntry);
	virtual CSGXFileEntry *addNewDirectory(CSGXFileEntry *pNewEntry);

    virtual CSGXFileEntry *createNewFile(CSGXFileEntry *pParentEntry, const sgxString &filename);
    virtual CSGXFileEntry *createNewDirectory(CSGXFileEntry *pParentEntry, const sgxString &dirName);

	virtual void			getRoot(sgxString &rootPath) = 0;

	virtual tBOOL			refreshFile(const sgxString &filePath);
};

#endif /* SGX_FILESYSTEM_DEVICE_HPP */
