From 4bf5065a9cdaf55a6915e647e9b5de5281d6622f Mon Sep 17 00:00:00 2001 From: Jonathan Neuschäfer Date: Wed, 8 Feb 2012 11:49:24 +0100 Subject: Cache textures by checksum --- src/filecache.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 src/filecache.cpp (limited to 'src/filecache.cpp') diff --git a/src/filecache.cpp b/src/filecache.cpp new file mode 100644 index 000000000..28d6bbc80 --- /dev/null +++ b/src/filecache.cpp @@ -0,0 +1,117 @@ +/* +Minetest-c55 +Copyright (C) 2010 celeron55, Perttu Ahola +Copyright (C) 2012 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 +(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. + +You should have received a copy of the GNU 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. +*/ + +#include "filecache.h" +#include "clientserver.h" +#include "log.h" +#include "filesys.h" +#include "utility.h" +#include "hex.h" + +#include +#include + +bool FileCache::loadByPath(const std::string &name, std::ostream &os, + const std::string &path) +{ + std::ifstream fis(path.c_str(), std::ios_base::binary); + + if(!fis.good()){ + infostream<<"FileCache: File not found in cache: " + <