Add comments for added function in utils.h
[platform/core/dotnet/launcher.git] / NativeLauncher / util / utils.cc
index f93f7d1..5e15b43 100644 (file)
@@ -248,9 +248,9 @@ static bool setDirOwnershipAndPermissions(const bf::path& path, bf::perms permis
        return true;
 }
 
-static bool copyOwnershipAndPermissions(const bf::path& path, const bf::path& dst) {
+static bool copyOwnershipAndPermissions(const bf::path& path, const bf::path& path2) {
        if (!bf::exists(path)) {
-               _ERR("Failed to copy ownership and permissions from %s to %s", path.c_str(), dst.c_str());
+               _ERR("Failed to copy ownership and permissions from %s to %s", path.c_str(), path2.c_str());
                return false;
        }
        bf::perms permissions = bf::status(path).permissions();
@@ -258,8 +258,8 @@ static bool copyOwnershipAndPermissions(const bf::path& path, const bf::path& ds
        if (stat(path.c_str(), &stats) != 0) {
                return false;
        }
-       if (!setDirOwnershipAndPermissions(dst, permissions, stats.st_uid, stats.st_gid)) {
-               _ERR("Failed to copy ownership and permissions from %s to %s", path.c_str(), dst.c_str());
+       if (!setDirOwnershipAndPermissions(path2, permissions, stats.st_uid, stats.st_gid)) {
+               _ERR("Failed to copy ownership and permissions from %s to %s", path.c_str(), path2.c_str());
                return false;
        }
        return true;
@@ -278,29 +278,29 @@ bool createDir(const bf::path& path) {
        return true;
 }
 
-bool copyDir(const bf::path& path, const bf::path& dst, FSFlag flags, bool skip_symlink) {
+bool copyDir(const bf::path& path1, const bf::path& path2, FSFlag flags) {
        try {
                // Check whether the function call is valid
-               if (!bf::exists(path) || !bf::is_directory(path)) {
-                       _ERR("Source directory %s does not exist or is not a directory", path.c_str());
+               if (!bf::exists(path1) || !bf::is_directory(path1)) {
+                       _ERR("Source directory %s does not exist or is not a directory", path1.c_str());
                        return false;
                }
-               if (!bf::exists(dst)) {
+               if (!bf::exists(path2)) {
                        // Create the destination directory
-                       if (!createDir(dst)) {
-                               _ERR("Unable to create destination directory %s", dst.c_str());
+                       if (!createDir(path2)) {
+                               _ERR("Unable to create destination directory %s", path2.c_str());
                                return false;
                        }
                        if (flags & FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS) {
-                               copyOwnershipAndPermissions(path, dst);
+                               copyOwnershipAndPermissions(path1, path2);
                        }
                } else {
                        if (!(flags & (FS_MERGE_SKIP | FS_MERGE_OVERWRITE))) {
-                               _ERR("Destination directory %s already exists", dst.c_str());
+                               _ERR("Destination directory %s already exists", path2.c_str());
                                return false;
                        }
                        if (flags & (FS_MERGE_OVERWRITE | FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS)) {
-                               copyOwnershipAndPermissions(path, dst);
+                               copyOwnershipAndPermissions(path1, path2);
                        }
                }
        } catch (const bf::filesystem_error& error) {
@@ -309,14 +309,11 @@ bool copyDir(const bf::path& path, const bf::path& dst, FSFlag flags, bool skip_
        }
 
        // Iterate through the source directory
-       for (bf::directory_iterator file(path); file != bf::directory_iterator(); ++file) {
+       for (bf::directory_iterator file(path1); file != bf::directory_iterator(); ++file) {
                try {
                        bf::path current(file->path());
-                       bf::path target = dst / current.filename();
+                       bf::path target = path2 / current.filename();
                        if (bf::is_symlink(symlink_status(current))) {
-                               if (skip_symlink) {
-                                       continue;
-                               }
                                if ((flags & (FS_MERGE_SKIP | FS_MERGE_OVERWRITE)) && bf::exists(target)) {
                                        continue;
                                }
@@ -328,7 +325,7 @@ bool copyDir(const bf::path& path, const bf::path& dst, FSFlag flags, bool skip_
                                }
                        } else if (bf::is_directory(current)) {
                                // Found directory: Recursion
-                               if (!copyDir(current, target, flags, skip_symlink)) {
+                               if (!copyDir(current, target, flags)) {
                                        return false;
                                }
                        } else {
@@ -362,32 +359,32 @@ bool copyDir(const bf::path& path, const bf::path& dst, FSFlag flags, bool skip_
        return true;
 }
 
-bool copyFile(const bf::path& path, const bf::path& dst) {
+bool copyFile(const bf::path& path1, const bf::path& path2) {
        bs::error_code error;
-       bf::copy_file(path, dst, bf::copy_option::overwrite_if_exists, error);
+       bf::copy_file(path1, path2, bf::copy_option::overwrite_if_exists, error);
        if (error) {
-               _ERR("copy file %s due to error [%s]", path.c_str(), error.message().c_str());
+               _ERR("copy file %s due to error [%s]", path1.c_str(), error.message().c_str());
                return false;
        }
        return true;
 }
 
-bool moveFile(const bf::path& path, const bf::path& dst, bool force) {
-       if (!force && bf::exists(dst)) {
+bool moveFile(const bf::path& path1, const bf::path& path2) {
+       if (bf::exists(path2)) {
                return false;
        }
        bs::error_code error;
-       bf::rename(path, dst, error);
+       bf::rename(path1, path2, error);
        if (error) {
-               _ERR("Cannot move file: %s. Will copy/remove... with error [%s]", path.c_str(), error.message().c_str());
-               bf::copy_file(path, dst, bf::copy_option::overwrite_if_exists, error);
+               _ERR("Cannot move file: %s. Will copy/remove... with error [%s]", path1.c_str(), error.message().c_str());
+               bf::copy_file(path1, path2, bf::copy_option::overwrite_if_exists, error);
                if (error) {
-                       _ERR("Cannot copy file %s due to error [%s]", path.c_str(), error.message().c_str());
+                       _ERR("Cannot copy file %s due to error [%s]", path1.c_str(), error.message().c_str());
                        return false;
                }
-               bf::remove_all(path, error);
+               bf::remove_all(path1, error);
                if (error) {
-                       _ERR("Cannot remove old file when coping: %s with error [%s]", path.c_str(), error.message().c_str());
+                       _ERR("Cannot remove old file when coping: %s with error [%s]", path1.c_str(), error.message().c_str());
                        return false;
                }
        }