How to get absolute/full path to a file using FileUtils?

I need to get the full path to certain files that I need to process. I am using FileUtils as shown below.

//get the full path to the needed file
string pathToFile = FileUtils::sharedFileUtils()->fullPathFromRelativePath(incomingFileName.c_str());

However, I get the following error

No member named ‘fullPathFromRelativePath’ in ‘cocos2d::FileUtils’

I also get a deprecation working for sharedFileUtils.

Does anyone know how to go about getting a file’s absolute path?

There is no method in FileUtils called fullPathFromRelativePath, it’s fullPathFromRelativeFile (or fullPathForFilename if you want to use the default file search functionality).

Also, use FileUtils::getInstance() instead of FileUtils::sharedFileUtils().

Check out the API Reference and CCFileUtils source code, it helps when running into these kinds of questions.

1 Like

Thank you qwpeoriu, fullPathForFilename was exactly what I needed (and switching to FileUtils::getInstance() of course).

I appreciate your help