开发者

C Stat() failing on files in hidden folder

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").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜