New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open less files when detecting/opening blobs #4537
Conversation
000362d
to
9459497
Compare
Code LGTM, but haven't tested it. |
WBFS images that consist of several files seem to be broken. |
9459497
to
c662356
Compare
I found and fixed a simple mistake: I wasn't setting new_entry->file in WbfsFileReader::AddFileToList. WBFS files still don't seem to be working, though... There must be some additional bug in the third commit. |
c662356
to
8d91cf5
Compare
The other bug was that it didn't seek back to 0 before reading the WBFS header. Now that that's fixed, WBFS seems to be working correctly. |
@@ -177,23 +178,24 @@ std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename) | |||
if (cdio_is_cdrom(filename)) | |||
return DriveReader::Create(filename); | |||
|
|||
if (!File::Exists(filename)) | |||
File::IOFile file(filename, "rb"); | |||
u32 magic; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -177,23 +178,24 @@ std::unique_ptr<IBlobReader> CreateBlobReader(const std::string& filename) | |||
if (cdio_is_cdrom(filename)) | |||
return DriveReader::Create(filename); | |||
|
|||
if (!File::Exists(filename)) | |||
File::IOFile file(filename, "rb"); | |||
u32 magic; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
path[path.length() - 1] = '0' + m_total_files; | ||
} | ||
std::string current_path = path; | ||
if (m_files.size() >= 10) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
8d91cf5
to
f4f876d
Compare
static const char CISO_MAGIC[] = "CISO"; | ||
|
||
CISOFileReader::CISOFileReader(std::FILE* file) : m_file(file) | ||
CISOFileReader::CISOFileReader(File::IOFile&& file) : m_file(std::move(file)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
bool ReadHeader(); | ||
|
||
File::IOFile& SeekToCluster(u64 offset, u64* available); | ||
bool IsGood() { return m_good; } | ||
struct file_entry | ||
{ | ||
file_entry(File::IOFile&& file, u64 base_address, u64 size) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
b70d94b
to
db7f5af
Compare
...except for WBFS, which is special because it has the ability to open multiple files.
The first file used to be opened once by CreateBlobReader and once inside WbfsFileReader.
std::vector already keeps track of this for us.
There doesn't seem to be any reason for doing it.
db7f5af
to
b187326
Compare
Remember when Pokémon Snap used to take several minutes to start because we were opening files unnecessarily many times? (PR #2649)
I noticed that the blob code also was opening files unnecessarily many times, so I made this PR that cuts it down to one. I hope it will make game list scanning a little faster, but I don't think the difference will be as dramatic as with Pokémon Snap.
@JMC47 (or someone else?), please test that all file formats still are detected properly. I've only tested ISO and CISO this far. In particular, WBFS disc images that consist of multiple files need to be checked.