This is a piece of my code. It works fine if I use opendir on just ".", but when I try and open /.hidden, the stat fails. Does stat not work on files in a hidden folder, or am I doing something wrong?
direc = opendir("./.hidden");
if(direc ==NULL)
{
perror("opendir failed");
}
while((curr_file=readdir(direc)))
{
if(( strcmp(curr_file->d_name,".")!=0 && strcmp(curr_file->d_name,"..")!=0))
{
strcpy(file_name,".");
strcat(file_name,"/");
strcat(file_name,curr_file->d_name);
if(stat(file_name,&st开发者_开发百科atp))
{
perror("stat failed");
}
You neglected to update the code that builds the file name, so it's trying to stat("./filename")
instead of stat("./.hidden/filename")
.
精彩评论