我在使用时收到了一些奇怪的结果opendir()
:
int dtw(char *path) {
struct stat statbuf;
...
else if (S_ISDIR(statbuf.st_mode)) {
printf("Path is: %s\n", path);
struct dirent *dirent;
DIR *dirp;
if ((dirp = opendir(path)) == NULL) {
puts("Can't open directory.");
return -1;
}
printf("Path is: %s\n", path);
}
...
}
结果是:
Path is: /home/.../etc
Path is:
唯一会影响path
的是opendir()
这里。它有我没有看到的副作用吗?还是有其他事情在工作?