Remove boost dependency 53/303753/4
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 4 Jan 2024 08:06:24 +0000 (17:06 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 6 Feb 2024 06:37:36 +0000 (15:37 +0900)
Change-Id: Id66232cb8414dd71c21c30809be65590a94f1169
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
14 files changed:
CMakeLists.txt
packaging/pkgmgr-tool.spec
src/res-copy/CMakeLists.txt
src/res-copy/include/file_util.hh
src/res-copy/include/param_checker.hh
src/res-copy/src/condition_validator.cc
src/res-copy/src/copy_request_handler.cc
src/res-copy/src/createdir_request_handler.cc
src/res-copy/src/file_util.cc
src/res-copy/src/param_checker.cc
src/res-copy/src/remove_request_handler.cc
src/res-copy/src/uninstall_request_handler.cc
tests/unit_tests/CMakeLists.txt
tests/unit_tests/res-copy/src/test_request_handler.cc

index 2b80120..f8a018f 100644 (file)
@@ -41,8 +41,6 @@ PKG_CHECK_MODULES(STORAGE_DEPS REQUIRED storage)
 PKG_CHECK_MODULES(SQLITE_DEPS REQUIRED sqlite3)
 PKG_CHECK_MODULES(SMACK_DEPS REQUIRED libsmack)
 
-FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem program_options iostreams)
-
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs -pie" )
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
index 089fbdb..bf3263f 100644 (file)
@@ -11,7 +11,6 @@ Requires:  unzip
 Requires:  smack
 Requires:  cryptsetup
 
-BuildRequires:  boost-devel
 BuildRequires:  cmake
 BuildRequires:  gettext-tools
 BuildRequires:  pkgconfig(glib-2.0)
index 172cabd..a1e05d8 100644 (file)
@@ -10,7 +10,6 @@ APPLY_PKG_CONFIG(${TARGET_RES_COPY} PUBLIC
   AUL_DEPS
   GLIB_DEPS
   BUNDLE_DEPS
-  Boost
   PKGMGR_DEPS
   PKGMGR_INFO_DEPS
   PKGMGR_INSTALLER_DEPS
index 238516a..ff4bad3 100644 (file)
 #ifndef FILE_UTIL_HH_
 #define FILE_UTIL_HH_
 
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/optional.hpp>
-
-namespace bf = boost::filesystem;
+#include <filesystem>
 
 namespace res_handler {
 
@@ -35,25 +31,25 @@ enum FSFlag : int {
 
 FSFlag operator|(FSFlag a, FSFlag b);
 
-bool CreateDir(const boost::filesystem::path& path);
-bool CreateDirs(const std::string& pkgid, const boost::filesystem::path& path);
+bool CreateDir(const std::filesystem::path& path);
+bool CreateDirs(const std::string& pkgid, const std::filesystem::path& path);
 
-bool CopyDir(const boost::filesystem::path& src,
-             const boost::filesystem::path& dst,
+bool CopyDir(const std::filesystem::path& src,
+             const std::filesystem::path& dst,
              FSFlag flags = FS_NONE, bool skip_symlink = false);
 
-bool CopyFile(const boost::filesystem::path& src,
-             const boost::filesystem::path& dst);
+bool CopyFile(const std::filesystem::path& src,
+             const std::filesystem::path& dst);
 
-bool RemoveAll(const boost::filesystem::path& path);
+bool RemoveAll(const std::filesystem::path& path);
 
-bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
+bool SetDirOwnershipAndPermissions(const std::filesystem::path& path,
                       mode_t  mode, uid_t uid, gid_t gid);
 
-bool SetDirPermissions(const boost::filesystem::path& path,
+bool SetDirPermissions(const std::filesystem::path& path,
                       mode_t mode);
 
-bool SetOwnership(const bf::path& path, uid_t uid, gid_t gid);
+bool SetOwnership(const std::filesystem::path& path, uid_t uid, gid_t gid);
 
 }  // namespace res_handler
 
index 8fa10fb..36aab83 100644 (file)
@@ -42,7 +42,6 @@ class ParamChecker {
   uid_t uid_ = 0;
   ReqType req_type_ = ReqType::REQ_TYPE_UNKNOWN;
 
-  void SetRequestType(std::string key);
   bool ValidatePkgID();
   bool ValidatePathList();
 };
index b089129..68af56f 100644 (file)
 
 #include <pkgmgr-info.h>
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
 #include <tzplatform_config.h>
 
+#include <filesystem>
 #include <iostream>
 #include <list>
 #include <string>
+#include <system_error>
 
 #include "include/logging.hh"
 #include "include/request_type.hh"
 #include "include/res_path_info.hh"
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -58,19 +57,19 @@ bool IsPackageExists(std::string pkgid, uid_t uid) {
 }
 
 bool CheckFreeSpaceAtPath(int64_t required_size,
-    const bf::path& target_location) {
-  boost::system::error_code error;
-  bf::path root = target_location;
+    const fs::path& target_location) {
+  std::error_code error;
+  fs::path root = target_location;
 
-  while (!bf::exists(root) && root != root.root_path())
+  while (!fs::exists(root) && root != root.root_path())
     root = root.parent_path();
 
-  if (!bf::exists(root)) {
+  if (!fs::exists(root)) {
     LOG(ERROR) << "No mount point for path: " << target_location;
     return false;
   }
 
-  bf::space_info space_info = bf::space(root, error);
+  fs::space_info space_info = fs::space(root, error);
   if (error) {
     LOG(ERROR) << "Failed to get space_info: " << error.message();
     return false;
@@ -79,9 +78,9 @@ bool CheckFreeSpaceAtPath(int64_t required_size,
   return (space_info.free >= static_cast<uint64_t>(required_size));
 }
 
-int64_t GetBlockSizeForPath(const bf::path& path_in_partition) {
+int64_t GetBlockSizeForPath(const fs::path& path_in_partition) {
   struct stat stats;
-  if (stat(path_in_partition.string().c_str(), &stats)) {
+  if (stat(path_in_partition.c_str(), &stats)) {
     LOG(ERROR) << "stat(" << path_in_partition.string()
                << ") failed - error code: " << errno;
     return -1;
@@ -93,15 +92,15 @@ int64_t RoundUpToBlockSizeOf(int64_t size, int64_t block_size) {
   return ((size + block_size - 1) / block_size) * block_size;
 }
 
-int64_t GetDirectorySize(const bf::path& path) {
+int64_t GetDirectorySize(const fs::path& path) {
   int64_t block_size = GetBlockSizeForPath(path);
 
   if (block_size == -1)
     return -1;
 
   int64_t size = 0;
-  for (bf::recursive_directory_iterator iter(path);
-      iter != bf::recursive_directory_iterator(); ++iter) {
+  for (fs::recursive_directory_iterator iter(path);
+      iter != fs::recursive_directory_iterator(); ++iter) {
       struct stat buf;
       if (lstat(iter->path().c_str(), &buf) == -1) {
         LOG(ERROR) << "lstat() failed for: " << iter->path();
@@ -138,22 +137,22 @@ ErrorType ConditionValidator::ValidateCondition(ReqType req_type,
 
 ErrorType ConditionValidator::CheckCopyRequest(
     std::list<ResPathInfo> path_list) {
-  boost::filesystem::path src_root_path(root_path_);
+  fs::path src_root_path(root_path_);
   uintmax_t res_size = 0;
 
   src_root_path = src_root_path / "apps_rw" / pkgid_;
   for (auto& path_info : path_list) {
-    boost::filesystem::path res_path(src_root_path);
+    fs::path res_path(src_root_path);
     res_path = res_path  / path_info.GetSrcPath();
-    if (!boost::filesystem::exists(res_path)) {
+    if (!fs::exists(res_path)) {
       LOG(ERROR) << "Resource not exists : " << res_path;
       return ErrorType::ERROR_RES_NOT_FOUND;
     }
 
-    if (boost::filesystem::is_directory(res_path))
+    if (fs::is_directory(res_path))
       res_size += GetDirectorySize(res_path);
     else
-      res_size += boost::filesystem::file_size(res_path);
+      res_size += fs::file_size(res_path);
   }
   LOG(INFO) << "Required size for resource: " << res_size;
 
@@ -168,9 +167,9 @@ ErrorType ConditionValidator::CheckCopyRequest(
 ErrorType ConditionValidator::CheckRemoveRequest(
     std::list<ResPathInfo> path_list) {
   for (auto& path_info : path_list) {
-    boost::filesystem::path dst_path(root_path_);
+    fs::path dst_path(root_path_);
     dst_path = dst_path / "priv_shared_res"/ pkgid_ / path_info.GetDstPath();
-    if (!boost::filesystem::exists(dst_path)) {
+    if (!fs::exists(dst_path)) {
       LOG(ERROR) << "Resource not exists : " << dst_path;
       return ErrorType::ERROR_RES_NOT_FOUND;
     }
index a1bc08d..de015f5 100644 (file)
@@ -17,9 +17,7 @@
 
 #include "include/copy_request_handler.hh"
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
 #include <iostream>
 #include <string>
 
@@ -29,7 +27,7 @@
 #include "include/logging.hh"
 #include "include/res_path_info.hh"
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -45,30 +43,30 @@ CopyRequestHandler::CopyRequestHandler(
   AbstractRequestHandler(pkgid, uid, root_path, path_list) {}
 
 ErrorType CopyRequestHandler::Execute() {
-  bf::path src_root_path(GetSrcRootPath());
-  bf::path dst_root_path(GetDstRootPath());
+  fs::path src_root_path(GetSrcRootPath());
+  fs::path dst_root_path(GetDstRootPath());
 
   if (!CreateDir(dst_root_path))
     return ErrorType::ERROR_SYSTEM_ERROR;
 
   for (auto& path_info : GetPathList()) {
-    bf::path src_path = src_root_path / path_info.GetSrcPath();
-    if (!bf::exists(src_path)) {
+    fs::path src_path = src_root_path / path_info.GetSrcPath();
+    if (!fs::exists(src_path)) {
       LOG(ERROR) << "Path not exists :" << src_path;
       path_info.SetState(ResPathInfo::State::FAILED);
       return ErrorType::ERROR_RES_NOT_FOUND;
     }
 
-    bf::path dst_path = dst_root_path / path_info.GetDstPath();
+    fs::path dst_path = dst_root_path / path_info.GetDstPath();
 
-    if (bf::is_directory(src_path)) {
+    if (fs::is_directory(src_path)) {
       if (!CopyDir(src_path, dst_path, FS_MERGE_OVERWRITE, true)) {
         LOG(ERROR) << "Failed to copy directory " << src_path;
         path_info.SetState(ResPathInfo::State::FAILED);
         return ErrorType::ERROR_SYSTEM_ERROR;
       }
     } else {
-      if (bf::is_directory(dst_path))
+      if (fs::is_directory(dst_path))
         dst_path /= src_path.filename();
 
       if (!CopyFile(src_path, dst_path)) {
@@ -88,16 +86,16 @@ const std::string CopyRequestHandler::GetRequestHandlerType() const {
 }
 
 std::list<ResPathInfo> CopyRequestHandler::GetResultPathList() {
-  bf::path src_root_path(GetSrcRootPath());
-  bf::path dst_root_path(GetDstRootPath());
+  fs::path src_root_path(GetSrcRootPath());
+  fs::path dst_root_path(GetDstRootPath());
   std::list<ResPathInfo> result;
 
   for (const auto& path_info : GetPathList()) {
-    bf::path src_path = src_root_path / path_info.GetSrcPath();
-    bf::path dst_path = dst_root_path / path_info.GetDstPath();
-    bf::path result_path = path_info.GetDstPath();
+    fs::path src_path = src_root_path / path_info.GetSrcPath();
+    fs::path dst_path = dst_root_path / path_info.GetDstPath();
+    fs::path result_path = path_info.GetDstPath();
 
-    if (bf::is_directory(dst_path) && !bf::is_directory(src_path))
+    if (fs::is_directory(dst_path) && !fs::is_directory(src_path))
       result_path /= src_path.filename();
 
     result.emplace_back(result_path.string(), "", path_info.GetState());
index eaacee6..66d784a 100644 (file)
@@ -17,9 +17,7 @@
 
 #include "include/createdir_request_handler.hh"
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
 #include <iostream>
 #include <string>
 
@@ -29,7 +27,7 @@
 #include "include/logging.hh"
 #include "include/res_path_info.hh"
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -45,13 +43,13 @@ CreateDirRequestHandler::CreateDirRequestHandler(
   AbstractRequestHandler(pkgid, uid, root_path, path_list) {}
 
 ErrorType CreateDirRequestHandler::Execute() {
-  bf::path dst_root_path(GetDstRootPath());
+  fs::path dst_root_path(GetDstRootPath());
 
   if (!CreateDir(dst_root_path))
     return ErrorType::ERROR_SYSTEM_ERROR;
 
   for (auto& path_info : GetPathList()) {
-    bf::path dst_path = dst_root_path / path_info.GetSrcPath();
+    fs::path dst_path = dst_root_path / path_info.GetSrcPath();
     if (!CreateDirs(GetPkgID(), dst_path)) {
       path_info.SetState(ResPathInfo::State::FAILED);
       return ErrorType::ERROR_SYSTEM_ERROR;
index 0d8d504..93cc74d 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <pwd.h>
+#include <unistd.h>
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/optional.hpp>
-#include <boost/system/error_code.hpp>
+#include <algorithm>
+#include <filesystem>
+#include <string>
+#include <random>
 
 #include "include/logging.hh"
 
-namespace bs = boost::system;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -40,6 +40,34 @@ constexpr gid_t kPrivPlatformGid = 10212;
 constexpr mode_t kDefaultMode640 = S_IRUSR | S_IWUSR | S_IRGRP;
 constexpr mode_t kDirectoryMode650 = S_IRUSR | S_IWUSR | S_IRGRP | S_IXGRP;
 
+// To replace with std::filesystem::unique_path()
+fs::path GenerateUniquePath(const std::string& format) {
+  static constexpr auto chars =
+      "0123456789"
+      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+      "abcdefghijklmnopqrstuvwxyz";
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  auto dist = std::uniform_int_distribution{{}, std::strlen(chars) - 1};
+  size_t len = std::count_if(format.begin(), format.end(),
+      [](char c) { return c == '%'; });
+
+  auto random_string = std::string(len, '\0');
+  std::generate_n(begin(random_string), len,
+      [&]() {
+        return chars[dist(gen)];
+      });
+
+  auto iter = random_string.begin();
+  std::string result(format);
+  std::transform(result.begin(), result.end(), result.begin(),
+      [&](char c) {
+        return c == '%' ? *iter++ : c;
+      });
+
+  return result;
+}
+
 }  // namespace
 
 namespace res_handler {
@@ -48,9 +76,9 @@ FSFlag operator|(FSFlag a, FSFlag b) {
   return static_cast<FSFlag>(static_cast<int>(a) | static_cast<int>(b));
 }
 
-bool SetDirPermissions(const boost::filesystem::path& path,
+bool SetDirPermissions(const fs::path& path,
                       mode_t mode) {
-  if (chmod(path.string().c_str(), mode) != 0) {
+  if (chmod(path.c_str(), mode) != 0) {
     LOG(ERROR) << "Failed to set permissions for path: " << path
                << ", errno : " << errno;
     return false;
@@ -59,12 +87,12 @@ bool SetDirPermissions(const boost::filesystem::path& path,
   return true;
 }
 
-bool RemoveAll(const bf::path& path) {
-  if (!exists(path) && !bf::is_symlink(bf::symlink_status(path)))
+bool RemoveAll(const fs::path& path) {
+  if (!exists(path) && !fs::is_symlink(fs::symlink_status(path)))
     return true;
 
-  bs::error_code error;
-  bf::remove_all(path, error);
+  std::error_code error;
+  fs::remove_all(path, error);
 
   if (error) {
     LOG(ERROR) << "Cannot remove: " << path << ", " << error.message();
@@ -74,17 +102,17 @@ bool RemoveAll(const bf::path& path) {
   return true;
 }
 
-bool CopyDir(const boost::filesystem::path& src,
-             const boost::filesystem::path& dst,
+bool CopyDir(const fs::path& src,
+             const fs::path& dst,
              FSFlag flags, bool skip_symlink) {
   try {
     // Check whether the function call is valid
-    if (!bf::exists(src) || !bf::is_directory(src)) {
+    if (!fs::exists(src) || !fs::is_directory(src)) {
       LOG(ERROR) << "Source directory " << src
                  << " does not exist or is not a directory.";
       return false;
     }
-    if (!bf::exists(dst)) {
+    if (!fs::exists(dst)) {
       // Create the destination directory
       if (!CreateDir(dst)) {
         LOG(ERROR) << "Unable to create destination directory" << dst;
@@ -97,64 +125,64 @@ bool CopyDir(const boost::filesystem::path& src,
         return false;
       }
     }
-  } catch (const bf::filesystem_error& error) {
+  } catch (const fs::filesystem_error& error) {
     LOG(ERROR) << "Failed to copy directory: " << error.what();
     return false;
   }
 
   // Iterate through the source directory
-  for (bf::directory_iterator file(src);
-      file != bf::directory_iterator();
+  for (fs::directory_iterator file(src);
+      file != fs::directory_iterator();
       ++file) {
     try {
-      bf::path current(file->path());
-      bf::path target = dst / current.filename();
+      fs::path current(file->path());
+      fs::path target = dst / current.filename();
 
-      if (bf::is_symlink(symlink_status(current))) {
+      if (fs::is_symlink(symlink_status(current))) {
         if (skip_symlink)
           continue;
         if ((flags & (FS_MERGE_SKIP | FS_MERGE_OVERWRITE)) &&
-            bf::exists(target))
+            fs::exists(target))
           continue;
-        bs::error_code error;
-        bf::copy_symlink(current, target, error);
+        std::error_code error;
+        fs::copy_symlink(current, target, error);
         if (error) {
           LOG(ERROR) << "Failed to copy symlink: " << current << ", "
                      << error.message();
           return false;
         }
-      } else if (bf::is_directory(current)) {
+      } else if (fs::is_directory(current)) {
         // Found directory: Recursion
         if (!CopyDir(current, target, flags, skip_symlink)) {
           return false;
         }
       } else {
-        if ((flags & FS_MERGE_SKIP) && bf::exists(target))
+        if ((flags & FS_MERGE_SKIP) && fs::exists(target))
           continue;
-        bf::path destination = target;
+        fs::path destination = target;
 
         if (flags & FS_COMMIT_COPY_FILE)
           destination =
-              bf::unique_path(target.parent_path() / "%%%%-%%%%-%%%%-%%%%");
+              target.parent_path() / GenerateUniquePath("%%%%-%%%%-%%%%-%%%%");
 
         if (flags & FS_MERGE_OVERWRITE)
-          bf::copy_file(current, destination,
-                        bf::copy_option::overwrite_if_exists);
+          fs::copy_file(current, destination,
+                        fs::copy_options::overwrite_existing);
         else
-          bf::copy_file(current, destination);
+          fs::copy_file(current, destination);
 
         if (flags & FS_COMMIT_COPY_FILE) {
           if (flags & FS_MERGE_OVERWRITE)
-            bf::remove(target);
+            fs::remove(target);
 
-          bf::rename(destination, target);
+          fs::rename(destination, target);
         }
 
         if (!SetDirOwnershipAndPermissions(
             destination, kDirectoryMode650, kRootUID, kPrivPlatformGid))
           return false;
       }
-    } catch (const bf::filesystem_error& error) {
+    } catch (const fs::filesystem_error& error) {
       LOG(ERROR) << "Failed to copy directory: " << error.what();
       return false;
     }
@@ -162,16 +190,16 @@ bool CopyDir(const boost::filesystem::path& src,
   return true;
 }
 
-bool CreateDir(const bf::path& path) {
-  if (bf::exists(path))
+bool CreateDir(const fs::path& path) {
+  if (fs::exists(path))
     return true;
 
-  boost::system::error_code error;
-  bf::create_directory(path, error);
+  std::error_code error;
+  fs::create_directory(path, error);
 
   if (error) {
     LOG(ERROR) << "Failed to create directory: "
-               << boost::system::system_error(error).what();
+               << std::system_error(error).what();
     return false;
   }
 
@@ -182,12 +210,12 @@ bool CreateDir(const bf::path& path) {
   return true;
 }
 
-bool CopyFile(const bf::path& src, const bf::path& dst) {
-  if (bf::is_symlink(bf::symlink_status(src)))
+bool CopyFile(const fs::path& src, const fs::path& dst) {
+  if (fs::is_symlink(fs::symlink_status(src)))
     return true;
 
-  bs::error_code error;
-  bf::copy_file(src, dst, bf::copy_option::overwrite_if_exists, error);
+  std::error_code error;
+  fs::copy_file(src, dst, fs::copy_options::overwrite_existing, error);
   if (error) {
     LOG(WARNING) << "copy file " << src << " due to error ["
         << error.message() << "]";
@@ -203,7 +231,7 @@ bool CopyFile(const bf::path& src, const bf::path& dst) {
   return true;
 }
 
-bool SetOwnership(const bf::path& path, uid_t uid, gid_t gid) {
+bool SetOwnership(const fs::path& path, uid_t uid, gid_t gid) {
   int ret = lchown(path.c_str(), uid, gid);
   if (ret != 0) {
     LOG(ERROR) << "Failed to change owner of: " << path;
@@ -213,7 +241,7 @@ bool SetOwnership(const bf::path& path, uid_t uid, gid_t gid) {
   return true;
 }
 
-bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
+bool SetDirOwnershipAndPermissions(const fs::path& path,
                       mode_t mode, uid_t uid, gid_t gid) {
   if (!SetOwnership(path, uid, gid)) {
     LOG(ERROR) << "Failed to change owner: " << path
@@ -229,17 +257,17 @@ bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
 }
 
 bool CreateDirs(
-    const std::string& pkgid, const boost::filesystem::path& path) {
-  boost::system::error_code error;
-  bf::create_directories(path, error);
+    const std::string& pkgid, const fs::path& path) {
+  std::error_code error;
+  fs::create_directories(path, error);
 
   if (error) {
     LOG(ERROR) << "Failed to create directory: "
-               << boost::system::system_error(error).what();
+               << std::system_error(error).what();
     return false;
   }
 
-  bf::path target_path = path;
+  fs::path target_path = path;
   while(target_path.filename() != pkgid) {
 
     if (!SetDirOwnershipAndPermissions(
index e583ca3..db69697 100644 (file)
 
 #include "include/param_checker.hh"
 
+#include <getopt.h>
 #include <pkgmgr-info.h>
-
-#include <boost/exception/diagnostic_information.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/program_options.hpp>
-#include <boost/system/error_code.hpp>
+#include <unistd.h>
 
 #include <string>
 #include <iostream>
@@ -32,9 +28,6 @@
 #include "include/request_type.hh"
 #include "include/res_path_info.hh"
 
-namespace bs = boost::system;
-namespace bpo = boost::program_options;
-
 namespace {
 
 bool IsPathTraversal(const std::string& path) {
@@ -49,50 +42,90 @@ bool IsPathTraversal(const std::string& path) {
   return true;
 }
 
+const struct option long_opts[] = {
+  { "uid", required_argument, nullptr, 'u' },
+  { "session-id", required_argument, nullptr, 'k' },
+  { "path", required_argument, nullptr, 'p' },
+  { "remove", required_argument, nullptr, 'r' },
+  { "delete", required_argument, nullptr, 'd' },
+  { "copy", required_argument, nullptr, 'c' },
+  { "createdir", required_argument, nullptr, 'D' },
+  { "help", no_argument, nullptr, 'h' },
+};
+
+const char kHelpMessage[] = R"(
+  -u [ --uid ] arg (=0)   user id
+  -k [ --session-id ] arg session id
+  -p [ --path ] arg       source-destination path
+  -r [ --remove ] arg     remove shared resource
+  -d [ --delete ] arg     delete shared resource for package
+  -c [ --copy ] arg       copy resource
+  -D [ --createdir ] arg  create directories
+  -h [ --help ]           Show this message
+)";
+
+void PrintHelp() {
+  std::cerr << kHelpMessage;
+}
+
 }  // namespace
 
 namespace res_handler {
 
 ParamChecker::ParamChecker(int argc, char* argv[]) {
-  bpo::options_description options;
-
-  options.add_options()
-      ("uid,u", bpo::value<int>()->default_value(0), "user id")
-      ("session-id,k", bpo::value<std::string>()->default_value(""),
-          "session id")
-      ("path,p", bpo::value<std::vector<std::string>>()->multitoken(),
-          "source-destination path")
-      ("remove,r", bpo::value<std::string>(), "remove shared resource")
-      ("delete,d", bpo::value<std::string>(),
-          "delete shared resource for package")
-      ("copy,c", bpo::value<std::string>(), "copy resource")
-      ("createdir,D", bpo::value<std::string>(), "create directories")
-      ("help,h", "Show this message");
-
-  bpo::parsed_options parsed_options = bpo::command_line_parser(argc, argv)
-      .options(options)
-      .run();
-
-  for (const bpo::option& o : parsed_options.options) {
-    if (o.string_key == "uid") {
-      uid_ = static_cast<uid_t>(std::stoi(o.value.front()));
-    } else if (o.string_key == "session-id") {
-      session_id_ = o.value.front();
-    } else if (o.string_key == "path") {
-      if (o.value.front() == o.value.back())
-        path_info_list_.emplace_back(o.value.front(), "");
-      else
-        path_info_list_.emplace_back(o.value.front(), o.value.back());
-    } else if (o.string_key == "copy" ||
-        o.string_key == "delete" ||
-        o.string_key == "remove" ||
-        o.string_key == "createdir") {
-      pkgid_ = o.value.front();
-      SetRequestType(o.string_key);
-    } else if (o.string_key == "help") {
-      std::cout << options;
-    } else {
-      std::cout << "Invalid option : " << o.string_key << std::endl;
+  // force reset global variable for getopt_long() before parsing
+  optind = 1;
+  int opt_idx;
+  while (true) {
+    int opt = getopt_long(argc, argv, "u:k:p:r:d:c:D:h", long_opts, &opt_idx);
+    if (opt == -1)
+      break;
+
+    switch (opt) {
+      case 'u':
+        if (optarg)
+          uid_ = std::stoi(optarg);
+        break;
+      case 'k':
+        if (optarg)
+          session_id_ = optarg;
+        break;
+      case 'p':
+        if (optarg) {
+          std::string src = optarg;
+          std::string dst;
+          if ((optind + 1) <= argc && *argv[optind] != '-')
+            dst = argv[optind];
+          path_info_list_.emplace_back(src, dst);
+        }
+        break;
+      case 'r':
+        if (optarg)
+          pkgid_ = optarg;
+        req_type_ = ReqType::REQ_TYPE_REMOVE;
+        break;
+      case 'd':
+        if (optarg)
+          pkgid_ = optarg;
+        req_type_ = ReqType::REQ_TYPE_UNINSTALL;
+        break;
+      case 'c':
+        if (optarg)
+          pkgid_ = optarg;
+        req_type_ = ReqType::REQ_TYPE_NEW;
+        break;
+      case 'D':
+        if (optarg)
+          pkgid_ = optarg;
+        req_type_ = ReqType::REQ_TYPE_CREATEDIR;
+        break;
+      case 'h':
+        PrintHelp();
+        break;
+      default:
+        std::cout << "Invalid option" << std::endl;
+        PrintHelp();
+        break;
     }
   }
 }
@@ -137,17 +170,6 @@ bool ParamChecker::Validate() {
   return true;
 }
 
-void ParamChecker::SetRequestType(std::string key) {
-  if (key == "copy")
-    req_type_ = ReqType::REQ_TYPE_NEW;
-  else if (key == "remove")
-    req_type_ = ReqType::REQ_TYPE_REMOVE;
-  else if (key == "delete")
-    req_type_ = ReqType::REQ_TYPE_UNINSTALL;
-  else if (key == "createdir")
-    req_type_ = ReqType::REQ_TYPE_CREATEDIR;
-}
-
 bool ParamChecker::ValidatePkgID() {
   if (pkgid_.size() == 0) {
     LOG(ERROR) << "pkgid is empty";
index ce97335..098cc5b 100644 (file)
@@ -17,9 +17,7 @@
 
 #include "include/remove_request_handler.hh"
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
 #include <iostream>
 #include <string>
 
@@ -29,7 +27,7 @@
 #include "include/logging.hh"
 #include "include/res_path_info.hh"
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -45,16 +43,16 @@ RemoveRequestHandler::RemoveRequestHandler(
   AbstractRequestHandler(pkgid, uid, root_path, path_list) {}
 
 ErrorType RemoveRequestHandler::Execute() {
-  bf::path dst_root_path(GetDstRootPath());
+  fs::path dst_root_path(GetDstRootPath());
 
-  if (!bf::exists(dst_root_path)) {
+  if (!fs::exists(dst_root_path)) {
     LOG(ERROR) << "root path not exists";
     return ErrorType::ERROR_RES_NOT_FOUND;
   }
 
   for (auto& path_info : GetPathList()) {
-    bf::path dst_path = dst_root_path / path_info.GetSrcPath();
-    if (!bf::exists(dst_path)) {
+    fs::path dst_path = dst_root_path / path_info.GetSrcPath();
+    if (!fs::exists(dst_path)) {
       LOG(ERROR) << "Path not exists: " << dst_path;
       continue;
     }
index c5912b0..2e85d0c 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "include/uninstall_request_handler.hh"
 
+#include <filesystem>
 #include <iostream>
 #include <string>
 
@@ -26,7 +27,7 @@
 #include "include/logging.hh"
 #include "include/res_path_info.hh"
 
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -47,8 +48,8 @@ ErrorType UninstallRequestHandler::Execute() {
     return ErrorType::ERROR_INVALID_PARAMETER;
   }
 
-  bf::path root_path(GetDstRootPath());
-  if (!bf::exists(root_path)) {
+  fs::path root_path(GetDstRootPath());
+  if (!fs::exists(root_path)) {
     LOG(WARNING) << "path not exists : " << root_path;
     return ErrorType::ERROR_NONE;
   }
index 97743fd..abf1687 100644 (file)
@@ -41,7 +41,6 @@ APPLY_PKG_CONFIG(${TARGET_PKGMGR_TOOL_UNITTESTS} PUBLIC
   SMACK_DEPS
   SQLITE_DEPS
   TZPLATFORM_DEPS
-  Boost
 )
 
 INSTALL(TARGETS ${TARGET_PKGMGR_TOOL_UNITTESTS} DESTINATION /usr/bin/)
index 33d06bd..4763a6c 100644 (file)
 #include <gtest/gtest.h>
 #include <stdio.h>
 
-#include <boost/filesystem/fstream.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
+#include <filesystem>
 #include <list>
 #include <memory>
 #include <string>
@@ -54,8 +50,7 @@ using res_handler::RemoveRequestHandler;
 using res_handler::ResPathInfo;
 using res_handler::UninstallRequestHandler;
 
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
 
 namespace {
 
@@ -69,12 +64,12 @@ std::string GetRootPath() {
   return "./tests/unit_tests/res-copy/data";
 }
 
-bf::path GetSrcRootPath() {
-  return bf::path(GetRootPath()) / "apps_rw" / kTestPkgID;
+fs::path GetSrcRootPath() {
+  return fs::path(GetRootPath()) / "apps_rw" / kTestPkgID;
 }
 
-bf::path GetDstRootPath() {
-  return bf::path(GetRootPath()) / "priv_shared_res" / kTestPkgID;
+fs::path GetDstRootPath() {
+  return fs::path(GetRootPath()) / "priv_shared_res" / kTestPkgID;
 }
 
 }  // namespace
@@ -88,13 +83,13 @@ class CopyRequestHandlerTest : public TestFixture {
   virtual ~CopyRequestHandlerTest() {}
 
   virtual void SetUp() {
-    bf::create_directories(GetDstRootPath() / "dest_dir");
+    fs::create_directories(GetDstRootPath() / "dest_dir");
 
     EXPECT_CALL(GetMock<OsMock>(), lchown(_, _, _)).WillRepeatedly(Return(0));
     EXPECT_CALL(GetMock<OsMock>(), chmod(_, _)).WillRepeatedly(Return(0));
   }
   virtual void TearDown() {
-    bf::remove_all(GetDstRootPath());
+    fs::remove_all(GetDstRootPath());
   }
 };
 
@@ -104,16 +99,16 @@ class RemoveRequestHandlerTest : public TestFixture {
   virtual ~RemoveRequestHandlerTest() {}
 
   virtual void SetUp() {
-    bf::create_directories(GetDstRootPath() / "new_dir/new_dir2");
-    bf::copy_file(GetSrcRootPath() / "data/resource_file.txt",
+    fs::create_directories(GetDstRootPath() / "new_dir/new_dir2");
+    fs::copy_file(GetSrcRootPath() / "data/resource_file.txt",
         GetDstRootPath() / "resource_file.txt");
-    bf::copy_file(GetSrcRootPath() / "data/resource_file.txt",
+    fs::copy_file(GetSrcRootPath() / "data/resource_file.txt",
         GetDstRootPath() / "new_dir/resource_file.txt");
-    bf::copy_file(GetSrcRootPath() / "data/resource_file.txt",
+    fs::copy_file(GetSrcRootPath() / "data/resource_file.txt",
         GetDstRootPath() / "new_dir/new_dir2/resource_file.txt");
   }
   virtual void TearDown() {
-    bf::remove_all(GetDstRootPath());
+    fs::remove_all(GetDstRootPath());
   }
 };
 
@@ -123,11 +118,11 @@ class UninstallRequestHandlerTest : public TestFixture {
   virtual ~UninstallRequestHandlerTest() {}
 
   virtual void SetUp() {
-    bf::create_directories(GetDstRootPath());
+    fs::create_directories(GetDstRootPath());
   }
 
   virtual void TearDown() {
-    bf::remove_all(GetDstRootPath());
+    fs::remove_all(GetDstRootPath());
   }
 };
 
@@ -137,11 +132,11 @@ class CreateDirRequestHandlerTest : public TestFixture {
   virtual ~CreateDirRequestHandlerTest() {}
 
   virtual void SetUp() {
-    bf::create_directories(GetDstRootPath() / "existed_dir");
+    fs::create_directories(GetDstRootPath() / "existed_dir");
   }
 
   virtual void TearDown() {
-    bf::remove_all(GetDstRootPath());
+    fs::remove_all(GetDstRootPath());
   }
 };
 
@@ -152,11 +147,11 @@ TEST_F(CopyRequestHandlerTest, CopyFileAtRootToRoot) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyFileAtRootToRoot_ChangeFileName) {
@@ -166,11 +161,11 @@ TEST_F(CopyRequestHandlerTest, CopyFileAtRootToRoot_ChangeFileName) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "another_name.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyFileAtRootToDirectory) {
@@ -180,14 +175,14 @@ TEST_F(CopyRequestHandlerTest, CopyFileAtRootToDirectory) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "dest_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyFileAtRootToDirectory_ChangeFileName) {
@@ -197,14 +192,14 @@ TEST_F(CopyRequestHandlerTest, CopyFileAtRootToDirectory_ChangeFileName) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "dest_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "newname.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyFileAtDirectoryToRoot) {
@@ -214,11 +209,11 @@ TEST_F(CopyRequestHandlerTest, CopyFileAtDirectoryToRoot) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file3.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyFileAtDirectoryToRoot_ChangeFileName) {
@@ -229,11 +224,11 @@ TEST_F(CopyRequestHandlerTest, CopyFileAtDirectoryToRoot_ChangeFileName) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "newname.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyFileAtDirectoryToDirectory) {
@@ -243,14 +238,14 @@ TEST_F(CopyRequestHandlerTest, CopyFileAtDirectoryToDirectory) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "dest_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file3.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToRoot_ChangeFileName) {
@@ -261,14 +256,14 @@ TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToRoot_ChangeFileName) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "dest_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "newname.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToRoot) {
@@ -278,18 +273,18 @@ TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToRoot) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file3.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path = check_path.parent_path();
   check_path /= "resource_dir2";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file2.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToDirectory) {
@@ -299,21 +294,21 @@ TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToDirectory) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "dest_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file3.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path = check_path.parent_path();
   check_path /= "resource_dir2";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file2.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToDirectory2) {
@@ -323,21 +318,21 @@ TEST_F(CopyRequestHandlerTest, CopyDirectoryAtRootToDirectory2) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_dir1";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file3.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path = check_path.parent_path();
   check_path /= "resource_dir2";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file2.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyDirectoryAtDirectoryToRoot) {
@@ -347,11 +342,11 @@ TEST_F(CopyRequestHandlerTest, CopyDirectoryAtDirectoryToRoot) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file2.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, CopyDirectoryAtDirectoryToDirectory) {
@@ -361,14 +356,14 @@ TEST_F(CopyRequestHandlerTest, CopyDirectoryAtDirectoryToDirectory) {
 
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path = GetDstRootPath();
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path = GetDstRootPath();
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "dest_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "resource_file2.txt";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CopyRequestHandlerTest, ResNotexists) {
@@ -398,8 +393,8 @@ TEST_F(RemoveRequestHandlerTest, RemoveFileAtRoot) {
   RemoveRequestHandler handler("test_pkg", 0, GetRootPath(), path_list);
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path(GetDstRootPath() / "resource_file.txt");
-  EXPECT_FALSE(bf::exists(check_path));
+  fs::path check_path(GetDstRootPath() / "resource_file.txt");
+  EXPECT_FALSE(fs::exists(check_path));
 }
 
 TEST_F(RemoveRequestHandlerTest, RemoveFileAtDirectory) {
@@ -409,8 +404,8 @@ TEST_F(RemoveRequestHandlerTest, RemoveFileAtDirectory) {
   RemoveRequestHandler handler("test_pkg", 0, GetRootPath(), path_list);
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path(GetDstRootPath() / "new_dir/resource_file.txt");
-  EXPECT_FALSE(bf::exists(check_path));
+  fs::path check_path(GetDstRootPath() / "new_dir/resource_file.txt");
+  EXPECT_FALSE(fs::exists(check_path));
 }
 
 TEST_F(RemoveRequestHandlerTest, RemoveDirectoryAtRoot) {
@@ -420,8 +415,8 @@ TEST_F(RemoveRequestHandlerTest, RemoveDirectoryAtRoot) {
   RemoveRequestHandler handler("test_pkg", 0, GetRootPath(), path_list);
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path(GetDstRootPath() / "new_dir");
-  EXPECT_FALSE(bf::exists(check_path));
+  fs::path check_path(GetDstRootPath() / "new_dir");
+  EXPECT_FALSE(fs::exists(check_path));
 }
 
 TEST_F(RemoveRequestHandlerTest, RemoveDirectoryAtDirectory) {
@@ -431,8 +426,8 @@ TEST_F(RemoveRequestHandlerTest, RemoveDirectoryAtDirectory) {
   RemoveRequestHandler handler("test_pkg", 0, GetRootPath(), path_list);
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path(GetDstRootPath() / "new_dir/new_dir2");
-  EXPECT_FALSE(bf::exists(check_path));
+  fs::path check_path(GetDstRootPath() / "new_dir/new_dir2");
+  EXPECT_FALSE(fs::exists(check_path));
 }
 
 TEST_F(UninstallRequestHandlerTest, RemoveRootPath) {
@@ -441,12 +436,12 @@ TEST_F(UninstallRequestHandlerTest, RemoveRootPath) {
   UninstallRequestHandler handler(
       "test_pkg", 0, GetRootPath(), path_list);
   EXPECT_EQ(handler.Execute(), res_handler::ErrorType::ERROR_NONE);
-  EXPECT_FALSE(bf::exists(GetDstRootPath()));
+  EXPECT_FALSE(fs::exists(GetDstRootPath()));
 }
 
 TEST_F(UninstallRequestHandlerTest, RootNotExists) {
   std::list<ResPathInfo> path_list;
-  bf::remove_all(GetDstRootPath());
+  fs::remove_all(GetDstRootPath());
 
   UninstallRequestHandler handler(
       "test_pkg", 0, GetRootPath(), path_list);
@@ -470,7 +465,7 @@ TEST_F(CreateDirRequestHandlerTest, CreateOneAtRoot) {
   EXPECT_EQ(handler.Execute(),
       res_handler::ErrorType::ERROR_NONE);
 
-  EXPECT_TRUE(bf::exists(GetDstRootPath() / "new_dir"));
+  EXPECT_TRUE(fs::exists(GetDstRootPath() / "new_dir"));
 }
 
 TEST_F(CreateDirRequestHandlerTest, CreateOneAtExistedDirectory) {
@@ -482,7 +477,7 @@ TEST_F(CreateDirRequestHandlerTest, CreateOneAtExistedDirectory) {
   EXPECT_EQ(handler.Execute(),
       res_handler::ErrorType::ERROR_NONE);
 
-  EXPECT_TRUE(bf::exists(GetDstRootPath() / "existed_dir/new_dir"));
+  EXPECT_TRUE(fs::exists(GetDstRootPath() / "existed_dir/new_dir"));
 }
 
 TEST_F(CreateDirRequestHandlerTest, CreateHierachyAtRoot) {
@@ -494,11 +489,11 @@ TEST_F(CreateDirRequestHandlerTest, CreateHierachyAtRoot) {
   EXPECT_EQ(handler.Execute(),
       res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path(GetDstRootPath() / "new_dir");
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path(GetDstRootPath() / "new_dir");
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "another_new_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }
 
 TEST_F(CreateDirRequestHandlerTest, CreateHierachyAtExistedDirectory) {
@@ -510,9 +505,9 @@ TEST_F(CreateDirRequestHandlerTest, CreateHierachyAtExistedDirectory) {
   EXPECT_EQ(handler.Execute(),
       res_handler::ErrorType::ERROR_NONE);
 
-  bf::path check_path(GetDstRootPath() / "existed_dir/new_dir");
-  EXPECT_TRUE(bf::exists(check_path));
+  fs::path check_path(GetDstRootPath() / "existed_dir/new_dir");
+  EXPECT_TRUE(fs::exists(check_path));
 
   check_path /= "another_new_dir";
-  EXPECT_TRUE(bf::exists(check_path));
+  EXPECT_TRUE(fs::exists(check_path));
 }