Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
filecache.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4Copyright (C) 2013 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation; either version 2.1 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License along
17with this program; if not, write to the Free Software Foundation, Inc.,
1851 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#pragma once
22
23#include <iostream>
24#include <string>
25#include <string_view>
26
28{
29public:
30 /*
31 'dir' is the file cache directory to use.
32 */
33 FileCache(const std::string &dir) : m_dir(dir) {}
34
35 bool update(const std::string &name, std::string_view data);
36 bool load(const std::string &name, std::ostream &os);
37 bool exists(const std::string &name);
38
39 // Copy another file on disk into the cache
40 bool updateCopyFile(const std::string &name, const std::string &src_path);
41
42private:
43 std::string m_dir;
44
45 void createDir();
46 bool loadByPath(const std::string &path, std::ostream &os);
47 bool updateByPath(const std::string &path, std::string_view data);
48};
static v2f dir(const v2f &pos_dist)
Definition: camera.cpp:204
Definition: filecache.h:28
bool exists(const std::string &name)
Definition: filecache.cpp:101
bool updateCopyFile(const std::string &name, const std::string &src_path)
Definition: filecache.cpp:108
void createDir()
Definition: filecache.cpp:31
bool update(const std::string &name, std::string_view data)
Definition: filecache.cpp:89
bool updateByPath(const std::string &path, std::string_view data)
Definition: filecache.cpp:70
FileCache(const std::string &dir)
Definition: filecache.h:33
bool load(const std::string &name, std::ostream &os)
Definition: filecache.cpp:95
bool loadByPath(const std::string &path, std::ostream &os)
Definition: filecache.cpp:39
std::string m_dir
Definition: filecache.h:43