Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
filecache.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4// Copyright (C) 2013 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
5
6#pragma once
7
8#include <iostream>
9#include <string>
10#include <string_view>
11
13{
14public:
15 /*
16 'dir' is the file cache directory to use.
17 */
18 FileCache(const std::string &dir) : m_dir(dir) {}
19
20 bool update(const std::string &name, std::string_view data);
21 bool load(const std::string &name, std::ostream &os);
22 bool exists(const std::string &name);
23
24 // Copy another file on disk into the cache
25 bool updateCopyFile(const std::string &name, const std::string &src_path);
26
27private:
28 std::string m_dir;
29
30 void createDir();
31 bool loadByPath(const std::string &path, std::ostream &os);
32 bool updateByPath(const std::string &path, std::string_view data);
33};
static v2f dir(const v2f &pos_dist)
Definition camera.cpp:191
Definition filecache.h:13
bool exists(const std::string &name)
Definition filecache.cpp:76
bool updateCopyFile(const std::string &name, const std::string &src_path)
Definition filecache.cpp:82
void createDir()
Definition filecache.cpp:15
bool update(const std::string &name, std::string_view data)
Definition filecache.cpp:64
bool updateByPath(const std::string &path, std::string_view data)
Definition filecache.cpp:50
FileCache(const std::string &dir)
Definition filecache.h:18
bool load(const std::string &name, std::ostream &os)
Definition filecache.cpp:70
bool loadByPath(const std::string &path, std::ostream &os)
Definition filecache.cpp:23
std::string m_dir
Definition filecache.h:28