Projects > cpp > Issues > Bug #3418

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Resource path in fileUtils isn't alway right

Bug #3418 [Closed]
MR_R 2013-12-17 16:40 . Updated almost 3 years ago

the resource path generated by checkPath is the CurrentDirectory. But the CurrentDirectory doens’t necessary needs to be the directory where the .exe is. In order to get the right directory in Windows I propose the following change incheckPath()

static void _checkPath()
    if (0 == s_resourcePath.length())
        // Get the full path of current exe file.
    WCHAR FilePath[MAX_PATH] = { 0 };
    GetModuleFileNameW(0, FilePath, MAX_PATH);

    // Strip the exe filename from path and get folder name.

    // Set the current working directory.

        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), NULL, NULL);

        s_resourcePath = convertPathFormatToUnixStyle(utf8Path);

In order to build the following file needs to be included in CCFileUtilsWin32.cpp:
#include “Shlwapi.h”

and Shlwapi.lib needs to be linked to libcocos2d 2014-10-08 02:51

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to

Atom PDF

Start date:2013-12-17
Due date:
% Done:


Target version:-

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.