Dolphin, the GameCube and Wii emulator - Forums
Problem opening games - Printable Version

+- Dolphin, the GameCube and Wii emulator - Forums (https://forums.dolphin-emu.org)
+-- Forum: Dolphin Emulator Discussion and Support (https://forums.dolphin-emu.org/Forum-dolphin-emulator-discussion-and-support)
+--- Forum: Development Discussion (https://forums.dolphin-emu.org/Forum-development-discussion)
+--- Thread: Problem opening games (/Thread-problem-opening-games)



Problem opening games - imk - 12-09-2009

I've been compiling my own builds and there seems to be a problem with mine where some games don't show up in the list, and if you try to open them manually, it will say the file doesn't exist (which it clearly does).

Builds from other people have no problem listing or opening the other games.

I'm building with MSVS2010 Beta 2. I compile them as x64 JITIL, and I profile the binary, too.

I took a look at the source and nothing seems to be wrong as far as opening files. Perhaps it's a bug with MSVS2010? Is anyone else using this version and have they ran into a similar problem?


RE: Problem opening games - imk - 12-10-2009

I'm having trouble with this still.

I looked in CoreParameter.cpp under the SCoreStartupParameter::AutoSetup() function.

The problem it's running into is related to File::Exists().

From there I went into FileUtil.cpp to dig around.

I made a simple modification to print the result of stat().

Code:
--- C:/Users/Dopefish/AppData/Local/Temp/FileUtil.cp-revBASE.svn001.tmp.cpp    Wed Dec  9 23:54:26 2009
+++ C:/Users/Dopefish/Documents/Visual Studio 2010/Projects/dolphin-emu/Source/Core/Common/Src/FileUtil.cpp    Wed Dec  9 23:52:45 2009
@@ -19,6 +19,9 @@
#include "FileUtil.h"
#include "StringUtil.h"

+#include <errno.h>
+extern int errno;
+
#ifdef _WIN32
#include <windows.h>
#include <shlobj.h>        // for SHGetFolderPath
@@ -72,6 +75,7 @@
        
    char *copy = StripTailDirSlashes(__strdup(filename));
    int result = stat(copy, &file_info);
+    PanicAlert("File: %s\nResult: %d\nError: %s", copy, result, strerror(errno));
    free(copy);

    return (result == 0);


When you compile and first open Dolphin, it's going to pop up a bunch of dialogs as that function is called, just dismiss them all.

When I finally get to the main interface, I go to open and select the .gcz, and the result is simply "No error" (error code 0) yet the application still says the file does not exist.

The stat function returns -1, though, which indicates an error... so this really doesn't make much sense.

Code:
57:58:061 E[*]: Warning: File: D:\Games\Dolphin\Games\game.gcz
Result: -1
Error: No error
58:01:172 E[*]: Warning: The file you specified (D:\Games\Dolphin\Games\game.gcz) does not exists



















Alright, since Dolphin is written in C++, I just went ahead and replaced the existing function with something more C++, and it works.

Code:
--- C:/Users/Dopefish/AppData/Local/Temp/FileUtil.c-revBASE.svn002.tmp.cpp    Thu Dec 10 00:19:15 2009
+++ C:/Users/Dopefish/Documents/Visual Studio 2010/Projects/dolphin-emu/Source/Core/Common/Src/FileUtil.cpp    Thu Dec 10 00:19:03 2009
@@ -68,13 +68,15 @@
// Returns true if file filename exists
bool Exists(const char *filename)
{
-    struct stat file_info;
-        
-    char *copy = StripTailDirSlashes(__strdup(filename));
-    int result = stat(copy, &file_info);
-    free(copy);
+    std::ifstream ifsFile;
+    std::ofstream ofsFile;

-    return (result == 0);
+    ifsFile.open(filename, std::ifstream::in);
+    ifsFile.close();
+    if (ifsFile.fail())
+        return 0;
+    else
+        return 1;
}

// Returns true if filename is a directory

It can now find and open all games that it couldn't before for me.