1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-10 19:32:10 +00:00
luanti/src/client/filecache.h

34 lines
858 B
C
Raw Normal View History

// Luanti
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
// Copyright (C) 2013 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
2012-02-08 11:49:24 +01:00
#pragma once
2012-02-08 11:49:24 +01:00
#include <iostream>
#include <string>
#include <string_view>
2012-02-08 11:49:24 +01:00
class FileCache
{
public:
/*
'dir' is the file cache directory to use.
*/
FileCache(const std::string &dir) : m_dir(dir) {}
bool update(const std::string &name, std::string_view data);
bool load(const std::string &name, std::ostream &os);
bool exists(const std::string &name);
2024-01-20 16:26:05 +01:00
// Copy another file on disk into the cache
bool updateCopyFile(const std::string &name, const std::string &src_path);
2012-02-08 11:49:24 +01:00
private:
std::string m_dir;
2024-01-20 16:26:05 +01:00
void createDir();
2012-03-25 11:50:29 +03:00
bool loadByPath(const std::string &path, std::ostream &os);
bool updateByPath(const std::string &path, std::string_view data);
2012-02-08 11:49:24 +01:00
};