Skip to content
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

Merged
merged 5 commits into from Jan 11, 2017

Conversation

JosJuice
Copy link
Member

@JosJuice JosJuice commented Dec 21, 2016

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.

@BhaaLseN
Copy link
Member

Code LGTM, but haven't tested it.

@leoetlino
Copy link
Member

WBFS images that consist of several files seem to be broken.

@JosJuice
Copy link
Member Author

JosJuice commented Dec 31, 2016

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.

@JosJuice
Copy link
Member Author

JosJuice commented Jan 1, 2017

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.

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

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.

@JosJuice JosJuice force-pushed the blob-open-less-files branch 2 times, most recently from b70d94b to db7f5af Compare January 6, 2017 14:00
...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.
@lioncash lioncash merged commit 55b82e3 into dolphin-emu:master Jan 11, 2017
@JosJuice JosJuice deleted the blob-open-less-files branch January 11, 2017 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants