Address more feedback

This commit is contained in:
Henrik Rydgård 2021-06-07 00:49:31 +02:00
parent c6163fd3e4
commit 308c7d693c
3 changed files with 15 additions and 15 deletions

View file

@ -38,6 +38,7 @@
#include <memory>
#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;

View file

@ -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...
}
}
}

View file

@ -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());
}
}