aboutsummaryrefslogtreecommitdiff
path: root/assets/interlocking.html.LyXconv
diff options
context:
space:
mode:
authorywang <yw05@forksworld.de>2020-12-30 02:13:57 +0100
committerywang <yw05@forksworld.de>2020-12-30 02:13:57 +0100
commitf4d193c6d159eb907a063c0d0ea9de18325d8979 (patch)
treeba1783542fb0eb19c6ebcbda1b4c689f7434b44d /assets/interlocking.html.LyXconv
parent846e688200dd9367df29b5407a783ec39ecc5669 (diff)
downloadadvtrains-f4d193c6d159eb907a063c0d0ea9de18325d8979.tar.gz
advtrains-f4d193c6d159eb907a063c0d0ea9de18325d8979.tar.bz2
advtrains-f4d193c6d159eb907a063c0d0ea9de18325d8979.zip
Minor optimizations
Diffstat (limited to 'assets/interlocking.html.LyXconv')
0 files changed, 0 insertions, 0 deletions
">"log.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);