/** 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/src/sgx/filesystem/ramfile/ramdevice.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/filesystem/filesystem.hpp"
#include "sgx/filesystem/ramfile/ramfile.hpp"

//
// Memory Device
//
CSGXDeviceMemory::CSGXDeviceMemory(tBYTE *ptr, tUINT32 size) : CSGXDevice()
{
    m_Ptr = ptr;
    m_Size = size;
}

tBOOL CSGXDeviceMemory::mountDirectory(CSGXFileEntry *pEntry, const sgxString &rootmount, tBOOL recursive)
{
SGX_UNUSED(rootmount);
SGX_UNUSED(recursive);

    pEntry->m_pBlock = new CSGXDeviceBlock();
    pEntry->m_Data.m_Filesize = m_Size;
    return true;
}

void CSGXDeviceMemory::getRoot(sgxString &rootPath) {
	rootPath = "";
}

CSGXDeviceBlockState *CSGXDeviceMemory::open(CSGXDeviceBlock *pBlk, const sgxString &access)
{
SGX_UNUSED(pBlk);
SGX_UNUSED(access);

    CSGXDeviceBlockStateMemory *pState = new CSGXDeviceBlockStateMemory;

    pState->m_CurrOffset = 0;
    pState->m_pMemDevice = this;
    return pState;
}
