1 // Copyright (c) 2016 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.
5 #ifndef COMMON_SHARED_DIRS_H_
6 #define COMMON_SHARED_DIRS_H_
8 #include <boost/filesystem/path.hpp>
9 #include <pkgmgrinfo_basic.h>
14 namespace common_installer {
17 PkgInfo(std::string pkg_id_, std::string api_version_, std::string author_)
19 api_version(api_version_),
23 std::string api_version;
24 std::string author_id;
27 using PkgList = std::vector<PkgInfo>;
30 * \brief Performs a creation of directories for specific user in internal storage
32 * \param pkgid id of package
33 * \param trusted is package trusted
34 * \param create_skel_directories flag
36 * \return true if succeed, false otherwise
38 bool PerformInternalDirectoryCreationForUser(uid_t uid,
39 const std::string& pkgid,
43 * \brief Performs a creation of directories for specific user in external storage
45 * \param pkgid id of package
46 * \param create_skel_directories flag
48 * \return true if succeed, false otherwise
51 bool PerformExternalDirectoryCreationForUser(uid_t uid,
52 const std::string& pkgid);
55 * \brief Performs a removal of directories for specific user in external storage
56 * \param user id of user
57 * \param pkgid id of package
59 * \return true if succeed, false otherwise
61 bool PerformExternalDirectoryDeletionForUser(uid_t user,
62 const std::string& pkgid);
65 * \brief Performs a creation of directories in internal storage
67 * \param pkgid id of package
68 * \param trusted is package trusted
69 * \param create_skel_directories flag
71 * \return true if succeed, false otherwise
74 bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid,
78 * \brief Performs a creation of directories in external storage (eg. SD card)
80 * \param pkgid id of package
81 * \param create_skel_directories flag
83 * \return true if succeed, false otherwise
86 bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid);
89 * \brief Performs a removal of directories in external storage (eg. SD card)
90 * \param pkgid id of package
92 * \return true if succeed, false otherwise
94 bool PerformExternalDirectoryDeletionForAllUsers(const std::string& pkgid);
97 * \brief Helper function fetching information about packages
99 * \param pkgs list of packages requested to fetch information about. If list
100 * is empty, all possible pkg id's are considered.
102 * \return pkg_list list containing information about requested packages
105 PkgList CreatePkgInformationList(uid_t uid = getuid(),
106 const std::vector<std::string>& pkgs =
107 std::vector<std::string>());
110 * \brief Create skeleton directories for package
112 * \param pkgid package id
114 * \return bool true if succeed, false otherwise
117 bool CreateSkelDirectories(const std::string& pkgid);
120 * \brief Performs deletion of directories
122 * \param pkgid package id
124 * \return true if succeed, false otherwise
127 bool DeleteSkelDirectories(const std::string& pkgid);
130 * \brief Delete per-user directories
132 * \param pkgid package id
134 * \return true if succeed, false otherwise
137 bool DeleteUserDirectories(const std::string& pkgid);
140 * \brief Copy per-user directories
142 * \param pkgid package id
144 * \return bool true if succeed, false otherwise
147 bool CopyUserDirectories(const std::string& pkgid);
150 * \brief Returns path prefix for internal storage, typically '/home'
152 * \return path prefix
155 std::string GetDirectoryPathForInternalStorage();
158 * \brief Returns path prefix for external storage, typically sd card mount point
160 * \return path prefix
163 std::string GetDirectoryPathForExternalStorage();
165 } // namespace common_installer
167 #endif // COMMON_SHARED_DIRS_H_