FileSystem.cpp 824 B

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