1// Copyright 2017 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 LIBBRILLO_POLICY_RESILIENT_POLICY_UTIL_H_
6#define LIBBRILLO_POLICY_RESILIENT_POLICY_UTIL_H_
7
8#include <map>
9#include <string>
10
11#include <base/files/file_path.h>
12#include <brillo/brillo_export.h>
13
14namespace policy {
15
16// Returns a map from policy file index to absolute path. The default policy
17// file is included at index 0 if present (despite not having an index in its
18// filename).
19BRILLO_EXPORT std::map<int, base::FilePath> GetSortedResilientPolicyFilePaths(
20    const base::FilePath& default_policy_path);
21
22// Returns the path to policy file corresponding to |index| value, based on
23// the path of the default policy given by |default_policy_path|. Doesn't check
24// the existence of the file on disk.
25BRILLO_EXPORT base::FilePath GetResilientPolicyFilePathForIndex(
26    const base::FilePath& default_policy_path,
27    int index);
28
29// Returns whether the |policy_path| file is a resilient file based on the name
30// of the file, assuming the |default_policy_path| is the path of the default
31// policy file. If successful, the |index_out| contains the index of the file as
32// deducted from the name. No parsing of file contents is done here.
33BRILLO_EXPORT bool ParseResilientPolicyFilePath(
34    const base::FilePath& policy_path,
35    const base::FilePath& default_policy_path,
36    int* index_out);
37
38}  // namespace policy
39
40#endif  // LIBBRILLO_POLICY_RESILIENT_POLICY_UTIL_H_
41