forked from simonsj/fdupes-jody
-
Notifications
You must be signed in to change notification settings - Fork 0
/
win_stat.h
56 lines (47 loc) · 1.73 KB
/
win_stat.h
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
47
48
49
50
51
52
53
54
55
56
/* Windows-native routines for getting stat()-like information
* See win_stat.c for license information */
#ifndef WIN_STAT_H
#define WIN_STAT_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MAN
#endif
#include <windows.h>
#include <stdint.h>
struct winstat {
uint64_t st_ino;
int64_t st_size;
uint32_t st_dev;
uint32_t st_nlink;
uint32_t st_mode;
time_t st_ctime;
time_t st_mtime;
time_t st_atime;
};
/* stat() macros for Windows "mode" flags (file attributes) */
#define S_ISARCHIVE(st_mode) ((st_mode & FILE_ATTRIBUTE_ARCHIVE) ? 1 : 0)
#define S_ISRO(st_mode) ((st_mode & FILE_ATTRIBUTE_READONLY) ? 1 : 0)
#define S_ISHIDDEN(st_mode) ((st_mode & FILE_ATTRIBUTE_HIDDEN) ? 1 : 0)
#define S_ISSYSTEM(st_mode) ((st_mode & FILE_ATTRIBUTE_SYSTEM) ? 1 : 0)
#define S_ISCRYPT(st_mode) ((st_mode & FILE_ATTRIBUTE_ENCRYPTED) ? 1 : 0)
#define S_ISDIR(st_mode) ((st_mode & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0)
#define S_ISCOMPR(st_mode) ((st_mode & FILE_ATTRIBUTE_COMPRESSED) ? 1 : 0)
#define S_ISREPARSE(st_mode) ((st_mode & FILE_ATTRIBUTE_REPARSE) ? 1 : 0)
#define S_ISSPARSE(st_mode) ((st_mode & FILE_ATTRIBUTE_SPARSE) ? 1 : 0)
#define S_ISTEMP(st_mode) ((st_mode & FILE_ATTRIBUTE_TEMPORARY) ? 1 : 0)
#define S_ISREG(st_mode) ((st_mode & FILE_ATTRIBUTE_DIRECTORY) ? 0 : 1)
#ifndef WPATH_MAX
#define WPATH_MAX 8192
#endif
#ifndef M2W
#define M2W(a,b) MultiByteToWideChar(CP_UTF8, 0, a, -1, (LPWSTR)b, WPATH_MAX)
#endif
extern time_t nttime_to_unixtime(const uint64_t * const restrict timestamp);
extern time_t unixtime_to_nttime(const uint64_t * const restrict timestamp);
extern int win_stat(const char * const filename, struct winstat * const restrict buf);
#ifdef __cplusplus
}
#endif
#endif /* WIN_STAT_H */