Kaynağa Gözat

Revert "Merge pull request #5174 from ReinUsesLisp/fs-fix"

This reverts commit 5fe55b16a11d9ec607fb8a3fdddc77a4393cd96a, reversing
changes made to e94dd7e2c4fc3f7ca2c15c01bdc301be2b8a4c1b.
Morph 5 yıl önce
ebeveyn
işleme
8941cdb7d2
2 değiştirilmiş dosya ile 4 ekleme ve 36 silme
  1. 2 28
      src/common/file_util.cpp
  2. 2 8
      src/common/file_util.h

+ 2 - 28
src/common/file_util.cpp

@@ -98,11 +98,6 @@ bool Delete(const fs::path& path) {
 bool CreateDir(const fs::path& path) {
     LOG_TRACE(Common_Filesystem, "directory {}", path.string());
 
-    if (Exists(path)) {
-        LOG_DEBUG(Common_Filesystem, "path exists {}", path.string());
-        return true;
-    }
-
     std::error_code ec;
     const bool success = fs::create_directory(path, ec);
 
@@ -114,41 +109,20 @@ bool CreateDir(const fs::path& path) {
     return true;
 }
 
-bool CreateDirs(const fs::path& path) {
+bool CreateFullPath(const fs::path& path) {
     LOG_TRACE(Common_Filesystem, "path {}", path.string());
 
-    if (Exists(path)) {
-        LOG_DEBUG(Common_Filesystem, "path exists {}", path.string());
-        return true;
-    }
-
     std::error_code ec;
     const bool success = fs::create_directories(path, ec);
 
     if (!success) {
-        LOG_ERROR(Common_Filesystem, "Unable to create directories: {}", ec.message());
+        LOG_ERROR(Common_Filesystem, "Unable to create full path: {}", ec.message());
         return false;
     }
 
     return true;
 }
 
-bool CreateFullPath(const fs::path& path) {
-    LOG_TRACE(Common_Filesystem, "path {}", path);
-
-    // Removes trailing slashes and turns any '\' into '/'
-    const auto new_path = SanitizePath(path.string(), DirectorySeparator::ForwardSlash);
-
-    if (new_path.rfind('.') == std::string::npos) {
-        // The path is a directory
-        return CreateDirs(new_path);
-    } else {
-        // The path is a file
-        // Creates directory preceding the last '/'
-        return CreateDirs(new_path.substr(0, new_path.rfind('/')));
-    }
-}
-
 bool Rename(const fs::path& src, const fs::path& dst) {
     LOG_TRACE(Common_Filesystem, "{} --> {}", src.string(), dst.string());
 

+ 2 - 8
src/common/file_util.h

@@ -54,14 +54,8 @@ enum class UserPath {
 // Returns true if successful, or path already exists.
 bool CreateDir(const std::filesystem::path& path);
 
-// Create all directories in path
-// Returns true if successful, or path already exists.
-[[nodiscard("Directory creation can fail and must be tested")]] bool CreateDirs(
-    const std::filesystem::path& path);
-
-// Creates directories in path. Returns true on success.
-[[deprecated("This function is deprecated, use CreateDirs")]] bool CreateFullPath(
-    const std::filesystem::path& path);
+// Creates the full path of path. Returns true on success
+bool CreateFullPath(const std::filesystem::path& path);
 
 // Deletes a given file at the path.
 // This will also delete empty directories.