Remove CreateDirIn, not useful enough to keep.

This commit is contained in:
Henrik Rydgård committed 2021-06-07 00:24:51 +02:00
1 parent 5e3019073c
commit 825478bbf7
3 files changed
+4 -45

No files matched your search

+3 -41
View File
@@ -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()) {
-4
View File
@@ -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);
+1
View File
@@ -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.