kodi
SpecialProtocol.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <map>
12 #include <string>
13 
14 class CProfileManager;
15 
16 // static class for path translation from our special:// URLs.
17 
18 /* paths are as follows:
19 
20  special://xbmc/ - the main XBMC folder (i.e. where the app resides).
21  special://home/ - a writeable version of the main XBMC folder
22  Linux: ~/.kodi/
23  OS X: ~/Library/Application Support/Kodi/
24  Win32: ~/Application Data/XBMC/
25  special://envhome/ - on posix systems this will be equal to the $HOME
26  special://userhome/ - a writable version of the user home directory
27  Linux, OS X: ~/.kodi
28  Win32: home directory of user
29  special://masterprofile/ - the master users userdata folder - usually special://home/userdata
30  Linux: ~/.kodi/userdata/
31  OS X: ~/Library/Application Support/Kodi/UserData/
32  Win32: ~/Application Data/XBMC/UserData/
33  special://profile/ - the current users userdata folder - usually special://masterprofile/profiles/<current_profile>
34  Linux: ~/.kodi/userdata/profiles/<current_profile>
35  OS X: ~/Library/Application Support/Kodi/UserData/profiles/<current_profile>
36  Win32: ~/Application Data/XBMC/UserData/profiles/<current_profile>
37 
38  special://temp/ - the temporary directory.
39  Linux: ~/.kodi/temp
40  OS X: ~/
41  Win32: ~/Application Data/XBMC/cache
42 */
43 class CURL;
45 {
46 public:
47  static void RegisterProfileManager(const CProfileManager &profileManager);
48  static void UnregisterProfileManager();
49 
50  static void SetProfilePath(const std::string &path);
51  static void SetXBMCPath(const std::string &path);
52  static void SetXBMCBinPath(const std::string &path);
53  static void SetXBMCBinAddonPath(const std::string &path);
54  static void SetXBMCAltBinAddonPath(const std::string &path);
55  static void SetXBMCFrameworksPath(const std::string &path);
56  static void SetHomePath(const std::string &path);
57  static void SetUserHomePath(const std::string &path);
58  static void SetEnvHomePath(const std::string &path);
59  static void SetMasterProfilePath(const std::string &path);
60  static void SetTempPath(const std::string &path);
61  static void SetLogPath(const std::string &dir);
62 
63  static bool ComparePath(const std::string &path1, const std::string &path2);
64  static void LogPaths();
65 
66  static std::string TranslatePath(const std::string &path);
67  static std::string TranslatePath(const CURL &url);
68  static std::string TranslatePathConvertCase(const std::string& path);
69 
70 private:
71  static const CProfileManager *m_profileManager;
72 
73  static void SetPath(const std::string &key, const std::string &path);
74  static std::string GetPath(const std::string &key);
75 
76  static std::map<std::string, std::string> m_pathMap;
77 };
78 
79 #ifdef TARGET_WINDOWS
80 #define PATH_SEPARATOR_CHAR '\\'
81 #define PATH_SEPARATOR_STRING "\\"
82 #else
83 #define PATH_SEPARATOR_CHAR '/'
84 #define PATH_SEPARATOR_STRING "/"
85 #endif
Definition: URL.h:21
Definition: ProfileManager.h:25
Definition: SpecialProtocol.h:44