mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 02:33:43 +01:00
iOS: Fix opening files from iCloud and other secure places. Note: Not compatible with "Recents" yet.
This commit is contained in:
1 parent
e9cbd48ef7
commit
66b8e866fb
2 files changed
+18
-7
No files matched your search
@@ -155,6 +155,10 @@ bool TryUpdateSavedPath(Path *path) {
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
// DEBUG_LOG(Log::Loader, "Original path: %s", path->c_str());
|
||||
std::string pathStr = path->ToString();
|
||||
if (startsWith(pathStr, "/private/var/mobile/Containers/Data/Application/")) {
|
||||
// For in-application files only, strip off the /private prefix if present - it's sometimes there, sometimes not.
|
||||
pathStr = pathStr.substr(8);
|
||||
}
|
||||
|
||||
const std::string_view applicationRoot = "/var/mobile/Containers/Data/Application/";
|
||||
if (startsWith(pathStr, applicationRoot)) {
|
||||
|
||||
@@ -54,16 +54,23 @@ void DarwinFileSystemServices::ClearDelegate() {
|
||||
}
|
||||
|
||||
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
|
||||
std::string pathStr = urls[0].path.UTF8String;
|
||||
// Strip /private prefix if present.
|
||||
if (startsWith(pathStr, "/private/var/mobile/Containers/Data/Application/")) {
|
||||
pathStr = pathStr.substr(8);
|
||||
NSURL *url = urls.firstObject;
|
||||
if (!url) {
|
||||
self.panelCallback(false, Path());
|
||||
return;
|
||||
}
|
||||
|
||||
if (urls.count >= 1)
|
||||
self.panelCallback(true, Path(pathStr));
|
||||
else
|
||||
// 1. Start accessing the resource
|
||||
BOOL success = [url startAccessingSecurityScopedResource];
|
||||
if (success) {
|
||||
// 2. Pass the path to PPSSPP
|
||||
// Note: In a real app, you'd want to call stopAccessingSecurityScopedResource
|
||||
// when the game is closed, otherwise you "leak" kernel permissions.
|
||||
self.panelCallback(true, Path(url.path.UTF8String));
|
||||
} else {
|
||||
ERROR_LOG(Log::System, "Failed to start accessing security scoped resource for: %s", url.path.UTF8String);
|
||||
self.panelCallback(false, Path());
|
||||
}
|
||||
|
||||
INFO_LOG(Log::System, "Callback processed, pre-emptively hide keyboard");
|
||||
[sharedViewController hideKeyboard];
|
||||
|
||||
Reference in new issue
Block a user