X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ffilecache.h;h=96e4c8ba1b6c14a6f3d0ae8dad1304390755d01b;hb=359c8f82ceaef19563d0dba67a090e8fdc2dfb71;hp=ae3fbc602b12bad7419db6d6343b415e6902263e;hpb=f801e16b787f033cea4e473d69b54fe65248a439;p=minetest.git diff --git a/src/filecache.h b/src/filecache.h index ae3fbc602..96e4c8ba1 100644 --- a/src/filecache.h +++ b/src/filecache.h @@ -1,28 +1,27 @@ /* -Minetest-c55 -Copyright (C) 2010 celeron55, Perttu Ahola -Copyright (C) 2012 Jonathan Neuschäfer +Minetest +Copyright (C) 2013 celeron55, Perttu Ahola +Copyright (C) 2013 Jonathan Neuschäfer This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +GNU Lesser General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef FILECACHE_HEADER -#define FILECACHE_HEADER +#pragma once -#include #include +#include class FileCache { @@ -30,43 +29,14 @@ class FileCache /* 'dir' is the file cache directory to use. */ - FileCache(std::string dir): - m_dir(dir) - { - } - - /* - Searches the cache for a file with a given name. - If the file is found, lookup copies it into 'os' and - returns true. Otherwise false is returned. - */ - bool loadByName(const std::string &name, std::ostream &os); - - /* - Stores a file in the cache based on its name. - Returns true on success, false otherwise. - */ - bool updateByName(const std::string &name, const std::string &data); + FileCache(const std::string &dir) : m_dir(dir) {} - /* - Loads a file based on a check sum, which may be any kind of - rather unique byte sequence. Returns true, if the file could - be written into os, false otherwise. - */ - bool loadByChecksum(const std::string &checksum, std::ostream &os); - - /* - Stores a file in the cache based on its checksum. - Returns true on success, false otherwise. - */ - bool updateByChecksum(const std::string &checksum, const std::string &data); + bool update(const std::string &name, const std::string &data); + bool load(const std::string &name, std::ostream &os); private: std::string m_dir; bool loadByPath(const std::string &path, std::ostream &os); bool updateByPath(const std::string &path, const std::string &data); - std::string getPathFromChecksum(const std::string &checksum); }; - -#endif