Move GetLightUserList() to user_util.h
[platform/core/appfw/app-installers.git] / src / common / utils / file_util.h
index 183da45..45e943c 100644 (file)
@@ -3,31 +3,74 @@
 #ifndef COMMON_UTILS_FILE_UTIL_H_
 #define COMMON_UTILS_FILE_UTIL_H_
 
+#include <sys/types.h>
+
 #include <boost/filesystem.hpp>
 #include <boost/filesystem/path.hpp>
 #include <string>
+#include <vector>
 
 namespace common_installer {
 
+enum FSFlag : int {
+  FS_NONE              = 0,
+  FS_MERGE_SKIP        = (1 << 0),
+  FS_MERGE_OVERWRITE   = (1 << 1),
+  FS_COMMIT_COPY_FILE  = (1 << 2),
+  FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS = (1 << 3)
+};
+
+FSFlag operator|(FSFlag a, FSFlag b);
+
+bool SetOwnership(const boost::filesystem::path& path, uid_t uid, gid_t gid);
+
+bool SetOwnershipAll(const boost::filesystem::path& path, uid_t uid, gid_t gid);
+
 bool CreateDir(const boost::filesystem::path& path);
 
 bool CopyDir(const boost::filesystem::path& src,
-             const boost::filesystem::path& dst);
+             const boost::filesystem::path& dst,
+             FSFlag flags = FS_NONE, bool skip_symlink = false);
 
 bool CopyFile(const boost::filesystem::path& src,
              const boost::filesystem::path& dst);
 
+bool RestoreBackup(const boost::filesystem::path& path);
+
+bool MakeBackup(const boost::filesystem::path& path);
+
+bool RemoveBackup(const boost::filesystem::path& path);
+
+bool RemoveAll(const boost::filesystem::path& path);
+
+bool Remove(const boost::filesystem::path& path);
+
 bool MoveDir(const boost::filesystem::path& src,
-             const boost::filesystem::path& dst);
+             const boost::filesystem::path& dst, FSFlag flags = FS_NONE);
 
 bool MoveFile(const boost::filesystem::path& src,
-              const boost::filesystem::path& dst);
+              const boost::filesystem::path& dst, bool force = false);
+
+bool BackupDir(const boost::filesystem::path& src,
+    const boost::filesystem::path& dst, const std::string& entry);
 
 bool SetDirPermissions(const boost::filesystem::path& path,
                        boost::filesystem::perms permissions);
 
+bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
+                      boost::filesystem::perms permissions, uid_t uid,
+                      gid_t gid);
+
+bool CopyOwnershipAndPermissions(const boost::filesystem::path& src,
+                                 const boost::filesystem::path& dst);
+
 int64_t GetUnpackedPackageSize(const boost::filesystem::path& path);
 
+int64_t GetDirectorySize(const boost::filesystem::path& path);
+
+bool CheckFreeSpaceAtPath(int64_t required_size,
+    const boost::filesystem::path& target_location);
+
 boost::filesystem::path GenerateTmpDir(const boost::filesystem::path& app_path);
 
 boost::filesystem::path GenerateTemporaryPath(
@@ -40,11 +83,21 @@ bool ExtractToTmpDir(const char* zip_path,
                      const boost::filesystem::path& tmp_dir,
                      const std::string& filter_prefix);
 
+bool CheckPathInZipArchive(const char* zip_archive_path,
+                           const boost::filesystem::path& relative_zip_path,
+                           bool* found);
+
 bool HasDirectoryClimbing(const boost::filesystem::path& path);
 
 boost::filesystem::path MakeRelativePath(const boost::filesystem::path& input,
                                          const boost::filesystem::path& base);
 
+bool IsSubDir(const boost::filesystem::path& path,
+              const boost::filesystem::path& root);
+
+boost::filesystem::path RelativePath(const boost::filesystem::path& from,
+                                     const boost::filesystem::path& to);
+
 }  // namespace common_installer
 
 #endif  // COMMON_UTILS_FILE_UTIL_H_