diff --git a/Common/File/AndroidStorage.cpp b/Common/File/AndroidStorage.cpp index 5112fee7e9..deacb16e1a 100644 --- a/Common/File/AndroidStorage.cpp +++ b/Common/File/AndroidStorage.cpp @@ -99,7 +99,6 @@ bool Android_RemoveFile(const std::string &fileUri) { } static bool ParseFileInfo(const std::string &line, File::FileInfo *fileInfo) { - INFO_LOG(FILESYS, "!! %s", line.c_str()); std::vector parts; SplitString(line, '|', parts); if (parts.size() != 5) { @@ -109,10 +108,10 @@ static bool ParseFileInfo(const std::string &line, File::FileInfo *fileInfo) { fileInfo->name = std::string(parts[2]); fileInfo->isDirectory = parts[0][0] == 'D'; fileInfo->exists = true; - sscanf(parts[1].c_str(), "%ld", &fileInfo->size); + sscanf(parts[1].c_str(), "%" PRIu64, &fileInfo->size); fileInfo->fullName = Path(parts[3]); - fileInfo->isWritable = false; // TODO: We don't yet request write access - sscanf(parts[4].c_str(), "%ld", &fileInfo->lastModified); + fileInfo->isWritable = true; // TODO: Should be passed as part of the string. + sscanf(parts[4].c_str(), "%" PRIu64, &fileInfo->lastModified); return true; } @@ -151,9 +150,8 @@ std::vector Android_ListContentUri(const std::string &path) { jstring str = (jstring)env->GetObjectArrayElement(fileList, i); const char *charArray = env->GetStringUTFChars(str, 0); if (charArray) { // paranoia - std::string file = charArray; File::FileInfo info; - if (ParseFileInfo(file, &info)) { + if (ParseFileInfo(std::string(charArray), &info)) { items.push_back(info); } } diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 1131e34fab..bfe168a33d 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -130,7 +130,7 @@ FILE *OpenCFile(const Path &path, const char *mode) { INFO_LOG(COMMON, "Opening file by fd for write"); } - // Read, let's support this - easy one. + // TODO: Support append modes and stuff... For now let's go with the most common one. int descriptor = Android_OpenContentUriFd(path.ToString(), Android_OpenContentUriMode::READ_WRITE_TRUNCATE); if (descriptor == -1) { INFO_LOG(COMMON, "Opening '%s' for write failed", path.ToString().c_str()); @@ -143,7 +143,7 @@ FILE *OpenCFile(const Path &path, const char *mode) { } break; default: - ERROR_LOG(COMMON, "OpenCFile(%s): Not yet supported", path.c_str()); + ERROR_LOG(COMMON, "OpenCFile(%s): PathType not yet supported", path.c_str()); return nullptr; } @@ -163,13 +163,23 @@ int OpenFD(const Path &path, OpenFlag flags) { return -1; } - if (flags != OPEN_READ) { - // TODO - ERROR_LOG(COMMON, "Modes other than plain OPEN_READ not yet supported"); + Android_OpenContentUriMode mode; + if (flags == OPEN_READ) { + mode = Android_OpenContentUriMode::READ; + } else if (flags & OPEN_WRITE) { + if (flags & OPEN_TRUNCATE) { + mode = Android_OpenContentUriMode::READ_WRITE; + } else { + mode = Android_OpenContentUriMode::READ_WRITE_TRUNCATE; + } + // 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); return -1; } - int descriptor = Android_OpenContentUriFd(path.ToString(), Android_OpenContentUriMode::READ); + int descriptor = Android_OpenContentUriFd(path.ToString(), mode); return descriptor; } @@ -305,7 +315,7 @@ bool IsDirectory(const Path &filename) { if (!Android_GetFileInfo(filename.ToString(), &info)) { return false; } - return info.isDirectory; + return info.exists && info.isDirectory; } default: return false; @@ -341,10 +351,7 @@ bool Delete(const Path &filename) { case PathType::NATIVE: break; // OK case PathType::CONTENT_URI: - { - FileInfo info; return Android_RemoveFile(filename.ToString()); - } default: return false; } diff --git a/Common/File/Path.h b/Common/File/Path.h index 5070ca2bef..53fc8745e2 100644 --- a/Common/File/Path.h +++ b/Common/File/Path.h @@ -6,9 +6,8 @@ enum class PathType { UNDEFINED = 0, - NATIVE = 1, - // RELATIVE, // (do we need this?) - CONTENT_URI = 2, // Android only + NATIVE = 1, // Can be relative. + CONTENT_URI = 2, // Android only. Can only be absolute! HTTP = 3, // http://, https:// }; diff --git a/Core/Config.cpp b/Core/Config.cpp index 634ed94abd..b8b08d8d9e 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1246,7 +1246,6 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { iRunCount++; - // TODO: What layer's responsibility is it to handle content:// URIs? // This check is probably not really necessary here anyway, you can always // press Home or Browse if you're in a bad directory. if (!File::Exists(currentDirectory)) @@ -1254,7 +1253,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { Section *log = iniFile.GetOrCreateSection(logSectionName); - bool debugDefaults = true; + bool debugDefaults = false; #ifdef _DEBUG debugDefaults = true; #endif diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index e54ac5b2ea..9102da39e0 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -962,9 +962,6 @@ Debugger\WebSocket - - FileSystems - Ext\libzip @@ -1877,9 +1874,6 @@ Debugger\WebSocket - - FileSystems - Ext\libzip diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index d328c37d1b..614d5d664e 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -280,12 +280,20 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File flags |= File::OPEN_TRUNCATE; int fd = File::OpenFD(fullName, (File::OpenFlag)flags); - hFile = fd; // Try to detect reads/writes to PSP/GAME to avoid them in replays. if (fullName.FilePathContains("PSP/GAME/")) { inGameDir_ = true; } - return fd != -1; + hFile = fd; + if (fd != -1) { + // Success + return true; + } else { + // TODO: Need better error codes from OpenFD so we can distinguish + // disk full. Just set not found for now. + error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND; + return false; + } } int flags = 0; @@ -814,7 +822,7 @@ static void tmFromFiletime(tm &dest, FILETIME &src) { // // Note: PSP-created files would stay lowercase, but this uppercases them too. // Hopefully no PSP games read directories after they create files in them... -std::string SimulateVFATBug(std::string filename) { +static std::string SimulateVFATBug(std::string filename) { // These are the characters allowed in DOS filenames. static const char *FAT_UPPER_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&'(){}-_`~"; static const char *FAT_LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&'(){}-_`~"; diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index effd1d31b0..96688e9cdd 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -153,8 +153,6 @@ void GameManager::Update() { INFO_LOG(HLE, "Download completed! Status = %d", curDownload_->ResultCode()); Path fileName = curDownload_->outfile(); if (curDownload_->ResultCode() == 200) { - // TODO: This fails. Wonder if there's a race condition? - if (!File::Exists(fileName)) { ERROR_LOG(HLE, "Downloaded file '%s' does not exist :(", fileName.c_str()); curDownload_.reset(); diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index aae8330fd0..a09a5e759a 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -136,10 +136,13 @@ public class PpssppActivity extends NativeActivity { private static String fileInfoToString(DocumentFile file) { String str = "F|"; - if (file.isDirectory()) { + if (file.isVirtual()) { + // This we don't want to see. + str = "V|"; + Log.e(TAG, "Got virtual file: " + file.getUri()); + } else if (file.isDirectory()) { str = "D|"; } - // TODO: Should we do something with child.isVirtual()?. str += file.length() + "|" + file.getName() + "|" + file.getUri() + "|" + file.lastModified(); return str; } @@ -186,6 +189,7 @@ public class PpssppActivity extends NativeActivity { Uri uri = Uri.parse(rootTreeUri); DocumentFile documentFile = DocumentFile.fromTreeUri(this, uri); if (documentFile != null) { + // TODO: Check the file extension and choose MIME type appropriately. DocumentFile createdFile = documentFile.createFile("application/octet-stream", fileName); return createdFile != null; } else { diff --git a/ext/gason/gason.h b/ext/gason/gason.h index 7c3eed96f6..1f1cd976a2 100644 --- a/ext/gason/gason.h +++ b/ext/gason/gason.h @@ -29,7 +29,7 @@ union JsonValue { : fval(x) { } JsonValue(JsonTag tag = JSON_NULL, void *payload = nullptr) { - assert((uintptr_t)payload <= JSON_VALUE_PAYLOAD_MASK); + assert((uint64_t)payload <= JSON_VALUE_PAYLOAD_MASK); ival = JSON_VALUE_NAN_MASK | ((uint64_t)tag << JSON_VALUE_TAG_SHIFT) | (uintptr_t)payload; } bool isDouble() const {