mirror of https://github.com/PCSX2/pcsx2.git
Implemented a better "host:" rewrite system, which takes the path of the elf being loaded as the root of the virtual "host:". This is the same behaviour as pc-side ps2link clients. The code could probably be cleaned up a lot or made more configurable, if someone wants to improve it.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3316 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
fe92409fd4
commit
f1630170ed
|
@ -25,6 +25,51 @@
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set this to 0 to disable rewriting 'host:' paths!
|
||||||
|
#define USE_HOST_REWRITE 1
|
||||||
|
|
||||||
|
#if USE_HOST_REWRITE
|
||||||
|
static char HostRoot[1024];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Hle_SetElfPath(const char* elfFileName)
|
||||||
|
{
|
||||||
|
#if USE_HOST_REWRITE
|
||||||
|
DevCon.WriteLn("HLE Host: Will load ELF: %s\n", elfFileName);
|
||||||
|
|
||||||
|
const char* pos1 = strrchr(elfFileName,'/');
|
||||||
|
const char* pos2 = strrchr(elfFileName,'\\');
|
||||||
|
|
||||||
|
if(pos2 > pos1) // we want the LAST path separator
|
||||||
|
pos1=pos2;
|
||||||
|
|
||||||
|
if(!pos1) // if pos1 is NULL, then pos2 was not > pos1, so it must also be NULL
|
||||||
|
{
|
||||||
|
Console.Warning("HLE Warning: ELF does not have a path!!\n");
|
||||||
|
|
||||||
|
// use %CD%/host/
|
||||||
|
getcwd(HostRoot,1000); // save the other 23 chars to append /host/ :P
|
||||||
|
HostRoot[1000]=0; // Be Safe.
|
||||||
|
|
||||||
|
char* last = HostRoot + strlen(HostRoot) - 1;
|
||||||
|
|
||||||
|
if((*last!='/') && (*last!='\\')) // PathAppend()-ish
|
||||||
|
last++;
|
||||||
|
|
||||||
|
strcpy(last,"/host/");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int len = pos1-elfFileName+1;
|
||||||
|
memcpy(HostRoot,elfFileName,len); // include the / (or \\)
|
||||||
|
HostRoot[len] = 0;
|
||||||
|
|
||||||
|
Console.WriteLn("HLE Host: Set 'host:' root path to: %s\n", HostRoot);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
namespace R3000A {
|
namespace R3000A {
|
||||||
|
|
||||||
#define v0 (psxRegs.GPR.n.v0)
|
#define v0 (psxRegs.GPR.n.v0)
|
||||||
|
@ -107,11 +152,7 @@ public:
|
||||||
}
|
}
|
||||||
else // relative paths
|
else // relative paths
|
||||||
{
|
{
|
||||||
// this assumes the PWD/CWD points to pcsx2's data folder,
|
strcpy(pathMod,HostRoot);
|
||||||
// that is, eitehr the same folder as pcsx2.exe or somethign like
|
|
||||||
// c:\users\appdata\roaming\pcsx2, documents\pcsx2, $HOME\pcsx2, or similar
|
|
||||||
|
|
||||||
strcpy(pathMod,"host/");
|
|
||||||
strcat(pathMod,path);
|
strcat(pathMod,path);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -72,4 +72,6 @@ namespace R3000A
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void Hle_SetElfPath(const char* elfFileName);
|
||||||
|
|
||||||
#endif /* __PSXBIOS_H__ */
|
#endif /* __PSXBIOS_H__ */
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
|
#include "IopBios.h"
|
||||||
|
|
||||||
#include "Counters.h"
|
#include "Counters.h"
|
||||||
#include "GS.h"
|
#include "GS.h"
|
||||||
#include "Elfheader.h"
|
#include "Elfheader.h"
|
||||||
|
@ -104,6 +106,9 @@ void SysCoreThread::SetElfOverride( const wxString& elf )
|
||||||
{
|
{
|
||||||
//pxAssertDev( !m_hasValidMachine, "Thread synchronization error while assigning ELF override." );
|
//pxAssertDev( !m_hasValidMachine, "Thread synchronization error while assigning ELF override." );
|
||||||
m_elf_override = elf;
|
m_elf_override = elf;
|
||||||
|
|
||||||
|
|
||||||
|
Hle_SetElfPath(elf.ToUTF8());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysCoreThread::Reset()
|
void SysCoreThread::Reset()
|
||||||
|
|
Loading…
Reference in New Issue