37 |
return numread; |
return numread; |
38 |
} |
} |
39 |
|
|
40 |
|
#include <winioctl.h> |
41 |
|
|
42 |
void os_ftruncate(OS_FD fd, OFF_T size) |
void os_ftruncate(OS_FD fd, OFF_T size) |
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; |
49 |
|
BOOL bRet = DeviceIoControl(fd, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw, NULL); |
50 |
|
if (!bRet) { |
51 |
|
// No sparse files for you, sucker... |
52 |
|
// DWORD err = GetLastError(); |
53 |
|
} |
54 |
curpos = SetFilePointer (fd, 0, NULL, FILE_CURRENT); |
curpos = SetFilePointer (fd, 0, NULL, FILE_CURRENT); |
55 |
if (curpos == 0xFFFFFFFF |
if (curpos == 0xFFFFFFFF |
56 |
|| SetFilePointer (fd, ofs_low, &ofs_high, FILE_BEGIN) == 0xFFFFFFFF |
|| SetFilePointer (fd, ofs_low, &ofs_high, FILE_BEGIN) == 0xFFFFFFFF |