blob: f676dec4123db3508c8f86a86f2f82ca06481083 [file] [log] [blame]
Enrico Granata60b1cbc2019-05-20 11:06:46 -07001// Copyright 2019 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef MEMS_SETUP_DELEGATE_H_
6#define MEMS_SETUP_DELEGATE_H_
7
8#include <unistd.h>
9
10#include <string>
11
12#include <base/files/file_path.h>
13#include <base/macros.h>
14#include <base/optional.h>
15
16namespace mems_setup {
17
18class Delegate {
19 public:
20 virtual ~Delegate() = default;
21
22 virtual base::Optional<std::string> ReadVpdValue(const std::string& key) = 0;
23 virtual bool ProbeKernelModule(const std::string& module) = 0;
24
Harvey Yang06ce00f2020-12-01 18:05:23 +080025 virtual bool CreateDirectory(const base::FilePath&) = 0;
Enrico Granata60b1cbc2019-05-20 11:06:46 -070026 virtual bool Exists(const base::FilePath&) = 0;
27
Enrico Granata10e19de2019-05-21 14:17:36 -070028 virtual base::Optional<gid_t> FindGroupId(const char* group) = 0;
29
30 virtual int GetPermissions(const base::FilePath& path) = 0;
31 virtual bool SetPermissions(const base::FilePath& path, int mode) = 0;
32
33 virtual bool SetOwnership(const base::FilePath& path,
34 uid_t user,
35 gid_t group) = 0;
36
Enrico Granata60b1cbc2019-05-20 11:06:46 -070037 protected:
38 Delegate() = default;
Qijiang Fan6bc59e12020-11-11 02:51:06 +090039 Delegate(const Delegate&) = delete;
40 Delegate& operator=(const Delegate&) = delete;
Enrico Granata60b1cbc2019-05-20 11:06:46 -070041};
42
43} // namespace mems_setup
44
45#endif // MEMS_SETUP_DELEGATE_H_