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