mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 18:49:51 +01:00
Merge pull request #21294 from hrydgard/filesystem-times
Add compat flag to freeze reported file creation times. Helps Silent Hill: Shattered Memories
This commit is contained in:
6 files changed
+74
-53
No files matched your search
+29
-30
@@ -67,6 +67,29 @@ static uint64_t FiletimeToStatTime(FILETIME ft, int* out_usec) {
|
||||
|
||||
return (uint64_t)(ticks / windowsTickResolution - secToUnixEpoch);
|
||||
}
|
||||
|
||||
// This is used for both WIN32_FILE_ATTRIBUTE_DATA and WIN32_FIND_DATA, which have the same time and size fields.
|
||||
template<class T>
|
||||
void ReadFileAttributes(FileInfo *fileInfo, const T &attrs) {
|
||||
fileInfo->atime = FiletimeToStatTime(attrs.ftLastAccessTime, &fileInfo->atimeUs);
|
||||
fileInfo->mtime = FiletimeToStatTime(attrs.ftLastWriteTime, &fileInfo->mtimeUs);
|
||||
fileInfo->ctime = FiletimeToStatTime(attrs.ftCreationTime, &fileInfo->ctimeUs);
|
||||
|
||||
fileInfo->exists = true;
|
||||
fileInfo->size = ((uint64_t)attrs.nFileSizeHigh << 32) | attrs.nFileSizeLow;
|
||||
fileInfo->isDirectory = (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
fileInfo->isWritable = (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
|
||||
if (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
|
||||
fileInfo->access = 0444; // Read
|
||||
} else {
|
||||
fileInfo->access = 0666; // Read/Write
|
||||
}
|
||||
if (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
fileInfo->access |= 0111; // Execute
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool GetFileInfo(const Path &path, FileInfo * fileInfo) {
|
||||
@@ -101,21 +124,9 @@ bool GetFileInfo(const Path &path, FileInfo * fileInfo) {
|
||||
fileInfo->exists = false;
|
||||
return false;
|
||||
}
|
||||
fileInfo->size = (uint64_t)attrs.nFileSizeLow | ((uint64_t)attrs.nFileSizeHigh << 32);
|
||||
fileInfo->isDirectory = (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
fileInfo->isWritable = (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
fileInfo->exists = true;
|
||||
fileInfo->atime = FiletimeToStatTime(attrs.ftLastAccessTime, &fileInfo->atimeUs);
|
||||
fileInfo->mtime = FiletimeToStatTime(attrs.ftLastWriteTime, &fileInfo->mtimeUs);
|
||||
fileInfo->ctime = FiletimeToStatTime(attrs.ftCreationTime, &fileInfo->ctimeUs);
|
||||
if (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
|
||||
fileInfo->access = 0444; // Read
|
||||
} else {
|
||||
fileInfo->access = 0666; // Read/Write
|
||||
}
|
||||
if (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
fileInfo->access |= 0111; // Execute
|
||||
}
|
||||
|
||||
ReadFileAttributes(fileInfo, attrs);
|
||||
|
||||
#else
|
||||
|
||||
#if (defined __ANDROID__) && (__ANDROID_API__ < 21)
|
||||
@@ -313,21 +324,9 @@ bool GetFilesInDir(const Path &directory, std::vector<FileInfo> *files, const ch
|
||||
FileInfo info;
|
||||
info.name = virtualName;
|
||||
info.fullName = directory / virtualName;
|
||||
info.exists = true;
|
||||
info.size = ((uint64_t)ffd.nFileSizeHigh << 32) | ffd.nFileSizeLow;
|
||||
info.isDirectory = (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
info.isWritable = (ffd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
info.atime = FiletimeToStatTime(ffd.ftLastAccessTime, &info.atimeUs);
|
||||
info.mtime = FiletimeToStatTime(ffd.ftLastWriteTime, &info.mtimeUs);
|
||||
info.ctime = FiletimeToStatTime(ffd.ftCreationTime, &info.ctimeUs);
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
|
||||
info.access = 0444; // Read
|
||||
} else {
|
||||
info.access = 0666; // Read/Write
|
||||
}
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
info.access |= 0111; // Execute
|
||||
}
|
||||
|
||||
ReadFileAttributes(&info, ffd);
|
||||
|
||||
if (!info.isDirectory) {
|
||||
std::string ext = info.fullName.GetFileExtension();
|
||||
if (!ext.empty()) {
|
||||
|
||||
@@ -162,6 +162,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
|
||||
CheckSetting(iniFile, gameID, "DetectDestBlendSquared", &flags_.DetectDestBlendSquared);
|
||||
CheckSetting(iniFile, gameID, "BoostExactFramebufferMatch", &flags_.BoostExactFramebufferMatch);
|
||||
CheckSetting(iniFile, gameID, "PersistentFramebuffers", &flags_.PersistentFramebuffers);
|
||||
CheckSetting(iniFile, gameID, "FileCreatedTimeHack", &flags_.FileCreatedTimeHack);
|
||||
}
|
||||
|
||||
void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) {
|
||||
|
||||
@@ -121,6 +121,7 @@ struct CompatFlags {
|
||||
bool DetectDestBlendSquared;
|
||||
bool BoostExactFramebufferMatch;
|
||||
bool PersistentFramebuffers;
|
||||
bool FileCreatedTimeHack;
|
||||
};
|
||||
|
||||
struct VRCompat {
|
||||
|
||||
@@ -1236,7 +1236,11 @@ bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
{
|
||||
entries[i].st_mode = 0x11FF;
|
||||
if (sfoFiles[i].exists) {
|
||||
ConvertTmToPspDateTime(entries[i].st_ctime, sfoFiles[i].ctime, sfoFiles[i].ctimeUs);
|
||||
tm ctime = sfoFiles[i].ctime;
|
||||
if (PSP_CoreParameter().compat.flags().FileCreatedTimeHack) {
|
||||
ctime = {};
|
||||
}
|
||||
ConvertTmToPspDateTime(entries[i].st_ctime, ctime, sfoFiles[i].ctimeUs);
|
||||
ConvertTmToPspDateTime(entries[i].st_atime, sfoFiles[i].atime, sfoFiles[i].atimeUs);
|
||||
ConvertTmToPspDateTime(entries[i].st_mtime, sfoFiles[i].mtime, sfoFiles[i].mtimeUs);
|
||||
} else {
|
||||
@@ -1257,7 +1261,7 @@ bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
if (GenericLogEnabled(Log::sceUtility, LogLevel::LINFO)) {
|
||||
INFO_LOG(Log::sceUtility, "LIST (searchstring=%s): %d files (max: %d)", searchString.c_str(), param->idList->resultCount, maxFileCount);
|
||||
for (int i = 0; i < validDir.size(); i++) {
|
||||
INFO_LOG(Log::sceUtility, "%s: mode %08x, ctime: %s, atime: %s, mtime: %s",
|
||||
NOTICE_LOG(Log::sceUtility, "LIST %s: mode %08x, ctime: %s, atime: %s, mtime: %s",
|
||||
entries[i].name, entries[i].st_mode, FmtPspTime(entries[i].st_ctime).c_str(), FmtPspTime(entries[i].st_atime).c_str(), FmtPspTime(entries[i].st_mtime).c_str());
|
||||
}
|
||||
}
|
||||
@@ -1326,18 +1330,18 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr)
|
||||
|
||||
// Does not list directories, nor recurse into them, and ignores files not ALL UPPERCASE.
|
||||
bool isCrypted = GetSaveCryptMode(param, GetSaveDirName(param, 0)) != 0;
|
||||
for (auto file = files.begin(), end = files.end(); file != end; ++file) {
|
||||
if (file->type == FILETYPE_DIRECTORY) {
|
||||
for (const auto &file : files) {
|
||||
if (file.type == FILETYPE_DIRECTORY) {
|
||||
continue;
|
||||
}
|
||||
// TODO: What are the exact rules? It definitely skips lowercase, and allows FILE or FILE.EXT.
|
||||
if (file->name.find_first_of("abcdefghijklmnopqrstuvwxyz") != file->name.npos) {
|
||||
DEBUG_LOG(Log::sceUtility, "SavedataParam::GetFilesList(): skipping file %s with lowercase", file->name.c_str());
|
||||
if (file.name.find_first_of("abcdefghijklmnopqrstuvwxyz") != file.name.npos) {
|
||||
DEBUG_LOG(Log::sceUtility, "SavedataParam::GetFilesList(): skipping file %s with lowercase", file.name.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isSystemFile = file->name == ICON0_FILENAME || file->name == ICON1_FILENAME || file->name == PIC1_FILENAME;
|
||||
isSystemFile = isSystemFile || file->name == SND0_FILENAME || file->name == SFO_FILENAME;
|
||||
bool isSystemFile = file.name == ICON0_FILENAME || file.name == ICON1_FILENAME || file.name == PIC1_FILENAME;
|
||||
isSystemFile = isSystemFile || file.name == SND0_FILENAME || file.name == SFO_FILENAME;
|
||||
|
||||
SceUtilitySavedataFileListEntry *entry = NULL;
|
||||
int sizeOffset = 0;
|
||||
@@ -1345,7 +1349,7 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr)
|
||||
if (fileList->systemEntries.IsValid() && fileList->resultNumSystemEntries < fileList->maxSystemEntries) {
|
||||
entry = &fileList->systemEntries[fileList->resultNumSystemEntries++];
|
||||
}
|
||||
} else if (secureFilenames.find(file->name) != secureFilenames.end()) {
|
||||
} else if (secureFilenames.find(file.name) != secureFilenames.end()) {
|
||||
if (fileList->secureEntries.IsValid() && fileList->resultNumSecureEntries < fileList->maxSecureEntries) {
|
||||
entry = &fileList->secureEntries[fileList->resultNumSecureEntries++];
|
||||
}
|
||||
@@ -1360,17 +1364,24 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr)
|
||||
}
|
||||
|
||||
// Out of space for this file in the list.
|
||||
if (entry == NULL) {
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entry->st_mode = 0x21FF;
|
||||
entry->st_size = file->size + sizeOffset;
|
||||
ConvertTmToPspDateTime(entry->st_ctime, file->ctime, file->ctimeUs);
|
||||
ConvertTmToPspDateTime(entry->st_atime, file->atime, file->atimeUs);
|
||||
ConvertTmToPspDateTime(entry->st_mtime, file->mtime, file->mtimeUs);
|
||||
entry->st_size = file.size + sizeOffset;
|
||||
|
||||
tm ctime = file.ctime;
|
||||
if (PSP_CoreParameter().compat.flags().FileCreatedTimeHack) {
|
||||
ctime = {};
|
||||
}
|
||||
|
||||
ConvertTmToPspDateTime(entry->st_ctime, ctime, file.ctimeUs);
|
||||
ConvertTmToPspDateTime(entry->st_atime, file.atime, file.atimeUs);
|
||||
ConvertTmToPspDateTime(entry->st_mtime, file.mtime, file.mtimeUs);
|
||||
|
||||
// TODO: Probably actually 13 + 3 pad...
|
||||
strncpy(entry->name, file->name.c_str(), 16);
|
||||
strncpy(entry->name, file.name.c_str(), 16);
|
||||
entry->name[15] = '\0';
|
||||
}
|
||||
|
||||
@@ -1379,7 +1390,7 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr)
|
||||
if (fileList->normalEntries.IsValid()) {
|
||||
for (int i = 0; i < (int)fileList->resultNumNormalEntries; i++) {
|
||||
const SceUtilitySavedataFileListEntry &info = fileList->normalEntries[i];
|
||||
INFO_LOG(Log::sceUtility, "%s: mode %08x, ctime: %s, atime: %s, mtime: %s",
|
||||
NOTICE_LOG(Log::sceUtility, "FILES: %s: mode %08x, ctime: %s, atime: %s, mtime: %s",
|
||||
info.name, info.st_mode, FmtPspTime(info.st_ctime).c_str(), FmtPspTime(info.st_atime).c_str(), FmtPspTime(info.st_mtime).c_str());
|
||||
}
|
||||
} else if (fileList->resultNumNormalEntries > 0) {
|
||||
|
||||
+11
-7
@@ -1220,14 +1220,18 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
|
||||
ImGui::Text("Total bytes to transfer: %d", gstate.getTransferWidth() * gstate.getTransferHeight() * gstate.getTransferBpp());
|
||||
} else {
|
||||
// Visualize prim by default (even if we're not directly on a prim instruction).
|
||||
VirtualFramebuffer *vfb = rbViewer_.GetVFB(gpuDebug->GetFramebufferManagerCommon());
|
||||
if (vfb) {
|
||||
if (vfb->fbo) {
|
||||
ImGui::Text("Framebuffer: %s", vfb->fbo->Tag());
|
||||
} else {
|
||||
ImGui::Text("Framebuffer");
|
||||
FramebufferManagerCommon *fbMan = gpuDebug->GetFramebufferManagerCommon();
|
||||
VirtualFramebuffer *vfb = nullptr;
|
||||
if (fbMan) {
|
||||
vfb = rbViewer_.GetVFB(fbMan);
|
||||
if (vfb) {
|
||||
if (vfb->fbo) {
|
||||
ImGui::Text("Framebuffer: %s", vfb->fbo->Tag());
|
||||
} else {
|
||||
ImGui::Text("Framebuffer");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::SetNextItemWidth(200.0f);
|
||||
ImGui::SliderFloat("Zoom", &previewZoom_, 0.125f, 2.f, "%.3f", ImGuiSliderFlags_Logarithmic);
|
||||
|
||||
@@ -2135,3 +2135,8 @@ NPUZ00062 = true # Mahjong Artifacts (MJA)
|
||||
NPEZ00194 = true # Mahjong Artifacts (MJA)
|
||||
NPEZ00003 = true # MJA 2
|
||||
NPUZ00006 = true # MJA 2
|
||||
|
||||
[FileCreatedTimeHack]
|
||||
# Silent Hill: Shattered Memories does some strange checks of the file-created time, which won't pass on some platforms. See issue #13781
|
||||
ULES01352 = true
|
||||
ULUS10450 = true
|
||||
Reference in new issue
Block a user