Address more feedback, warning fix

This commit is contained in:
Henrik Rydgård 2021-06-06 10:50:58 +02:00
parent 37d651a89d
commit 3737daaf0c
9 changed files with 42 additions and 35 deletions

View file

@ -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<std::string> 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<File::FileInfo> 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);
}
}

View file

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

View file

@ -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://
};

View file

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

View file

@ -962,9 +962,6 @@
<ClCompile Include="Debugger\WebSocket\MemoryInfoSubscriber.cpp">
<Filter>Debugger\WebSocket</Filter>
</ClCompile>
<ClCompile Include="FileSystems\AndroidStorageFileSystem.cpp">
<Filter>FileSystems</Filter>
</ClCompile>
<ClCompile Include="..\ext\libzip\zip_utf-8.c">
<Filter>Ext\libzip</Filter>
</ClCompile>
@ -1877,9 +1874,6 @@
<ClInclude Include="Debugger\WebSocket\MemoryInfoSubscriber.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>
<ClInclude Include="FileSystems\AndroidStorageFileSystem.h">
<Filter>FileSystems</Filter>
</ClInclude>
<ClInclude Include="..\ext\libzip\zip_source_file_win32.h">
<Filter>Ext\libzip</Filter>
</ClInclude>

View file

@ -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!@#$%^&'(){}-_`~";

View file

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

View file

@ -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 {

View file

@ -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 {