From 825478bbf7f192fe00dee3a7bfa0b196fed6c7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 16 May 2021 00:14:37 +0200 Subject: [PATCH] Remove CreateDirIn, not useful enough to keep. --- Common/File/FileUtil.cpp | 44 +++------------------------------------ Common/File/FileUtil.h | 4 ---- android/jni/app-android.h | 1 + 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index a0b22ccc94..7d388bb13e 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -230,12 +230,6 @@ static void StripTailDirSlashes(std::string &fname) { // Returns true if file filename exists. Will return true on directories. bool ExistsInDir(const Path &path, const std::string &filename) { return Exists(path / filename); - if (Android_IsContentUri(path.ToString())) { - AndroidContentURI uri(path.ToString()); - return Exists(Path(uri.WithComponent(filename).ToString())); - } else { - return Exists(path / filename); - } } bool Exists(const std::string &filename) { @@ -248,6 +242,8 @@ bool Exists(const std::string &filename) { } std::string fn = filename; + + // TODO: Remove. StripTailDirSlashes(fn); #if defined(_WIN32) @@ -373,7 +369,7 @@ bool CreateDir(const Path &path) { break; // OK case PathType::CONTENT_URI: { - // Convert it to a CreateDirIn call, if possible, since that's + // Convert it to a "CreateDirIn" call, if possible, since that's // what we can do with the storage API. AndroidContentURI uri(path.ToString()); std::string newDirName = uri.GetLastPart(); @@ -419,40 +415,6 @@ bool CreateDir(const Path &path) { #endif } -// Returns true if successful, or path already exists. -// Supports Android Content Storage URIs more reliably than CreateDir. -bool CreateDirIn(const std::string &parentDir, const std::string &newDirName) { - if (Android_IsContentUri(parentDir)) { - return Android_CreateDirectory(parentDir, newDirName); - } - std::string fn = parentDir; - StripTailDirSlashes(fn); - DEBUG_LOG(COMMON, "CreateDir('%s')", fn.c_str()); -#ifdef _WIN32 - std::string fullName = parentDir + "\\" + newDirName; - if (::CreateDirectory(ConvertUTF8ToWString(fullName).c_str(), NULL)) - return true; - DWORD error = GetLastError(); - if (error == ERROR_ALREADY_EXISTS) { - WARN_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: already exists", fullName.c_str()); - return true; - } - ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %08x", fullName.c_str(), (uint32_t)error); - return false; -#else - std::string fullName = parentDir + "/" + newDirName; - if (mkdir(fullName.c_str(), 0755) == 0) - return true; - int err = errno; - if (err == EEXIST) { - WARN_LOG(COMMON, "CreateDir: mkdir failed on %s: already exists", fullName.c_str()); - return true; - } - ERROR_LOG(COMMON, "CreateDir: mkdir failed on %s: %s", fullName.c_str(), strerror(err)); - return false; -#endif -} - // Creates the full path of fullPath returns true on success bool CreateFullPath(const Path &path) { switch (path.Type()) { diff --git a/Common/File/FileUtil.h b/Common/File/FileUtil.h index 9086140fe7..4ca7c7df21 100644 --- a/Common/File/FileUtil.h +++ b/Common/File/FileUtil.h @@ -67,10 +67,6 @@ uint64_t GetFileSize(FILE *f); // Returns true if successful, or path already exists. bool CreateDir(const Path &filename); -// Returns true if successful, or path already exists. -// Supports Android Content Storage URIs, unlike CreateDir. -bool CreateDirIn(const std::string &parentDir, const std::string &newDirName); - // Creates the full path of fullPath returns true on success bool CreateFullPath(const Path &fullPath); diff --git a/android/jni/app-android.h b/android/jni/app-android.h index b46331b197..b7cc5f56d6 100644 --- a/android/jni/app-android.h +++ b/android/jni/app-android.h @@ -8,6 +8,7 @@ #include "Common/LogManager.h" #include "Common/File/DirListing.h" +#include "Common/File/Path.h" // To emphasize that Android storage mode strings are different, let's just use // an enum.