mirror of
				https://github.com/kunkundi/crossdesk.git
				synced 2025-10-30 04:50:11 +08:00 
			
		
		
		
	[feat] add PathManager class in order to manage config/log/cache file path
This commit is contained in:
		
							
								
								
									
										42
									
								
								src/path_manager/path_manager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/path_manager/path_manager.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| /* | ||||
|  * @Author: DI JUNKUN | ||||
|  * @Date: 2025-07-16 | ||||
|  * Copyright (c) 2025 by DI JUNKUN, All Rights Reserved. | ||||
|  */ | ||||
|  | ||||
| #ifndef _PATH_MANAGER_H_ | ||||
| #define _PATH_MANAGER_H_ | ||||
|  | ||||
| #include <filesystem> | ||||
| #include <string> | ||||
| #ifdef _WIN32 | ||||
| #include <shlobj.h> | ||||
| #include <windows.h> | ||||
| #endif | ||||
|  | ||||
| class PathManager { | ||||
|  public: | ||||
|   explicit PathManager(const std::string& app_name); | ||||
|  | ||||
|   std::filesystem::path GetConfigPath(); | ||||
|  | ||||
|   std::filesystem::path GetCachePath(); | ||||
|  | ||||
|   std::filesystem::path GetLogPath(); | ||||
|  | ||||
|   bool CreateDirectories(const std::filesystem::path& p); | ||||
|  | ||||
|  private: | ||||
| #ifdef _WIN32 | ||||
|   std::filesystem::path GetKnownFolder(REFKNOWNFOLDERID id); | ||||
| #endif | ||||
|  | ||||
|   std::string GetHome(); | ||||
|   std::filesystem::path GetEnvOrDefault(const char* env_var, | ||||
|                                         const std::string& def); | ||||
|  | ||||
|  private: | ||||
|   std::string app_name_; | ||||
| }; | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user