From 308c7d693c3d7f35fcaac140e7102be9610401e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 7 Jun 2021 00:49:31 +0200 Subject: [PATCH] Address more feedback --- Common/File/FileUtil.cpp | 16 ++++++---------- UI/NativeApp.cpp | 7 +++++-- .../src/org/ppsspp/ppsspp/NativeActivity.java | 7 ++++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index bfe168a33d..bdd64d96c5 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -38,6 +38,7 @@ #include #include "Common/Log.h" +#include "Common/LogReporting.h" #include "Common/File/FileUtil.h" #include "Common/StringUtils.h" #include "Common/SysError.h" @@ -123,7 +124,7 @@ FILE *OpenCFile(const Path &path, const char *mode) { return nullptr; } } else { - INFO_LOG(COMMON, "Failed to navigate up to create file"); + INFO_LOG_REPORT_ONCE(openCFileFailedNavigateUp, COMMON, "Failed to navigate up to create file: %s", path.c_str()); return nullptr; } } else { @@ -175,7 +176,7 @@ int OpenFD(const Path &path, OpenFlag flags) { // TODO: Maybe better checking of additional flags here. } else { // TODO: Add support for more modes if possible. - ERROR_LOG(COMMON, "OpenFlag 0x%x not yet supported", flags); + ERROR_LOG_REPORT_ONCE(openFlagNotSupported, COMMON, "OpenFlag 0x%x not yet supported", flags); return -1; } @@ -471,17 +472,12 @@ bool CreateFullPath(const Path &path) { } Path curPath = root; - - INFO_LOG(COMMON, "About to create folder tree '%s', rooted at '%s'", path.c_str(), root.c_str()); - for (auto &part : parts) { curPath /= part; if (!File::Exists(curPath)) { - INFO_LOG(COMMON, "Creating folder '%s', doesn't already exist", curPath.c_str()); File::CreateDir(curPath); } } - INFO_LOG(COMMON, "Done"); return true; } @@ -528,7 +524,7 @@ bool Rename(const Path &srcFilename, const Path &destFilename) case PathType::NATIVE: break; // OK case PathType::CONTENT_URI: - ERROR_LOG(COMMON, "Moving files by Android URI is not yet supported"); + ERROR_LOG_REPORT_ONCE(renameUriNotSupported, COMMON, "Moving files by Android URI is not yet supported"); return false; default: return false; @@ -558,7 +554,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) case PathType::NATIVE: break; // OK case PathType::CONTENT_URI: - ERROR_LOG(COMMON, "Copying files by Android URI is not yet supported"); + ERROR_LOG_REPORT_ONCE(copyUriNotSupported, COMMON, "Copying files by Android URI is not yet supported"); break; default: return false; @@ -567,7 +563,7 @@ bool Copy(const Path &srcFilename, const Path &destFilename) case PathType::NATIVE: break; // OK case PathType::CONTENT_URI: - ERROR_LOG(COMMON, "Copying files by Android URI is not yet supported"); + ERROR_LOG_REPORT_ONCE(copyUriNotSupported, COMMON, "Copying files by Android URI is not yet supported"); return false; default: return false; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 749b83cb27..b8e1b67f0e 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -342,7 +342,10 @@ static bool CreateDirectoriesAndroid() { // On Android, create a PSP directory tree in the external_dir, // to hopefully reduce confusion a bit. - Path pspDir = g_Config.memStickDirectory / "PSP"; + Path pspDir = g_Config.memStickDirectory; + if (pspDir.GetFilename() != "PSP") { + pspDir /= "PSP"; + } INFO_LOG(IO, "Creating '%s' and subdirs:", pspDir.c_str()); File::CreateFullPath(pspDir); @@ -525,7 +528,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch } else { ERROR_LOG(SYSTEM, "Couldn't read directory '%s' specified by memstick_dir.txt.", memstickDir.c_str()); if (System_GetPropertyBool(SYSPROP_ANDROID_SCOPED_STORAGE)) { - // + // TODO: Gotta resolve this somehow... } } } diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 9b6084c365..6a1b82bf67 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -1157,15 +1157,16 @@ public abstract class NativeActivity extends Activity { if (selectedDirectoryUri != null) { String path = selectedDirectoryUri.toString(); Log.i(TAG, "Browse folder finished: " + path); - Log.i(TAG, "is tree:" + DocumentsContract.isTreeUri(selectedDirectoryUri)); - getContentResolver().takePersistableUriPermission(selectedDirectoryUri, Intent.FLAG_GRANT_READ_URI_PERMISSION); - + getContentResolver().takePersistableUriPermission(selectedDirectoryUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); DocumentFile documentFile = DocumentFile.fromTreeUri(this, selectedDirectoryUri); Log.i(TAG, "Document name: " + documentFile.getUri()); + /* + // Old debug log DocumentFile[] children = documentFile.listFiles(); for (DocumentFile child : children) { Log.i(TAG, "Child: " + child.getUri() + " " + child.getName()); } + */ NativeApp.sendMessage("browse_folderSelect", documentFile.getUri().toString()); } }