1d066c7e5Sopenharmony_ci# Configuration Policy Component
2d066c7e5Sopenharmony_ci
3d066c7e5Sopenharmony_ci## Introduction
4d066c7e5Sopenharmony_ci
5d066c7e5Sopenharmony_ciThe configuration policy component, namely, customization_config_policy, provides APIs for each service module to obtain the configuration directories at different levels or the configuration file paths.
6d066c7e5Sopenharmony_ci
7d066c7e5Sopenharmony_ci## System Architecture
8d066c7e5Sopenharmony_ci
9d066c7e5Sopenharmony_ci**Figure 1** Architecture of the configuration policy component
10d066c7e5Sopenharmony_ci
11d066c7e5Sopenharmony_ci![](figures/config_policy_en.png)
12d066c7e5Sopenharmony_ci
13d066c7e5Sopenharmony_ciThe architecture is described as follows:
14d066c7e5Sopenharmony_ci
15d066c7e5Sopenharmony_ci- **interfaces** provides the path of the file with the highest priority and all-level paths of the specified file.
16d066c7e5Sopenharmony_ci- **frameworks** initializes the configuration directory and queries the file path.
17d066c7e5Sopenharmony_ci
18d066c7e5Sopenharmony_ci## Directory Structure
19d066c7e5Sopenharmony_ci
20d066c7e5Sopenharmony_ciThe code directory structure of the configuration policy component is as follows:
21d066c7e5Sopenharmony_ci
22d066c7e5Sopenharmony_ci```
23d066c7e5Sopenharmony_ci/base/customization/
24d066c7e5Sopenharmony_ci├── config_policy           # Code repository for the configuration policy component
25d066c7e5Sopenharmony_ci│   ├── frameworks          # Core code of the configuration policy component
26d066c7e5Sopenharmony_ci│   │   ├── config_policy   # Configuration policy module
27d066c7e5Sopenharmony_ci│   │   │   └── src         # Implementation code
28d066c7e5Sopenharmony_ci│   ├── interfaces          # APIs of the configuration policy component
29d066c7e5Sopenharmony_ci│   │   ├── inner_api       # APIs for internal subsystems
30d066c7e5Sopenharmony_ci│   │   └── kits            # JavaScript APIs of the configurationpolicy component
31d066c7e5Sopenharmony_ci│   └── test                # Test code
32d066c7e5Sopenharmony_ci```
33d066c7e5Sopenharmony_ci
34d066c7e5Sopenharmony_ci## Usage
35d066c7e5Sopenharmony_ci
36d066c7e5Sopenharmony_ciCall the APIs of the configuration policy component to obtain the configuration directories at different levels or the configuration file paths.
37d066c7e5Sopenharmony_ci
38d066c7e5Sopenharmony_ci```
39d066c7e5Sopenharmony_ci#include "config_policy_utils.h"
40d066c7e5Sopenharmony_ci
41d066c7e5Sopenharmony_ciCfgDir *cfgDir = GetCfgDirList(); // Obtain the configuration directory list.
42d066c7e5Sopenharmony_ciFreeCfgDirList(cfgDir); // Release the memory after the list is obtained.
43d066c7e5Sopenharmony_ci
44d066c7e5Sopenharmony_ciconst char *cfgPath = "etc/xml/cfg.xml"; // Set the relative path and name of the configuration file.
45d066c7e5Sopenharmony_ciCfgFiles *cfgFiles = GetCfgFiles(cfgPath); // Obtain the configuration file paths of all configuration levels.
46d066c7e5Sopenharmony_ciFreeCfgFiles(cfgFiles); // Release the memory after the information is obtained.
47d066c7e5Sopenharmony_ci
48d066c7e5Sopenharmony_ciconst char *userPath = "etc/xml/user.xml"; // Set the relative path and name of the configuration file.
49d066c7e5Sopenharmony_cichar buf[MAX_PATH_LEN] = {0};
50d066c7e5Sopenharmony_cichar *filePath = GetOneCfgFile(userPath, buf, MAX_PATH_LEN); // Obtain the path of the configuration file with the highest priority.
51d066c7e5Sopenharmony_ci```
52d066c7e5Sopenharmony_ci
53d066c7e5Sopenharmony_ci## Constraints
54d066c7e5Sopenharmony_ci
55d066c7e5Sopenharmony_ci**Programming language**: C/C++
56d066c7e5Sopenharmony_ci
57d066c7e5Sopenharmony_ci## Repositories Involved
58d066c7e5Sopenharmony_ci
59d066c7e5Sopenharmony_ci**customization\_config\_policy**
60