| 1 | /** |
| 2 | * This file is part of the mingw-w64 runtime package. |
| 3 | * No warranty is given; refer to the file DISCLAIMER within this package. |
| 4 | */ |
| 5 | |
| 6 | #ifndef _FTW_HXX |
| 7 | #define	_FTW_HXX |
| 8 | |
| 9 | #include <sys/types.h> |
| 10 | #include <sys/stat.h> |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | struct FTW { |
| 17 | int base; |
| 18 | int level; |
| 19 | }; |
| 20 | |
| 21 | /* A regular file. */ |
| 22 | #define FTW_F 0 |
| 23 | /* A directory. */ |
| 24 | #define FTW_D 1 |
| 25 | /* An unreadable directory. */ |
| 26 | #define FTW_DNR	2 |
| 27 | /* An unstatable file. */ |
| 28 | #define FTW_NS 3 |
| 29 | /* A symbolic link (not supported). */ |
| 30 | #define FTW_SL 4 |
| 31 | /* A directory (all subdirs are visited). */ |
| 32 | #define FTW_DP 5 |
| 33 | /* A symbolic link naming non-existing file (not supported). */ |
| 34 | #define FTW_SLN 6 |
| 35 | |
| 36 | /* Do a physical walk (ignore symlinks). */ |
| 37 | #define FTW_PHYS 1 |
| 38 | /* Do report only files on same device as the argument (partial supported). */ |
| 39 | #define FTW_MOUNT 2 |
| 40 | /* Change to current directory while processing (unsupported). */ |
| 41 | #define FTW_CHDIR 4 |
| 42 | /* Do report files in directory before the directory itself.*/ |
| 43 | #define FTW_DEPTH 8 |
| 44 | /* Tell callback to return FTW_* values instead of zero to continue and non-zero to terminate. */ |
| 45 | #define FTW_ACTIONRETVAL 16 |
| 46 | |
| 47 | /* Continue with next sibling or with the first child-directory. */ |
| 48 | #define FTW_CONTINUE 0 |
| 49 | /* Return from ftw or nftw with FTW_STOP as return value. */ |
| 50 | #define FTW_STOP 1 |
| 51 | /* Valid only for FTW_D: Don't walk through the subtree. */ |
| 52 | #define FTW_SKIP_SUBTREE 2 |
| 53 | /* Continue with FTW_DP callback for current directory (if FTW_DEPTH) and then its siblings. */ |
| 54 | #define FTW_SKIP_SIBLINGS 3 |
| 55 | |
| 56 | /* |
| 57 | * When building mingw-w64 CRT files it is required that the ftw and |
| 58 | * nftw functions are not declared with __MINGW_ASM_CALL redirection. |
| 59 | * Otherwise the mingw-w64 would provide broken ftw and nftw symbols. |
| 60 | * To prevent ABI issues, the mingw-w64 runtime should not call the ftw, |
| 61 | * and nftw functions, instead it should call the fixed-size variants. |
| 62 | */ |
| 63 | #ifndef _CRTBLD |
| 64 | #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) |
| 65 | #ifdef _USE_32BIT_TIME_T |
| 66 | int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw32i64); |
| 67 | int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw32i64); |
| 68 | #else |
| 69 | int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw64); |
| 70 | int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw64); |
| 71 | #endif |
| 72 | #else |
| 73 | #ifdef _USE_32BIT_TIME_T |
| 74 | int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw32); |
| 75 | int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw32); |
| 76 | #else |
| 77 | int ftw (const char *, int (*) (const char *, const struct stat *, int), int) __MINGW_ASM_CALL(ftw64i32); |
| 78 | int nftw (const char *, int (*) (const char *, const struct stat *, int , struct FTW *), int, int) __MINGW_ASM_CALL(nftw64i32); |
| 79 | #endif |
| 80 | #endif |
| 81 | #endif |
| 82 | |
| 83 | int ftw64 (const char *, int (*) (const char *, const struct stat64 *, int), int); |
| 84 | int nftw64 (const char *, int (*) (const char *, const struct stat64 *, int , struct FTW *), int, int); |
| 85 | |
| 86 | #ifdef __cplusplus |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | #endif |