linux-wallpaperengine/WallpaperEngine/FileSystem/utils.cpp
Alexis Maiquez 69724adfdc ~ More class name changes and namespace modifictions (fs and irr)
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
2019-08-16 14:56:16 +02:00

27 lines
741 B
C++

// filesystem includes
#include "utils.h"
// engine includes
#include "../Irrlicht/Irrlicht.h"
namespace WallpaperEngine::FileSystem
{
std::string loadFullFile (irr::io::path file)
{
irr::io::IReadFile* reader = WallpaperEngine::Irrlicht::device->getFileSystem ()->createAndOpenFile (file);
if (reader == NULL)
throw std::runtime_error ("Cannot open file " + std::string (file.c_str ()) + " for reading");
char* filedata = new char [reader->getSize () + 1];
memset (filedata, 0, reader->getSize () + 1);
reader->read (filedata, reader->getSize ());
reader->drop ();
std::string content = filedata;
delete [] filedata;
return content;
}
};