VRS
A file format for sensor data.
Loading...
Searching...
No Matches
FileCache.h
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <memory>
20#include <string>
21
22namespace vrs {
23
24using std::string;
25
29class FileCache {
30 public:
39 static int makeFileCache(const string& app, const string& parentFolder = {});
40
42 static void disableFileCache();
43
46 static FileCache* getFileCache();
47
56 int getFile(const string& filename, string& outFilePath);
57
69 int getFile(const string& domain, const string& filename, string& outFilePath);
70
71 protected:
72 explicit FileCache(string mainFolder) : mainFolder_{std::move(mainFolder)} {}
73
74 private:
75 string mainFolder_;
76
77 static std::unique_ptr<FileCache> sFileCache;
78};
79
80} // namespace vrs
Utility class to manage various forms of file caching. Disabled by default.
Definition FileCache.h:29
static void disableFileCache()
To disable the file cache. Safe to call even if not enabled.
Definition FileCache.cpp:53
int getFile(const string &filename, string &outFilePath)
Definition FileCache.cpp:78
static FileCache * getFileCache()
Definition FileCache.cpp:57
static int makeFileCache(const string &app, const string &parentFolder={})
Definition FileCache.cpp:30
Definition AsyncDiskFileChunk.hpp:49