File: filecache.h

package info (click to toggle)
corectrl 1.4.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,420 kB
  • sloc: cpp: 40,502; ansic: 174; javascript: 151; makefile: 18; sh: 3
file content (29 lines) | stat: -rw-r--r-- 914 bytes parent folder | download | duplicates (3)
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
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright 2019 Juan Palacios <jpalaciosdev@gmail.com>

#pragma once

#include "ifilecache.h"
#include <filesystem>

class FileCache : public IFileCache
{
 public:
  FileCache(std::filesystem::path &&path) noexcept;

  void init() override;
  std::optional<std::filesystem::path> add(std::filesystem::path const &path,
                                           std::string const &name) override;
  std::optional<std::filesystem::path> add(std::vector<char> const &data,
                                           std::string const &name) override;
  void remove(std::string const &name) override;
  std::optional<std::filesystem::path>
  get(std::string const &name,
      std::filesystem::path const &defaultPath) const override;
  std::filesystem::path path() const override;

 private:
  bool cacheDirectoryExist() const;

  std::filesystem::path const path_;
};