Move GetLightUserList() to user_util.h
[platform/core/appfw/app-installers.git] / src / common / utils / file_util.cc
index 60295cb..76ce1de 100644 (file)
@@ -316,7 +316,7 @@ bool RemoveBackup(const bf::path& path) {
 }
 
 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;
@@ -332,7 +332,7 @@ bool RemoveAll(const bf::path& path) {
 
 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);
@@ -394,6 +394,7 @@ bool BackupDir(const boost::filesystem::path& src,
     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 |
@@ -409,7 +410,6 @@ int64_t GetUnpackedPackageSize(const bf::path& path) {
   int64_t size = 0;
   int64_t block_size = GetBlockSizeForPath(path);
 
-  // if failed to stat path
   if (block_size == -1)
     return -1;
 
@@ -448,7 +448,6 @@ int64_t GetUnpackedPackageSize(const bf::path& path) {
 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;
 
@@ -471,6 +470,7 @@ bool CheckFreeSpaceAtPath(int64_t required_size,
     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();
 
@@ -478,6 +478,7 @@ bool CheckFreeSpaceAtPath(int64_t required_size,
     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();
@@ -508,9 +509,11 @@ boost::filesystem::path GenerateTemporaryPath(
   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;
 }
 
@@ -560,7 +563,6 @@ bool ExtractToTmpDir(const char* zip_path, const bf::path& tmp_dir,
         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;
@@ -680,6 +682,7 @@ boost::filesystem::path MakeRelativePath(const boost::filesystem::path& input,
       LOG(ERROR) << base.string() << " is not base path for " << input.string();
       return input;
   }
+
   return input.string().substr(base.string().length() + 1);
 }
 
@@ -692,6 +695,7 @@ bool IsSubDir(const boost::filesystem::path& path,
     else
       p = p.parent_path();
   }
+
   return false;
 }
 
@@ -699,6 +703,7 @@ bf::path RelativePath(const bf::path& from,
                                      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;