filecache.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. Copyright (C) 2013 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. */
  17. #pragma once
  18. #include <iostream>
  19. #include <string>
  20. class FileCache
  21. {
  22. public:
  23. /*
  24. 'dir' is the file cache directory to use.
  25. */
  26. FileCache(const std::string &dir) : m_dir(dir) {}
  27. bool update(const std::string &name, const std::string &data);
  28. bool load(const std::string &name, std::ostream &os);
  29. private:
  30. std::string m_dir;
  31. bool loadByPath(const std::string &path, std::ostream &os);
  32. bool updateByPath(const std::string &path, const std::string &data);
  33. };