filecache.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef FILECACHE_HEADER
  18. #define FILECACHE_HEADER
  19. #include <string>
  20. #include <iostream>
  21. class FileCache
  22. {
  23. public:
  24. /*
  25. 'dir' is the file cache directory to use.
  26. */
  27. FileCache(std::string dir):
  28. m_dir(dir)
  29. {
  30. }
  31. bool update(const std::string &name, const std::string &data);
  32. bool load(const std::string &name, std::ostream &os);
  33. private:
  34. std::string m_dir;
  35. bool loadByPath(const std::string &path, std::ostream &os);
  36. bool updateByPath(const std::string &path, const std::string &data);
  37. };
  38. #endif