nftw BSD上的不同? [英] nftw different on BSD?

查看:141
本文介绍了nftw BSD上的不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用得到的目录树中的所有.c文件 nftw 通过以下code:

I'm trying to get all .c files in a directory tree using nftw with the following code:

static int gf(const char *path, const struct stat *st, int t, struct FTW *ftw) {
    if (t != FTW_F)
        return 0;
    if (strcmp(ext(path), ".c") == 0)
        addl(&files, dup(abspath(path)));
    return 0;
}

void getfiles(char *path) {
    nftw(path, gf, 255, FTW_PHYS);
}

它可以在Linux和Solaris,但对PC-BSD通过简单的不拾取任何文件失败。我缺少什么?

It works on Linux and Solaris, but on PC-BSD it fails by simply not picking up any files. What am I missing?

推荐答案

什么是 nftw 的返回值?如果是 1 错误号为设置为 EINVAL 这很可能是因为您超过了 OPEN_MAX 的价值。尝试通过一个较小的值作为第三个参数 nftw ,并确保它比 OPEN_MAX

What is the return value of nftw? If it's -1 and the errno is set to EINVAL it's quite likely that you're exceeding the value of OPEN_MAX. Try passing a smaller value as third parameter to nftw and ensure it's smaller than OPEN_MAX.

这篇关于nftw BSD上的不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆