Page MenuHomePhorge

FileSystemSourceMemory.cpp
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

FileSystemSourceMemory.cpp

#include <echo/FileSystem/FileSystemSourceMemory.h>
#include <echo/FileSystem/FileReferenceMemory.h>
#include <iostream>
namespace Echo
{
FileSystemSourceMemory::FileSystemSourceMemory(const std::string& identifier) : FileSystemSource(identifier)
{
}
FileSystemSourceMemory::~FileSystemSourceMemory()
{
}
File FileSystemSourceMemory::_Open(const std::string& originalFileName, const std::string&, File::OpenMode openMode)
{
if(openMode!=File::OpenModes::READ)
{
return File();
}
//format is
//address:size
size_t colon=originalFileName.find_first_of(':');
size_t dataSize=0;
//cull the size portion
std::string fileAddress;
if(colon!=std::string::npos)
{
std::string dataSizeString=originalFileName.substr(colon+1);
//if(dataSize.length()>2 && dataSize.substr(0,2)=="0x")
//else
dataSize=atoi(dataSizeString.c_str());
fileAddress=originalFileName.substr(0,colon);
}else
{
fileAddress=originalFileName;
}
size_t addr=static_cast<size_t>(atol(fileAddress.c_str()));
if(addr==0)
{
ECHO_LOG_ERROR("FileSystemSourceMemory: " << fileAddress << " > 0x" << std::hex << addr << ": 0x" << dataSize << std::dec << " invalid address.");
return CreateFile(originalFileName,originalFileName);
}
ECHO_LOG_DEBUG("FileSystemSourceMemory: " << fileAddress << " > 0x" << std::hex << addr << ": 0x" << dataSize << std::dec);
return CreateFile(originalFileName,originalFileName,shared_ptr<FileReferenceMemory>(new FileReferenceMemory(*this,reinterpret_cast<void*>(addr),dataSize)));
}
}

File Metadata

Mime Type
text/x-c++
Expires
Thu, Jan 16, 1:57 AM (8 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72126
Default Alt Text
FileSystemSourceMemory.cpp (1 KB)

Event Timeline