aboutsummaryrefslogtreecommitdiff
path: root/src/mods.h
Commit message (Expand)AuthorAge
* Remove ugly curl struct pointer from jsonFetchValue signaturesapier2014-06-19
* Pass arguments by referenceSelat2014-03-12
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Add support for modstore screenshotssapier2013-07-22
* Replace C++ mainmenu by formspec powered onesapier2013-07-02
* Optional dependencies and properly handle mod name conflicts againKahrl2013-05-03
* Migrate to STL containers/algorithms.Ilya Zhuravlev2013-03-11
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Improve behaviour for empty modpacks and when no mods at all are installed:Jürgen Doser2013-01-22
* Basic support for configuring which mods to load for each worldJürgen Doser2013-01-21
* Optimize headersPerttu Ahola2012-06-17
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* Add minetest.get_modpath(modname)Perttu Ahola2011-12-11
* Better mod loading error handlingPerttu Ahola2011-12-03
og.h" #include "filesys.h" #include <string> #include <iostream> #include <fstream> #include <stdlib.h> 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); }