summaryrefslogtreecommitdiff
path: root/Source/Core/Common/File.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2020-12-10 16:32:43 -0500
committerGitHub <noreply@github.com>2020-12-10 16:32:43 -0500
commit75899b0e1121f01afdd606e1dd3a5822fa408530 (patch)
tree53f8c2ef2a5b61248f588aae625181233e487e1a /Source/Core/Common/File.cpp
parentcca04d36e21377f3292dbceb05f4768523f17df4 (diff)
parent161f8c3fad9df97ae4f97b7f45125e5e4c9608a7 (diff)
Merge pull request #9221 from JosJuice/android-saf-sd-card
Android: Use storage access framework for custom SD card paths
Diffstat (limited to 'Source/Core/Common/File.cpp')
-rw-r--r--Source/Core/Common/File.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/Source/Core/Common/File.cpp b/Source/Core/Common/File.cpp
index a724cbb723..c601eb33f2 100644
--- a/Source/Core/Common/File.cpp
+++ b/Source/Core/Common/File.cpp
@@ -18,7 +18,6 @@
#ifdef ANDROID
#include <algorithm>
-#include "Common/StringUtil.h"
#include "jni/AndroidCommon/AndroidCommon.h"
#endif
@@ -66,24 +65,17 @@ void IOFile::Swap(IOFile& other) noexcept
bool IOFile::Open(const std::string& filename, const char openmode[])
{
Close();
+
#ifdef _WIN32
m_good = _tfopen_s(&m_file, UTF8ToTStr(filename).c_str(), UTF8ToTStr(openmode).c_str()) == 0;
#else
#ifdef ANDROID
- if (StringBeginsWith(filename, "content://"))
- {
- // The Java method which OpenAndroidContent passes the mode to does not support the b specifier.
- // Since we're on POSIX, it's fine to just remove the b.
- std::string mode_without_b(openmode);
- mode_without_b.erase(std::remove(mode_without_b.begin(), mode_without_b.end(), 'b'),
- mode_without_b.end());
- m_file = fdopen(OpenAndroidContent(filename, mode_without_b), mode_without_b.c_str());
- }
+ if (IsPathAndroidContent(filename))
+ m_file = fdopen(OpenAndroidContent(filename, OpenModeToAndroid(openmode)), openmode);
else
#endif
- {
m_file = std::fopen(filename.c_str(), openmode);
- }
+
m_good = m_file != nullptr;
#endif