/
file_storage.h
68 lines (50 loc) · 1.46 KB
/
file_storage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (C) 2017-2018 Egor Pugin <egor.pugin@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include "concurrent_map.h"
#include "file.h"
#include <primitives/templates.h>
namespace primitives::filesystem
{
class FileMonitor;
}
namespace sw
{
struct SwBuilderContext;
struct SW_BUILDER_API FileStorage
{
struct file_holder
{
ScopedFile f;
path fn;
file_holder(const path &fn);
~file_holder();
};
const SwBuilderContext &swctx;
String config;
bool fs_local;
ConcurrentHashMap<path, FileRecord> files;
FileStorage(const SwBuilderContext &swctx, const String &config);
FileStorage(FileStorage &&) = default;
FileStorage &operator=(FileStorage &&) = default;
~FileStorage();
void load();
void save();
void clear();
void reset();
void closeLogs();
FileRecord *registerFile(const File &f);
FileRecord *registerFile(const path &f);
void async_file_log(const FileRecord *r);
void async_command_log(size_t hash, size_t lwt, bool local);
private:
std::unique_ptr<file_holder> async_file_log_;
std::unique_ptr<file_holder> async_command_log_;
std::unique_ptr<file_holder> async_command_log_local_;
file_holder *getFileLog();
file_holder *getCommandLog(bool local);
};
}