linux-wallpaperengine/wallpaperengine/fs/utils.cpp
Alexis Maiquez cc74debaad Started rewrite of the wallpaper interpreter to aim for a more separated approach, this way the whole JSON data can be parsed and kept separeted from the actual rendering logic
# Implemented basic project file loading
  # Implemented basic camera settings loading

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
2019-08-13 17:17:08 +02:00

33 lines
855 B
C++

#include <cstdint>
#include <sys/stat.h>
// filesystem includes
#include <wallpaperengine/fs/utils.h>
// engine includes
#include <wallpaperengine/irrlicht.h>
namespace wp
{
namespace fs
{
std::string utils::loadFullFile (irr::io::path file)
{
irr::io::IReadFile* reader = wp::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;
}
}
}