20 |
extern void enter_blocking_section(); |
extern void enter_blocking_section(); |
21 |
extern void leave_blocking_section(); |
extern void leave_blocking_section(); |
22 |
|
|
23 |
extern ssize_t os_read(OS_FD fd, char *buf, size_t len) |
extern ssize_t os_read(OS_FD fd, char *buf, size_t len) |
24 |
{ |
{ |
25 |
DWORD numread; |
DWORD numread; |
26 |
BOOL ret; |
BOOL ret; |
37 |
return numread; |
return numread; |
38 |
} |
} |
39 |
|
|
40 |
#include <winioctl.h> |
#include <winioctl.h> |
41 |
|
|
42 |
void os_ftruncate(OS_FD fd, OFF_T size) |
void os_ftruncate(OS_FD fd, OFF_T size, /* bool */ int sparse) |
43 |
{ |
{ |
44 |
uint curpos; |
uint curpos; |
45 |
long ofs_low = (long) size; |
long ofs_low = (long) size; |
46 |
long ofs_high = (long) (size >> 32); |
long ofs_high = (long) (size >> 32); |
47 |
|
|
48 |
DWORD dw; |
if (sparse) { |
49 |
BOOL bRet = DeviceIoControl(fd, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw, NULL); |
DWORD dw; |
50 |
if (!bRet) { |
BOOL bRet = DeviceIoControl(fd, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw, NULL); |
51 |
// No sparse files for you, sucker... |
if (!bRet) { |
52 |
// DWORD err = GetLastError(); |
// No sparse files for you, sucker... |
53 |
} |
// DWORD err = GetLastError(); |
54 |
|
} |
55 |
|
} |
56 |
curpos = SetFilePointer (fd, 0, NULL, FILE_CURRENT); |
curpos = SetFilePointer (fd, 0, NULL, FILE_CURRENT); |
57 |
if (curpos == 0xFFFFFFFF |
if (curpos == 0xFFFFFFFF |
58 |
|| SetFilePointer (fd, ofs_low, &ofs_high, FILE_BEGIN) == 0xFFFFFFFF |
|| SetFilePointer (fd, ofs_low, &ofs_high, FILE_BEGIN) == 0xFFFFFFFF |
100 |
} |
} |
101 |
} |
} |
102 |
|
|
103 |
OFF_T os_lseek(OS_FD fd, OFF_T ofs, int cmd) |
OFF_T os_lseek(OS_FD fd, OFF_T ofs, int cmd) |
104 |
{ |
{ |
105 |
long ret; |
long ret; |
106 |
long ofs_low = ofs; |
long ofs_low = ofs; |
115 |
uerror("os_lseek", Nothing); |
uerror("os_lseek", Nothing); |
116 |
} |
} |
117 |
} |
} |
118 |
return ((OFF_T) ofs_high << 32 | ret); |
return ((OFF_T) ofs_high << 32 | ret); |
119 |
} |
} |
120 |
|
|
121 |
#include <winsock2.h> |
#include <winsock2.h> |