Cocos2d-x 安卓平台下如何遍历文件夹下的文件

我使用
std::string filePath = FileUtils::getInstance()->fullPathForFilename(path);
DIR dp;
struct dirent
dirp;

    if ((dp = opendir(filePath.c_str())) == NULL)
    {
        CCLog("can not match the folder path");
        return;
    }
    while ((dirp = readdir(dp)) != NULL)
    {
        struct stat buf;
        stat(folderPath.c_str(), &buf);

        // 如果是目录  
        if (S_ISDIR(buf.st_mode))
        {
            string path;
            if ((strcmp(dirp->d_name, ".") != 0) && (strcmp(dirp->d_name, "..") != 0))
            {
                path = folderPath + "/" + dirp->d_name;
            }
            //如果是目录,递归调用  
            FindAllFile(path);
        }
        else
        {
            std::string name = dirp->d_name;
            size_t iPos = name.find(".");
            std::string suffixName = name.substr(iPos+1,3);
            if (suffixName == "png" || suffixName == "jpg")
            {
                string fullName = folderName + name;
                log("fullName-----------%s", fullName.c_str());
                files.push_back(fullName);
            }
            // 如果是文件直接打印  
            //CCLog("%s/%s\n", folderPath.c_str(), dirp->d_name);
        }
    }
    closedir(dp);

结果打不开文件夹