Merge remote-tracking branch 'origin' into mp3-support

Conflicts:
	Core/HLE/sceAudio.cpp
	Core/HLE/sceMp3.cpp
This commit is contained in:
Henrik Rydgard 2013-06-22 18:08:43 +02:00
commit 4eb1638cc3
310 changed files with 68213 additions and 45168 deletions

View file

@ -17,8 +17,9 @@
#include <set>
#include "Common/StringUtils.h"
#include "../HLE/sceKernelThread.h"
#include "MetaFileSystem.h"
#include "Core/FileSystems/MetaFileSystem.h"
#include "Core/HLE/sceKernelThread.h"
#include "Core/Reporting.h"
static bool ApplyPathStringToComponentsVector(std::vector<std::string> &vector, const std::string &pathString)
{
@ -131,6 +132,13 @@ static bool RealPath(const std::string &currentDirectory, const std::string &inP
inAfterColon = inPath.substr(inColon + 1);
}
// Special case: "disc0:" is different from "disc0:/", so keep track of the single slash.
if (inAfterColon == "/")
{
outPath = prefix + inAfterColon;
return true;
}
if (! ApplyPathStringToComponentsVector(cmpnts, inAfterColon) )
{
WARN_LOG(HLE, "RealPath: inPath is not a valid path: \"%s\"", inPath.c_str());
@ -163,6 +171,7 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle)
return 0;
}
extern u32 ioErrorCode;
bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, MountPoint **system)
{
std::string realpath;
@ -170,20 +179,23 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
// Special handling: host0:command.txt (as seen in Super Monkey Ball Adventures, for example)
// appears to mean the current directory on the UMD. Let's just assume the current directory.
std::string inpath = _inpath;
if (strncasecmp(inpath.c_str(), "host0:", 5) == 0) {
if (strncasecmp(inpath.c_str(), "host0:", strlen("host0:")) == 0) {
INFO_LOG(HLE, "Host0 path detected, stripping: %s", inpath.c_str());
inpath = inpath.substr(6);
inpath = inpath.substr(strlen("host0:"));
}
const std::string *currentDirectory = &startingDirectory;
int currentThread = __KernelGetCurThread();
currentDir_t::iterator it = currentDir.find(currentThread);
if (it == currentDir.end())
if (it == currentDir.end())
{
//TODO: emulate PSP's error 8002032C: "no current working directory" if relative... may break things requiring fixes elsewhere
if (inpath.find(':') == std::string::npos /* means path is relative */)
WARN_LOG(HLE, "Path is relative, but current directory not set for thread %i. Should give error, instead falling back to %s", currentThread, startingDirectory.c_str());
//Attempt to emulate SCE_KERNEL_ERROR_NOCWD / 8002032C: may break things requiring fixes elsewhere
if (inpath.find(':') == std::string::npos /* means path is relative */)
{
ioErrorCode = SCE_KERNEL_ERROR_NOCWD;
WARN_LOG_REPORT(HLE, "Path is relative, but current directory not set for thread %i. returning 8002032C(SCE_KERNEL_ERROR_NOCWD) instead.", currentThread);
}
}
else
{
@ -300,8 +312,12 @@ void MetaFileSystem::ThreadEnded(int threadID)
currentDir.erase(threadID);
}
void MetaFileSystem::ChDir(const std::string &dir)
int MetaFileSystem::ChDir(const std::string &dir)
{
// Retain the old path and fail if the arg is 1023 bytes or longer.
if (dir.size() >= 1023)
return SCE_KERNEL_ERROR_NAMETOOLONG;
int curThread = __KernelGetCurThread();
std::string of;
@ -309,14 +325,24 @@ void MetaFileSystem::ChDir(const std::string &dir)
if (MapFilePath(dir, of, &mountPoint))
{
currentDir[curThread] = mountPoint->prefix + of;
//return true;
return 0;
}
else
{
//TODO: PSP's sceIoChdir seems very forgiving, but does it always accept bad paths and what happens when it does?
WARN_LOG(HLE, "ChDir failed to map path \"%s\", saving as current directory anyway", dir.c_str());
currentDir[curThread] = dir;
//return false;
for (size_t i = 0; i < fileSystems.size(); i++)
{
const std::string &prefix = fileSystems[i].prefix;
if (strncasecmp(prefix.c_str(), dir.c_str(), prefix.size()) == 0)
{
// The PSP is completely happy with invalid current dirs as long as they have a valid device.
WARN_LOG(HLE, "ChDir failed to map path \"%s\", saving as current directory anyway", dir.c_str());
currentDir[curThread] = dir;
return 0;
}
}
WARN_LOG_REPORT(HLE, "ChDir failed to map device for \"%s\", failing", dir.c_str());
return SCE_KERNEL_ERROR_NODEV;
}
}