/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     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: include/drivers/wintel32/filesystem/win32disc.hpp

*/

#ifndef SGX_WIN32_DISC_H
#define SGX_WIN32_DISC_H

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 tBOOL close(CSGXDeviceBlockState *pState);
    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);

private:
    sgxString   m_Root;
	tBOOL		m_bReadOnly;

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


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 tMEM_SIZE		read(tBYTE *pDest, tMEM_SIZE size);
    virtual tMEM_SIZE		write(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 // SGX_WIN32_DISC_H
