Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'struct dirent' has no member named 'd_type' #725

Open
SaeedRezaAmanat opened this issue Jul 2, 2020 · 0 comments
Open

'struct dirent' has no member named 'd_type' #725

SaeedRezaAmanat opened this issue Jul 2, 2020 · 0 comments

Comments

@SaeedRezaAmanat
Copy link

SaeedRezaAmanat commented Jul 2, 2020

#39 I googled and found this question. Yeah, it's my question too!
I really need my c program to be compiled as it's needed for a group project. When I compile I face this error:
error: 'struct dirent' has no member named 'd_type'
How can I solve this problem?

I am using windows 10. I need it for c programming language.

` struct dirent *dir;
DIR *pDir = opendir(path);

if (pDir) {
    while ((dir = readdir(pDir)) != NULL) {
        if (dir->d_type == FILE_FLAG) {
            String filename = malloc(sizeof(char) * strlen(dir->d_name));
            strcpy(filename, dir->d_name);
            result[resSize++] = filename;
        }
    }
    closedir(pDir);
}`

This is my struct dirent in direct.h:

struct dirent { long d_ino; /* Always zero. */ unsigned short d_reclen; /* Always zero. */ unsigned short d_namlen; /* Length of name in d_name. */ char d_name[260]; /* [FILENAME_MAX] */ /* File name. */ };

Edited: This post helped me to solve this problem, but is there a more neat way to solve it?
https://stackoverflow.com/questions/5530933/dirent-h-in-visual-studio-2010-or-2008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant