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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
%% options
copyright owner = Dirk Krause
copyright year = 2015-xxxx
license = bsd
%% module
#include "dk4filei.h"
$!trace-include
#if DK4_ON_WINDOWS
static
void
dk4fileinfo_copy_ufi(
dk4_ufi_t *uptr,
const BY_HANDLE_FILE_INFORMATION *bhfi
)
{
uptr->ser = bhfi->dwVolumeSerialNumber;
uptr->inh = bhfi->nFileIndexHigh;
uptr->inl = bhfi->nFileIndexLow;
}
#else
static
void
dk4fileinfo_copy_ufi(
dk4_ufi_t *uptr,
const dk4_stat_t *stb
)
{
uptr->dev = stb->st_dev;
uptr->ino = stb->st_ino;
}
#endif
int
dk4fileinfo_ufi(
dk4_ufi_t *dptr, const dk4_file_info_t *src, int ch, dk4_er_t *erp
)
{
int back = 0;
if ((NULL != dptr) && (NULL != src)) {
switch (ch) {
case DK4_FILE_INFO_CONTENTS_DATA_LINK: {
if (0 != (DK4_FILE_INFO_CONTENTS_DATA_LINK & (src->contents))) {
back = 1;
#if DK4_ON_WINDOWS
if ((DWORD)0UL == src->resio) {
dk4fileinfo_copy_ufi(dptr, &(src->linfo));
} else {
back = 0;
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
#else
dk4fileinfo_copy_ufi(dptr, &(src->lstb));
#endif
} else {
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
} break;
default: {
if (0 != (DK4_FILE_INFO_CONTENTS_DATA_TARGET & (src->contents))) {
back = 1;
#if DK4_ON_WINDOWS
if ((DWORD)0UL == src->resio) {
dk4fileinfo_copy_ufi(dptr, &(src->tinfo));
} else {
back = 0;
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
#else
dk4fileinfo_copy_ufi(dptr, &(src->tstb));
#endif
} else {
dk4error_set_simple_error_code(erp, DK4_E_NOT_FOUND);
}
} break;
}
} else {
dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS);
}
return back;
}
|