mirror of https://github.com/axmolengine/axmol.git
win32: Search resources in the executable directory by default instead of the current directory. Because new default location is much more predictable.
This commit is contained in:
parent
95bb2b7b7b
commit
653bf1549d
|
@ -29,6 +29,7 @@ THE SOFTWARE.
|
|||
#include "CCFileUtils-win32.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include <Shlobj.h>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -59,14 +60,16 @@ static void _checkPath()
|
|||
{
|
||||
if (0 == s_resourcePath.length())
|
||||
{
|
||||
WCHAR utf16Path[CC_MAX_PATH] = {0};
|
||||
GetCurrentDirectoryW(sizeof(utf16Path)-1, utf16Path);
|
||||
|
||||
char utf8Path[CC_MAX_PATH] = {0};
|
||||
int nNum = WideCharToMultiByte(CP_UTF8, 0, utf16Path, -1, utf8Path, sizeof(utf8Path), nullptr, nullptr);
|
||||
WCHAR *pUtf16ExePath = nullptr;
|
||||
_get_wpgmptr(&pUtf16ExePath);
|
||||
|
||||
s_resourcePath = convertPathFormatToUnixStyle(utf8Path);
|
||||
s_resourcePath.append("/");
|
||||
// We need only directory part without exe
|
||||
WCHAR *pUtf16DirEnd = wcsrchr(pUtf16ExePath, L'\\');
|
||||
|
||||
char utf8ExeDir[CC_MAX_PATH] = { 0 };
|
||||
int nNum = WideCharToMultiByte(CP_UTF8, 0, pUtf16ExePath, pUtf16DirEnd-pUtf16ExePath+1, utf8ExeDir, sizeof(utf8ExeDir), nullptr, nullptr);
|
||||
|
||||
s_resourcePath = convertPathFormatToUnixStyle(utf8ExeDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue