Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F123507
FileSystemSourceMemory.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
FileSystemSourceMemory.cpp
View Options
#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
Details
Attached
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)
Attached To
Mode
rEE Echo 3
Attached
Detach File
Event Timeline
Log In to Comment