aboutsummaryrefslogtreecommitdiff
path: root/src/clientmap.h
Commit message (Expand)AuthorAge
* Performance of main client loop up to 2x faster In places, up to 3 times fasterCraig Robbins2014-12-07
* Add support for interlaced polarized 3d screenssapier2014-05-18
* Fix rendering glitches when far from the center of the mapNovatux2014-03-04
* Fix and improve view range tunerPerttu Ahola2013-08-03
* Migrate to STL containers/algorithms.Ilya Zhuravlev2013-03-11
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Reorganize ClientMap rendering code for a bit more performancePerttu Ahola2012-09-04
* Optimize headersPerttu Ahola2012-06-17
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* Dynamic sky, fog and cloud colors; sun and moonPerttu Ahola2012-03-18
* Move ClientMap to clientmap.{h,cpp}Perttu Ahola2012-03-16
ss="hl com">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 Lesser General Public License for more details. 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. */ #include "filecache.h" #include "network/networkprotocol.h" #include "log.h" #include "filesys.h" #include <string> #include <iostream> #include <fstream> #include <cstdlib> bool FileCache::loadByPath(const std::string &path, std::ostream &os) { std::ifstream fis(path.c_str(), std::ios_base::binary); if(!fis.good()){ verbosestream<<"FileCache: File not found in cache: " <<path<<std::endl; return false; } bool bad = false; for(;;){ char buf[1024]; fis.read(buf, 1024); std::streamsize len = fis.gcount(); os.write(buf, len); if(fis.eof()) break; if(!fis.good()){ bad = true; break; } } if(bad){ errorstream<<"FileCache: Failed to read file from cache: \"" <<path<<"\""<<std::endl; } return !bad; } bool FileCache::updateByPath(const std::string &path, const std::string &data) { std::ofstream file(path.c_str(), std::ios_base::binary | std::ios_base::trunc); if(!file.good()) { errorstream<<"FileCache: Can't write to file at " <<path<<std::endl; return false; } file.write(data.c_str(), data.length()); file.close(); return !file.fail(); } bool FileCache::update(const std::string &name, const std::string &data) { std::string path = m_dir + DIR_DELIM + name; return updateByPath(path, data); } bool FileCache::load(const std::string &name, std::ostream &os) { std::string path = m_dir + DIR_DELIM + name; return loadByPath(path, os); } bool FileCache::exists(const std::string &name) { std::string path = m_dir + DIR_DELIM + name; std::ifstream fis(path.c_str(), std::ios_base::binary); return fis.good(); }