mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06:00
FileUtil: Add a class for Exists/IsDirectory/GetSize
Some code was calling more than one of these functions in a row (in particular, FileUtil.cpp itself did it a lot...), which is a waste since it's possible to call stat a single time and then read all three values from the stat struct. This commit adds a File::FileInfo class that calls stat once on construction and then lets Exists/IsDirectory/GetSize be executed very quickly. The performance improvement mostly matters for functions that can be handling a lot of files, such as File::ScanDirectoryTree. I've also done some cleanup in code that uses these functions. For instance, some code had checks like !Exists() || !IsDirectory(), which is functionally equivalent to !IsDirectory(), and some code was using File::GetSize even though there was an IOFile object that the code could call GetSize on.
This commit is contained in:
@ -359,18 +359,15 @@ void GameCubeConfigPane::ChooseSlotPath(bool is_slot_a, ExpansionInterface::TEXI
|
||||
|
||||
if (!filename.empty())
|
||||
{
|
||||
if (File::Exists(filename))
|
||||
if (memcard && File::Exists(filename))
|
||||
{
|
||||
if (memcard)
|
||||
GCMemcard memorycard(filename);
|
||||
if (!memorycard.IsValid())
|
||||
{
|
||||
GCMemcard memorycard(filename);
|
||||
if (!memorycard.IsValid())
|
||||
{
|
||||
WxUtils::ShowErrorDialog(wxString::Format(_("Cannot use that file as a memory card.\n%s\n"
|
||||
"is not a valid GameCube memory card file"),
|
||||
filename.c_str()));
|
||||
return;
|
||||
}
|
||||
WxUtils::ShowErrorDialog(wxString::Format(_("Cannot use that file as a memory card.\n%s\n"
|
||||
"is not a valid GameCube memory card file"),
|
||||
filename.c_str()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user