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