From d8a55756f3336fd711bc4a00e22ac87edac97aaa Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 10 Feb 2013 17:59:15 -0800 Subject: [PATCH] Always return a file descriptor in sceIoOpenAsync. Fixes #646. --- Core/HLE/sceIo.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 25341ea1db..7ea643ab06 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -891,9 +891,20 @@ u32 sceIoOpenAsync(const char *filename, int flags, int mode) { DEBUG_LOG(HLE, "sceIoOpenAsync() sorta implemented"); u32 fd = sceIoOpen(filename, flags, mode); + // TODO: This can't actually have a callback yet, but if it's set before waiting, it should be called. __IoCompleteAsyncIO(fd); + // We have to return an fd here, which may have been destroyed when we reach Wait if it failed. + if (fd == ERROR_ERRNO_FILE_NOT_FOUND) + { + FileNode *f = new FileNode(); + fd = kernelObjects.Create(f); + f->handle = 0; + f->fullpath = filename; + f->asyncResult = ERROR_ERRNO_FILE_NOT_FOUND; + } + return fd; }