Skip to content

Commit 1d076e2

Browse files
authored
Merge pull request #18683 from hrydgard/iso-directory-bugfix
Handle file type detection of extracted ISO directories better
2 parents 83999b8 + 00f53ad commit 1d076e2

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Core/FileLoaders/HTTPFileLoader.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void HTTPFileLoader::Prepare() {
117117

118118
int HTTPFileLoader::SendHEAD(const Url &url, std::vector<std::string> &responseHeaders) {
119119
if (!url.Valid()) {
120-
ERROR_LOG(LOADER, "HTTP request failed, invalid URL");
120+
ERROR_LOG(LOADER, "HTTP request failed, invalid URL: '%s'", url.ToString().c_str());
121121
latestError_ = "Invalid URL";
122122
return -400;
123123
}
@@ -131,7 +131,7 @@ int HTTPFileLoader::SendHEAD(const Url &url, std::vector<std::string> &responseH
131131
client_.SetDataTimeout(20.0);
132132
Connect();
133133
if (!connected_) {
134-
ERROR_LOG(LOADER, "HTTP request failed, failed to connect: %s port %d", url.Host().c_str(), url.Port());
134+
ERROR_LOG(LOADER, "HTTP request failed, failed to connect: %s port %d (resource: '%s')", url.Host().c_str(), url.Port(), url.Resource().c_str());
135135
latestError_ = "Could not connect (refused to connect)";
136136
return -400;
137137
}

Core/FileSystems/BlockDevices.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ extern "C"
4040
std::mutex NPDRMDemoBlockDevice::mutex_;
4141

4242
BlockDevice *constructBlockDevice(FileLoader *fileLoader) {
43-
if (!fileLoader->Exists())
43+
if (!fileLoader->Exists()) {
4444
return nullptr;
45+
}
46+
if (fileLoader->IsDirectory()) {
47+
ERROR_LOG(LOADER, "Can't open directory directly as block device: %s", fileLoader->GetPath().c_str());
48+
return nullptr;
49+
}
50+
4551
char buffer[8]{};
4652
size_t size = fileLoader->ReadAt(0, 1, 8, buffer);
4753
if (size != 8) {
@@ -61,7 +67,7 @@ BlockDevice *constructBlockDevice(FileLoader *fileLoader) {
6167
return new CHDFileBlockDevice(fileLoader);
6268
}
6369

64-
// Should be just a regular ISO. Let's open it as a plain block device and let the other systems take over.
70+
// Should be just a regular ISO file. Let's open it as a plain block device and let the other systems take over.
6571
return new FileBlockDevice(fileLoader);
6672
}
6773

UI/GameInfoCache.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ u64 GameInfo::GetGameSizeOnDiskInBytes() {
127127
case IdentifiedFileType::PSP_PBP_DIRECTORY:
128128
case IdentifiedFileType::PSP_SAVEDATA_DIRECTORY:
129129
return File::ComputeRecursiveDirectorySize(ResolvePBPDirectory(filePath_));
130-
130+
case IdentifiedFileType::PSP_DISC_DIRECTORY:
131+
return File::ComputeRecursiveDirectorySize(GetFileLoader()->GetPath());
131132
default:
132133
return GetFileLoader()->FileSize();
133134
}
@@ -138,7 +139,8 @@ u64 GameInfo::GetGameSizeUncompressedInBytes() {
138139
case IdentifiedFileType::PSP_PBP_DIRECTORY:
139140
case IdentifiedFileType::PSP_SAVEDATA_DIRECTORY:
140141
return File::ComputeRecursiveDirectorySize(ResolvePBPDirectory(filePath_));
141-
142+
case IdentifiedFileType::PSP_DISC_DIRECTORY:
143+
return File::ComputeRecursiveDirectorySize(GetFileLoader()->GetPath());
142144
default:
143145
{
144146
BlockDevice *blockDevice = constructBlockDevice(GetFileLoader().get());
@@ -576,7 +578,6 @@ class GameInfoWorkItem : public Task {
576578

577579
case IdentifiedFileType::PSP_DISC_DIRECTORY:
578580
{
579-
info_->fileType = IdentifiedFileType::PSP_ISO;
580581
SequentialHandleAllocator handles;
581582
VirtualDiscFileSystem umd(&handles, gamePath_);
582583

@@ -606,7 +607,6 @@ class GameInfoWorkItem : public Task {
606607
case IdentifiedFileType::PSP_ISO:
607608
case IdentifiedFileType::PSP_ISO_NP:
608609
{
609-
info_->fileType = IdentifiedFileType::PSP_ISO;
610610
SequentialHandleAllocator handles;
611611
// Let's assume it's an ISO.
612612
// TODO: This will currently read in the whole directory tree. Not really necessary for just a

0 commit comments

Comments
 (0)