# define tmkdir(path, mode) _wmkdir(path)
# define tstrerror_r win32_strerror_r_replacement
# define trename win32_rename_replacement
-# define ttruncate win32_truncate_replacement
# define tglob win32_wglob
#else /* __WIN32__ */
/* For non-Windows builds, the "tchar" type will be one byte and will specify a
# define TSTRDUP STRDUP
# define tstrerror_r strerror_r
# define trename rename
-# define ttruncate truncate
# define taccess access
# define tglob glob
#endif /* !__WIN32__ */
return -1;
}
-/* truncate() replacement */
-int
-win32_truncate_replacement(const wchar_t *path, off_t size)
-{
- DWORD err = NO_ERROR;
- LARGE_INTEGER liOffset;
-
- HANDLE h = win32_open_existing_file(path, GENERIC_WRITE);
- if (h == INVALID_HANDLE_VALUE)
- goto fail;
-
- liOffset.QuadPart = size;
- if (!SetFilePointerEx(h, liOffset, NULL, FILE_BEGIN))
- goto fail_close_handle;
-
- if (!SetEndOfFile(h))
- goto fail_close_handle;
- CloseHandle(h);
- return 0;
-
-fail_close_handle:
- err = GetLastError();
- CloseHandle(h);
-fail:
- if (err == NO_ERROR)
- err = GetLastError();
- set_errno_from_win32_error(err);
- return -1;
-}
-
-
/* This really could be replaced with _wcserror_s, but this doesn't seem to
* actually be available in MSVCRT.DLL on Windows XP (perhaps it's statically
* linked in by Visual Studio...?). */