From 1fa17b7e290dd7c7d5f3fb6bd81c068d647ae84b Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Thu, 2 Jun 2011 07:04:26 +0000 Subject: [PATCH] Potential fix for errors related to 'Not enough free blocks' changes fs getusage to return 1 additional inode to account for the directory itself Fixes save creation for at least two games, R8XE52 (Jurassic: The Hunted), STEETR (Tetris Party Deluxe) doesnt harm save creation in any games that i tested (about 25) also it is now possible to boot a nand title by selecting the tmd file using File > Open git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7575 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 2 +- .../Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp | 26 ++++++++++++++----- Source/Core/DiscIO/Src/NANDContentLoader.cpp | 2 +- Source/Core/DolphinWX/Src/FrameTools.cpp | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index 685b3bbbd2..8a2cec7bea 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -156,7 +156,7 @@ bool CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode) } else { - WARN_LOG(WII_IPC_FILEIO, "FileIO: Open failed - File doesn't exist %s", m_Filename.c_str()); + WARN_LOG(WII_IPC_FILEIO, "FileIO: Open (%s) failed - File doesn't exist %s", Modes[_Mode], m_Filename.c_str()); ReturnValue = FS_FILE_NOT_EXIST; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp index 6119eef325..8c87b29e9d 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_fs.cpp @@ -190,20 +190,34 @@ bool CWII_IPC_HLE_Device_fs::IOCtlV(u32 _CommandAddress) // this command sucks because it asks of the number of used // fsBlocks and inodes // It should be correct, but don't count on it... - std::string path(HLE_IPC_BuildFilename((const char*)Memory::GetPointer(CommandBuffer.InBuffer[0].m_Address), CommandBuffer.InBuffer[0].m_Size)); + const char *relativepath = (const char*)Memory::GetPointer(CommandBuffer.InBuffer[0].m_Address); + std::string path(HLE_IPC_BuildFilename(relativepath, CommandBuffer.InBuffer[0].m_Size)); u32 fsBlocks = 0; u32 iNodes = 0; INFO_LOG(WII_IPC_FILEIO, "IOCTL_GETUSAGE %s", path.c_str()); if (File::IsDirectory(path)) { - File::FSTEntry parentDir; - iNodes = File::ScanDirectoryTree(path, parentDir); + // LPFaint99: After I found that setting the number of inodes to the number of children + 1 for the directory itself + // I decided to compare with sneek which has the following 2 special cases which are + // Copyright (C) 2009-2011 crediar http://code.google.com/p/sneek/ + if ((memcmp(relativepath, "/title/00010001", 16 ) == 0 ) || + (memcmp(relativepath, "/title/00010005", 16) == 0 )) + { + fsBlocks = 23; // size is size/0x4000 + iNodes = 42; // empty folders return a FileCount of 1 + } + else + { + File::FSTEntry parentDir; + // add one for the folder itself, allows some games to create their save files + // R8XE52 (Jurassic: The Hunted), STEETR (Tetris Party Deluxe) now create their saves with this change + iNodes = 1 + File::ScanDirectoryTree(path, parentDir); - u64 totalSize = ComputeTotalFileSize(parentDir); // "Real" size, to be converted to nand blocks - - fsBlocks = (u32)(totalSize / (16 * 1024)); // one bock is 16kb + u64 totalSize = ComputeTotalFileSize(parentDir); // "Real" size, to be converted to nand blocks + fsBlocks = (u32)(totalSize / (16 * 1024)); // one bock is 16kb + } ReturnValue = FS_RESULT_OK; INFO_LOG(WII_IPC_FILEIO, "FS: fsBlock: %i, iNodes: %i", fsBlocks, iNodes); diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index 7d6d131e67..caae772283 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -212,7 +212,7 @@ bool CNANDContentLoader::Initialize(const std::string& _rName) } else { - SplitPath(TMDFileName, &m_Path, NULL, NULL); + m_Path = TMDFileName.substr(0, TMDFileName.find("title.tmd")); } File::IOFile pTMDFile(TMDFileName, "rb"); if (!pTMDFile) diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index ff1d7c03eb..b4981c0d53 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -662,7 +662,7 @@ void CFrame::DoOpen(bool Boot) _("Select the file to load"), wxEmptyString, wxEmptyString, wxEmptyString, _("All GC/Wii files (elf, dol, gcm, iso, ciso, gcz, wad)") + - wxString::Format(wxT("|*.elf;*.dol;*.gcm;*.iso;*.ciso;*.gcz;*.wad;*.dff|%s"), + wxString::Format(wxT("|*.elf;*.dol;*.gcm;*.iso;*.ciso;*.gcz;*.wad;*.dff;*.tmd|%s"), wxGetTranslation(wxALL_FILES)), wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);