FileSystem.cpp 746 B

123456789101112131415161718192021222324252627
  1. // filesystem includes
  2. #include "FileSystem.h"
  3. // engine includes
  4. #include "../Irrlicht/Irrlicht.h"
  5. namespace WallpaperEngine::FileSystem
  6. {
  7. std::string loadFullFile (irr::io::path file)
  8. {
  9. irr::io::IReadFile* reader = WallpaperEngine::Irrlicht::device->getFileSystem ()->createAndOpenFile (file);
  10. if (reader == NULL)
  11. throw std::runtime_error ("Cannot open file " + std::string (file.c_str ()) + " for reading");
  12. char* filedata = new char [reader->getSize () + 1];
  13. memset (filedata, 0, reader->getSize () + 1);
  14. reader->read (filedata, reader->getSize ());
  15. reader->drop ();
  16. std::string content = filedata;
  17. delete [] filedata;
  18. return content;
  19. }
  20. };