aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder/dirent_win.h
blob: ac11a64c0470517090692544e1e7995c7dd49ec2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <util/system/defaults.h>

#ifdef _win_

    #include <util/system/winint.h>

    #ifdef __cplusplus
extern "C" {
    #endif

    struct DIR {
        HANDLE sh;
        WIN32_FIND_DATAW wfd;
        WCHAR* fff_templ;
        int file_no;
        struct dirent* readdir_buf;
    };

    #define MAXNAMLEN (MAX_PATH - 1) * 2
    #define MAXPATHLEN MAX_PATH
    #define DT_DIR 4
    #define DT_REG 8
    #define DT_LNK 10
    #define DT_UNKNOWN 0

    struct dirent {
        ui32 d_fileno;              /* file number of entry */
        ui16 d_reclen;              /* length of this record */
        ui8 d_type;                 /* file type */
        ui8 d_namlen;               /* length of string in d_name */
        char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
    };

    struct DIR* opendir(const char* dirname);
    int closedir(struct DIR* dir);
    int readdir_r(struct DIR* dir, struct dirent* entry, struct dirent** result);
    struct dirent* readdir(struct DIR* dir);
    void rewinddir(struct DIR* dir);

    #ifdef __cplusplus
}
    #endif

#endif //_win_