/** 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/drivers/wintel32/filesystem/win32disc.hpp

*/

#ifndef DRIVERS_WINTEL32_FILESYSTEM_DISC_HPP
#define DRIVERS_WINTEL32_FILESYSTEM_DISC_HPP

class CSGXDeviceWin32Disc : public CSGXDevice
{
public:
    CSGXDeviceWin32Disc(const sgxString &path, const sgxString &access="rw");
    virtual ~CSGXDeviceWin32Disc() {}

    virtual tBOOL mountDirectory(CSGXFileEntry *pEntry, const sgxString &rootmount, tBOOL recursive);

    virtual CSGXDeviceBlockState *	open(CSGXDeviceBlock *pBlk, const sgxString &access);
    virtual CSGXFileEntry *			addNewFile(CSGXFileEntry *pNewEntry);
    virtual CSGXFileEntry *			addNewDirectory(CSGXFileEntry *pNewEntry);
    virtual CSGXFileEntry *			createNewDirectory(CSGXFileEntry *pParentEntry, const sgxString &dirName);
	virtual CSGXFileEntry *			createNewFile(CSGXFileEntry *pParentEntry, const sgxString &filename);
	virtual void					getRoot(sgxString &rootPath);

	virtual tBOOL					refreshFile(const sgxString &filePath);

	static void getFileModifiedDate(UTCDate &date, const FILETIME &filetime);

private:
    sgxString   m_Root;
	tBOOL		m_bReadOnly;

};


class CSGXDeviceBlockWin32Disc : public CSGXDeviceBlock
{
public:
    CSGXDeviceBlockWin32Disc(const sgxString &filename);
    //virtual tDISC_SIZE  getFileSize(CSGXDeviceBlock *pBlock) const;

    sgxString   m_Filename;
    tDISC_SIZE  m_Filesize;
};

class CSGXDeviceBlockStateWin32Disc : public CSGXDeviceBlockState
{
public:
    CSGXDeviceBlockStateWin32Disc(HANDLE hFile);
    virtual ~CSGXDeviceBlockStateWin32Disc();

    virtual tMEM_SIZE		read(tBYTE *pDest, tMEM_SIZE size);
    virtual tMEM_SIZE		write(const tBYTE *pDest, tMEM_SIZE size);
    virtual tBOOL			seek(tINT32 offset, CSGXDeviceBlockState::tSeekFrom from);
	virtual tDISC_SIZE		getFileSize() const;
	virtual tDISC_SIZE		getSeekPos() const;

    HANDLE  m_hFile;

private:
    CSGXDeviceBlockStateWin32Disc();    // no default ctor allowed
};


#endif // DRIVERS_WINTEL32_FILESYSTEM_DISC_HPP
