#include <unzip.h>
#include <zlib.h>
+#include <sessiond.h>
+
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/filesystem/operations.hpp>
}
bool RemoveAll(const bf::path& path) {
- if (!exists(path) && !bf::is_symlink(bf::symlink_status(path)))
+ if (!bf::exists(path) && !bf::is_symlink(bf::symlink_status(path)))
return true;
bs::error_code error;
bool Remove(const bf::path& path) {
bs::error_code error;
- if (!exists(bf::symlink_status(path, error)))
+ if (!bf::exists(bf::symlink_status(path, error)))
return true;
bf::remove(path, error);
const boost::filesystem::path& dst, const std::string& entry) {
if (!bf::exists(src / entry))
return true;
+
if (!MoveDir(src / entry, dst / entry,
FS_MERGE_OVERWRITE |
FS_COMMIT_COPY_FILE |
int64_t size = 0;
int64_t block_size = GetBlockSizeForPath(path);
- // if failed to stat path
if (block_size == -1)
return -1;
int64_t GetDirectorySize(const boost::filesystem::path& path) {
int64_t block_size = GetBlockSizeForPath(path);
- // if failed to stat path
if (block_size == -1)
return -1;
const boost::filesystem::path& target_location) {
bs::error_code error;
boost::filesystem::path root = target_location;
+
while (!bf::exists(root) && root != root.root_path())
root = root.parent_path();
LOG(ERROR) << "No mount point for path: " << target_location;
return false;
}
+
bf::space_info space_info = bf::space(root, error);
if (error) {
LOG(ERROR) << "Failed to get space_info: " << error.message();
bf::path pattern = path;
pattern += "-%%%%%%";
bf::path tmp_path;
+
do {
tmp_path = boost::filesystem::unique_path(pattern);
} while (boost::filesystem::exists(tmp_path));
+
return tmp_path;
}
std::string(raw_file_name_in_zip).find(filter_prefix) == 0) {
bf::path filename_in_zip_path(raw_file_name_in_zip);
- // prevent "directory climbing" attack
if (HasDirectoryClimbing(filename_in_zip_path)) {
LOG(ERROR) << "Relative path in widget in malformed";
return false;
LOG(ERROR) << base.string() << " is not base path for " << input.string();
return input;
}
+
return input.string().substr(base.string().length() + 1);
}
else
p = p.parent_path();
}
+
return false;
}
const bf::path& to) {
bf::path::const_iterator itr_path = from.begin();
bf::path::const_iterator itr_relative_to = to.begin();
+
while (itr_path != from.end() && itr_relative_to != to.end() &&
*itr_path == *itr_relative_to) {
++itr_path;
return result;
}
+std::vector<std::string> GetLightUserList(uid_t uid) {
+ int user_count = 0;
+ subsession_user_t* user_list = nullptr;
+ int ret = subsession_get_user_list(
+ static_cast<int>(uid), &user_list, &user_count);
+ if (ret != TIZEN_ERROR_NONE) {
+ LOG(ERROR) << "Failed to get light user list : " << ret;
+ return {};
+ }
+
+ std::vector<std::string> result_list;
+ for (int i = 0; i < user_count; i++) {
+ if (strlen(user_list[i]) == 0)
+ continue;
+
+ result_list.emplace_back(user_list[i]);
+ }
+
+ std::free(user_list);
+ return result_list;
+}
+
} // namespace common_installer