C++ ftw不会遍历子目录c++;

C++ ftw不会遍历子目录c++;,c++,C++,嘿,每个人,我都有这段代码,我正试图遍历一个目录树,但它只遍历1个子目录。有人能帮我让这段代码遍历树中的所有子目录吗 static int callback(const char *fpath, const struct stat *sb, int typeflag) { /* if it's a file */ if (typeflag == FTW_F) { /* for each filter, */ string basepath = f

嘿,每个人,我都有这段代码,我正试图遍历一个目录树,但它只遍历1个子目录。有人能帮我让这段代码遍历树中的所有子目录吗

static int callback(const char *fpath, const struct stat *sb, int typeflag) {
    /* if it's a file */
    if (typeflag == FTW_F) {

        /* for each filter, */
        string basepath = fpath;
        basepath = basepath.substr(0, basepath.find_last_of('/')-1);
        cout << "basepath: " << basepath << endl;


        for (int i = 0; i < sizeof(filters) / sizeof(filters[0]); i++) {
            string finpath = basepath + string(filters[i]);
            cout << "finpath: " << finpath << endl;
            //string path = basepath + string(filters[i]);
            // if the filename matches the filter, 
            if (fnmatch(finpath.c_str(), fpath, FNM_CASEFOLD) == 0) {
                cout << fpath << endl;
                break;
            }
        }
    }

    /* tell ftw to continue */
    return 0;
}
static int回调(const char*fpath,const struct stat*sb,int typeflag){
/*如果是文件*/
if(typeflag==FTW\u F){
/*对于每个过滤器*/
字符串basepath=fpath;
basepath=basepath.substr(0,basepath.find最后一个('/')-1);

既然目录是一种特定于平台的东西,那么您使用的是什么平台和什么编译器?我使用的是g++编译器递归是什么?