error on CCFileUtils::fullParhFromRelativePath


hello. sorry for my poor english. but i have a problem. plz help me.

i try to run my project on iOS. but it’s fail to open resource file.
The main culprit in the current problem seems to be CCFileUtils::fullParhFromRelativePath function on CCFileUtilsmm file.
This function not return an accurate path.
if input parameter contains no sub directory, then variable “fullpath” set well.
But curiously enough, if it contains sub directory then variable “fullpath” set nil.
like this:

I have no idea why this happen. plz give me a little bit of clue.

wtf.jpg (76.2 KB)


Just to be sure.

const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
    CCAssert(pszRelativePath != NULL, "CCFileUtils: Invalid path");

    NSString *fullpath = nil;
    NSString *relPath = [NSString stringWithUTF8String:pszRelativePath];

    // only if it is not an absolute path
    if( ! [relPath isAbsolutePath] ) {

        // pathForResource also searches in .lproj directories. issue #1230
        NSString *lastPathComponent = [relPath lastPathComponent];

        NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
        NSMutableString *imageDirectoryByAppendDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
        [imageDirectoryByAppendDirectory appendString:imageDirectory];

        // search path from directory set by setResourceDirectory
        fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
        if (fullpath == nil)
            // search from root directory
            fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent

    if (fullpath == nil)
        fullpath = relPath;

    return [fullpath UTF8String];


what the fuck is this ?

plz help me……
god bless you


Can you tell us how you use *CCFileUtils::fullPathFromRelativePath()*?

For example:

std::string path = CCFileUtils::sharedFileUtils() -> fullPathFromRelativePath( "Profiles/userProfile.xml" );
std::cout << "Path: " << path.c_str() << std::endl;

The above code prints something like this on the Simulator:

/Users/xxxx/Library/Application Support/iPhone Simulator/5.0/Application/some-hexadecimal-id/Caches/Profiles/userProfile.xml


thanks for reply.
yeh. From a common-sense point of view, function “fullPathFromRelativePath” return full path you said.
but like the preceding, that function return NOT full path( just relative path) when relative path contains sub drectory.

for example,

CCFileUtils::sharedFileUtils() > fullPathFromRelativePath;
/Users/xxxx/Library/Application Support/iPhone Simulator/5.0/Application/some-hexadecimal-id/img.png
> fullPathFromRelativePath( “ui/img.png” );
returns just

The funny thing is that function called by cocos2d method.

CCTexture2D * CCTextureCache::addImage(const char * path)
    CCAssert(path != NULL, "TextureCache: fileimage MUST not be NULL");

    CCTexture2D * texture = NULL;
    // Split up directory and filename
    // MUTEX:
    // Needed since addImageAsync calls this method from a different thread


    // remove possible -HD suffix to prevent caching the same image twice (issue #1040)
    std::string pathKey = path;

    pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str());

the result depends on whether parameter “path” contains directory or not. I can’t understand this situation.


oh shit ….
fullParhFromRelativePath function has been removed in 2.1rc0-x-2.1.2 ….
What have i done! ahhhhhhhhhhsdfl ashkdklfjhwlek fhlskdjf klsdjb fklajdbfklasjd;lfjk l;asdjfocausdro;cfaunouvcnucr;weuxrm;weuemrl;xasndzblkcnlzxmsltcmfnlhvtgnzpouc;tioybhl



Still not works … even upgraded