Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / utils / file_util.h
index 943f083..501633e 100644 (file)
@@ -5,8 +5,7 @@
 
 #include <sys/types.h>
 
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
 #include <string>
 #include <vector>
 
@@ -22,83 +21,85 @@ enum FSFlag : int {
 
 FSFlag operator|(FSFlag a, FSFlag b);
 
-bool SetOwnership(const boost::filesystem::path& path, uid_t uid, gid_t gid);
+bool SetOwnership(const std::filesystem::path& path, uid_t uid, gid_t gid);
 
-bool SetOwnershipAll(const boost::filesystem::path& path, uid_t uid, gid_t gid);
+bool SetOwnershipAll(const std::filesystem::path& path, uid_t uid, gid_t gid);
 
-bool CreateDir(const boost::filesystem::path& path);
+bool CreateDir(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 RestoreBackup(const boost::filesystem::path& path);
+bool RestoreBackup(const std::filesystem::path& path);
 
-bool MakeBackup(const boost::filesystem::path& path);
+bool MakeBackup(const std::filesystem::path& path);
 
-bool RemoveBackup(const boost::filesystem::path& path);
+bool RemoveBackup(const std::filesystem::path& path);
 
-bool RemoveAll(const boost::filesystem::path& path);
+bool RemoveAll(const std::filesystem::path& path);
 
-bool Remove(const boost::filesystem::path& path);
+bool Remove(const std::filesystem::path& path);
 
-bool MoveDir(const boost::filesystem::path& src,
-             const boost::filesystem::path& dst, FSFlag flags = FS_NONE);
+bool MoveDir(const std::filesystem::path& src,
+             const std::filesystem::path& dst, FSFlag flags = FS_NONE);
 
-bool MoveFile(const boost::filesystem::path& src,
-              const boost::filesystem::path& dst, bool force = false);
+bool MoveFile(const std::filesystem::path& src,
+              const std::filesystem::path& dst, bool force = false);
 
-bool BackupDir(const boost::filesystem::path& src,
-    const boost::filesystem::path& dst, const std::string& entry);
+bool BackupDir(const std::filesystem::path& src,
+    const std::filesystem::path& dst, const std::string& entry);
 
-bool SetDirPermissions(const boost::filesystem::path& path,
-                       boost::filesystem::perms permissions);
+bool SetDirPermissions(const std::filesystem::path& path,
+                       std::filesystem::perms permissions,
+                       bool add_perms = false);
 
-bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
-                      boost::filesystem::perms permissions, uid_t uid,
+bool SetDirOwnershipAndPermissions(const std::filesystem::path& path,
+                      std::filesystem::perms permissions, uid_t uid,
                       gid_t gid);
 
-bool CopyOwnershipAndPermissions(const boost::filesystem::path& src,
-                                 const boost::filesystem::path& dst);
+bool CopyOwnershipAndPermissions(const std::filesystem::path& src,
+                                 const std::filesystem::path& dst);
 
-int64_t GetUnpackedPackageSize(const boost::filesystem::path& path);
+int64_t GetUnpackedPackageSize(const std::filesystem::path& path);
 
-int64_t GetDirectorySize(const boost::filesystem::path& path);
+int64_t GetDirectorySize(const std::filesystem::path& path);
 
 bool CheckFreeSpaceAtPath(int64_t required_size,
-    const boost::filesystem::path& target_location);
+    const std::filesystem::path& target_location);
 
-boost::filesystem::path GenerateTmpDir(const boost::filesystem::path& app_path);
+std::filesystem::path GenerateTmpDir(const std::filesystem::path& app_path);
 
-boost::filesystem::path GenerateTemporaryPath(
-    const boost::filesystem::path& path);
+std::filesystem::path GenerateTemporaryPath(
+    const std::filesystem::path& path);
 
 bool ExtractToTmpDir(const char* zip_path,
-                     const boost::filesystem::path& tmp_dir);
+                     const std::filesystem::path& tmp_dir);
 
 bool ExtractToTmpDir(const char* zip_path,
-                     const boost::filesystem::path& tmp_dir,
+                     const std::filesystem::path& tmp_dir,
                      const std::string& filter_prefix);
 
 bool CheckPathInZipArchive(const char* zip_archive_path,
-                           const boost::filesystem::path& relative_zip_path,
+                           const std::filesystem::path& relative_zip_path,
                            bool* found);
 
-bool HasDirectoryClimbing(const boost::filesystem::path& path);
+bool HasDirectoryClimbing(const std::filesystem::path& path);
 
-boost::filesystem::path MakeRelativePath(const boost::filesystem::path& input,
-                                         const boost::filesystem::path& base);
+std::filesystem::path MakeRelativePath(const std::filesystem::path& input,
+                                         const std::filesystem::path& base);
 
-bool IsSubDir(const boost::filesystem::path& path,
-              const boost::filesystem::path& root);
+bool IsSubDir(const std::filesystem::path& path,
+              const std::filesystem::path& root);
 
-boost::filesystem::path RelativePath(const boost::filesystem::path& from,
-                                     const boost::filesystem::path& to);
+std::vector<std::string> GetDirectoryList(const std::filesystem::path& cwd);
 
-std::vector<std::string> GetDirectoryList(const boost::filesystem::path& cwd);
+std::filesystem::path GenerateUniquePathString(const std::string& format) ;
+
+bool SyncFile(const std::filesystem::path& path);
 
 }  // namespace common_installer