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 * \brief Performs a creation of directories for specific user in external storage
19 * \param pkgid id of package
20 * \param create_skel_directories flag
22 * \return true if succeed, false otherwise
25 bool PerformExternalDirectoryCreationForUser(uid_t uid,
26 const std::string& pkgid);
29 * \brief Performs a removal of directories for specific user in external storage
30 * \param user id of user
31 * \param pkgid id of package
33 * \return true if succeed, false otherwise
35 bool PerformExternalDirectoryDeletionForUser(uid_t user,
36 const std::string& pkgid);
39 * \brief Performs a creation of directories in external storage (eg. SD card)
41 * \param pkgid id of package
42 * \param create_skel_directories flag
44 * \return true if succeed, false otherwise
47 bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid);
50 * \brief Find pkgs which has external storage privilege for each user and make
51 * directories in external storage (eg. SD card)
53 * \return true if succeed, false otherwise
56 bool PerformExternalDirectoryCreationForAllPkgs();
59 * \brief Performs a removal of directories in external storage (eg. SD card)
60 * \param pkgid id of package
62 * \return true if succeed, false otherwise
64 bool PerformExternalDirectoryDeletionForAllUsers(const std::string& pkgid);
67 * \brief Creates per user storage directories in path
69 * \param pkgid package id
70 * \param trusted signed package flag
71 * \param shareddata shared data privilege flag
72 * \param is_readonly readonly flag
73 * \param additional_dirs additional directories vector
75 * \return true if succeed, false otherwise
77 bool CreatePerUserStorageDirectories(const std::string& pkgid,
78 bool trusted, bool shareddata,
80 const std::vector<const char*>
82 std::vector<const char*>());
85 * \brief Creates storage directories in path
87 * \param path base path, where storage directories will be created in
88 * \param pkgid package id
90 * \param trusted signed package flag
91 * \param shareddata shared data privilege flag
93 * \return true if succeed, false otherwise
95 bool CreateStorageDirectories(const boost::filesystem::path& path,
96 const std::string& pkgid, uid_t uid,
97 bool trusted, bool shareddata);
100 * \brief Deletes per user storage directories in path
102 * \param pkgid package id
103 * \param keep_rwdata keep rwdata flag
105 * \return true if succeed, false otherwise
107 bool DeletePerUserStorageDirectories(const std::string& pkgid,
108 bool keep_rwdata = false);
111 * \brief Deletes storage directories in path
113 * \param path base path, which contains storage directories
114 * \param pkgid package id
116 * \return true if succeed, false otherwise
118 bool DeleteStorageDirectories(const boost::filesystem::path& path,
119 const std::string& pkgid);
122 * \brief Deletes shared directories in path
124 * \param path base path, which containsshared directories
125 * \param pkgid package id
127 * \return true if succeed, false otherwise
129 bool DeleteSharedDirectories(const boost::filesystem::path& path,
130 const std::string& pkgid);
133 * \brief Returns path prefix for internal storage, typically '/home'
135 * \return path prefix
138 std::string GetDirectoryPathForInternalStorage();
141 * \brief Returns path prefix for external storage, typically sd card mount point
143 * \return path prefix
146 std::string GetDirectoryPathForExternalStorage();
149 * \brief Create symlinks for read-only files of global app for all users.
151 * \param pkgid package id
153 * \return true if succeed, false otherwise
156 bool CreateGlobalAppSymlinksForAllUsers(const std::string& pkgid);
159 * \brief Create symlinks for read-only files of global app for user.
161 * \param pkgid package id
164 * \return true if succeed, false otherwise
167 bool CreateGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid);
170 * \brief Delete symlinks for read-only files of global app for all users.
172 * \param pkgid package id
174 * \return true if succeed, false otherwise
177 bool DeleteGlobalAppSymlinksForAllUsers(const std::string& pkgid);
180 * \brief Delete symlinks for read-only files of global app for user.
182 * \param pkgid package id
185 * \return true if succeed, false otherwise
188 bool DeleteGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid);
191 * \brief Set owner and permission of package directory.
193 * \param pkgid package id
196 * \return true if succeed, false otherwise
198 bool SetPackageDirectoryOwnerAndPermissions(const boost::filesystem::path& path,
202 * \brief Return true when installer should support legacy shared data directory.
204 * \param api_version package api version
206 * \return true when should support legacy shared data directory, false otherwise
208 bool ShouldSupportLegacySharedDataDir(const std::string& api_version);
211 * \brief Creates shared data directory for specific package
213 * \param pkgid package id
216 * \return true if succeed, false otherwise
218 bool CreateSharedDataDir(const std::string& pkgid, uid_t uid);
221 * \brief Creates per user shared data directories for specific package
223 * \param pkgid package id
225 * \return true if succeed, false otherwise
227 bool CreatePerUserSharedDataDir(const std::string& pkgid);
230 * \brief Deletes of shared data directory for specific package
232 * \param pkgid package id
235 * \return true if succeed, false otherwise
237 bool DeleteSharedDataDir(const std::string& pkgid, uid_t uid);
240 * \brief Deletes per user shared data directories for specific package
242 * \param pkgid package id
244 * \return true if succeed, false otherwise
246 bool DeletePerUserSharedDataDir(const std::string& pkgid);
249 * \brief Backups shared data directories for specific package
251 * \param pkgid package id
254 * \return true if succeed, false otherwise
256 bool BackupSharedDataDir(const std::string& pkgid, uid_t uid);
259 * \brief Backups per user shared data directories for specific package
261 * \param pkgid package id
263 * \return true if succeed, false otherwise
265 bool BackupPerUserSharedDataDir(const std::string& pkgid);
268 * \brief Restores shared data directories for specific package
270 * \param pkgid package id
273 * \return true if succeed, false otherwise
275 bool RestoreSharedDataDir(const std::string& pkgid, uid_t uid);
278 * \brief Restores per user shared data directories for specific package
280 * \param pkgid package id
282 * \return true if succeed, false otherwise
284 bool RestorePerUserSharedDataDir(const std::string& pkgid);
287 * \brief Removes backup of shared data directories for specific package
289 * \param pkgid package id
292 * \return true if succeed, false otherwise
294 bool RemoveBackupSharedDataDir(const std::string& pkgid, uid_t uid);
297 * \brief Removes backup of per user shared data directories for specific package
299 * \param pkgid package id
301 * \return true if succeed, false otherwise
303 bool RemoveBackupPerUserSharedDataDir(const std::string& pkgid);
305 } // namespace common_installer
307 #endif // COMMON_SHARED_DIRS_H_