Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / utils / paths.h
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_UTILS_PATHS_H_
6 #define COMMON_UTILS_PATHS_H_
7
8 #include <unistd.h>
9
10 #include <filesystem>
11 #include <string>
12
13 #include "common/utils/request.h"
14
15 namespace common_installer {
16
17 /**
18  * \brief Helper function for getting backup path (used for recovery)
19  *        based on package path
20  *
21  * \param pkg_path package path
22  *
23  * \return backup path
24  */
25 std::filesystem::path GetBackupPathForPackagePath(
26     const std::filesystem::path& pkg_path);
27
28 /**
29  * \brief Helper function for getting backup path (used for recovery)
30  *        based on manifest file path
31  *
32  * \param manifest_path path to manifest file
33  *
34  * \return backup path
35  */
36 std::filesystem::path GetBackupPathForManifestFile(
37     const std::filesystem::path& manifest_path);
38
39 /**
40  * \brief Helper function for getting backup path (used for recovery)
41  *        based on icon path
42  *
43  * \param icon_path path to icon file
44  *
45  * \return backup path
46  */
47 std::filesystem::path GetBackupPathForIconFile(
48     const std::filesystem::path& icon_path);
49
50 /**
51  * @brief GetIconFileBackupExtension
52  * @return extension for backup icon files
53  */
54 std::string GetIconFileBackupExtension();
55
56 /**
57  * \brief Helper function for getting backup path of zip (used for recovery)
58  *        based on zip path
59  *
60  * \param zip_path path to zip file
61  *
62  * \return backup path of zip
63  */
64 std::filesystem::path GetBackupPathForZipFile(
65     const std::filesystem::path& zip_path);
66
67 /**
68  * @brief GetZipPackageLocation
69  *        Returns location where zip package file must be copied during package
70  *        installation.
71  *
72  * @param pkg_path package path
73  * @param pkgid package id
74  *
75  * @return full path of zip package location
76  */
77 std::filesystem::path GetZipPackageLocation(
78     const std::filesystem::path& pkg_path,
79     const std::string& pkgid);
80
81 /**
82  * @brief GetMountLocation
83  *        Returns the mount point of zip package. This location is used to
84  *        mount package.
85  *
86  * @param pkg_path package path for which zip mount location is being obtained
87  *
88  * @return full path of package mount point
89  */
90 std::filesystem::path GetMountLocation(
91     const std::filesystem::path& pkg_path);
92
93 /**
94  * @brief GetExternalCardPath
95  *        Returns full path to mounted filesystem of sd card
96  *
97  * @return path
98  */
99 std::filesystem::path GetExternalCardPath();
100
101 /**
102  * @brief GetExternalTepPath
103  *        Returns external installation location for tep package
104  * @param request_mode request type
105  * @param uid user id of request
106  *
107  * @return full directory path
108  */
109 std::filesystem::path GetExternalTepPath(RequestMode request_mode, uid_t uid);
110
111 /**
112  * @brief GetInternalTepPath
113  *        Returns internal installation location for tep package
114  * @param pkg_path path of installation request
115  *
116  * @return full directory path
117  */
118 std::filesystem::path GetInternalTepPath(
119     const std::filesystem::path& pkg_path);
120
121 /**
122  * @brief GetIconPath
123  *        Returns internal location for preinstalled global app icon
124  * @param base_path path of icon in application
125  * @param pkgid package id
126  * @param icon_filename filename of icon
127  * @param root_path root path of application
128  *
129  * @return full icon path
130  */
131 std::filesystem::path GetIconPath(const std::filesystem::path& base_path,
132                       const std::string& pkgid,
133                       const std::filesystem::path& icon_filename,
134                       const std::filesystem::path& root_path);
135
136 /**
137  * @brief IsExtendedStorageAvailable
138  *        Returns true if the extended storage is available
139  *
140  * @return true is the extended storage is available, otherwise false
141  */
142 bool IsExtendedStorageAvailable();
143
144 }  // namespace common_installer
145
146 #endif  // COMMON_UTILS_PATHS_H_