mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 15:42:49 +00:00
49d1a4c562
also start prefering NtDll API. so far: * NtQueryInformationFile * NtClose adds a performance workaround for windows unicode conversion. but that should probably be removed before merging
26 lines
532 B
C
26 lines
532 B
C
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
|
|
int truncate(const char *pathname, _off_t len){
|
|
int ret, err;
|
|
int fd = _open(pathname,_O_BINARY|_O_RDWR);
|
|
if (fd == -1) return fd;
|
|
ret = ftruncate(fd,len);
|
|
_get_errno(&err);
|
|
_close(fd);
|
|
_set_errno(err);
|
|
return ret;
|
|
}
|
|
|
|
int truncate64(const char *pathname, _off64_t len){
|
|
int ret, err;
|
|
int fd = _open(pathname,_O_BINARY|_O_RDWR);
|
|
if (fd == -1) return fd;
|
|
ret = ftruncate64(fd,len);
|
|
_get_errno(&err);
|
|
_close(fd);
|
|
_set_errno(err);
|
|
return ret;
|
|
}
|