commit x64 compilation from lulu cause the other branch dont seems to compile properly at home
This commit is contained in:
59
include/platform/filesystem/io_base.cpp
Normal file
59
include/platform/filesystem/io_base.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include "filesystem/io_base.h"
|
||||
#include "filesystem/io_handle.h"
|
||||
#include "memory/nauto_ptr.h"
|
||||
#include "nstring/nstring.h"
|
||||
#include "hash/nsha1.h"
|
||||
#include "log/log.h"
|
||||
|
||||
using GS::String;
|
||||
using namespace GS::IO;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Base::FileLoad(const char *uri, GS::Array <char> &buffer)
|
||||
{
|
||||
AutoPtr <Handle> h(Open(uri));
|
||||
if (h.IsNull())
|
||||
return false;
|
||||
|
||||
size_t size = h->GetSize();
|
||||
if (!buffer.Allocate(size))
|
||||
return false;
|
||||
|
||||
return asbool(h->Read(buffer.c_ptr(), size) == size);
|
||||
}
|
||||
bool Base::FileSave(const char *uri, const GS::Array <char> &buffer)
|
||||
{
|
||||
AutoPtr <Handle> h(Open(uri, ModeWrite));
|
||||
if (h.IsNull())
|
||||
return false;
|
||||
|
||||
return asbool(h->Write(buffer.c_ptr(), buffer.GetSize()) == buffer.GetSize());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Base::Exists(const char *uri)
|
||||
{
|
||||
AutoPtr <Handle> h(Open(uri, ModeRead));
|
||||
return h.IsValid();
|
||||
}
|
||||
String Base::Hash(const char *uri)
|
||||
{
|
||||
Array <char> data;
|
||||
return FileLoad(uri, data) ? SHA1::ComputeHexa(data) : String();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
String Base::MapToAbsolute(const char *uri) const
|
||||
{ return String(uri); }
|
||||
String Base::MapToRelative(const char *path) const
|
||||
{ return String(path); }
|
||||
//------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user