mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-04 10:18:31 +00:00
Perform some minor fixups
This commit is contained in:
parent
ca88ce5026
commit
4e93750afd
9 changed files with 24 additions and 50 deletions
|
@ -21,15 +21,14 @@
|
|||
#include "libc/nt/files.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int sys_ftruncate_nt(int fd, uint64_t length) {
|
||||
textwindows int sys_ftruncate_nt(int64_t handle, uint64_t length) {
|
||||
bool32 ok;
|
||||
int64_t tell;
|
||||
if (!__isfdkind(fd, kFdFile)) return ebadf();
|
||||
tell = -1;
|
||||
if (SetFilePointerEx(g_fds.p[fd].handle, 0, &tell, kNtFileCurrent)) {
|
||||
ok = SetFilePointerEx(g_fds.p[fd].handle, length, NULL, kNtFileBegin) &&
|
||||
SetEndOfFile(g_fds.p[fd].handle);
|
||||
SetFilePointerEx(g_fds.p[fd].handle, tell, NULL, kNtFileBegin);
|
||||
if (SetFilePointerEx(handle, 0, &tell, kNtFileCurrent)) {
|
||||
ok = SetFilePointerEx(handle, length, NULL, kNtFileBegin) &&
|
||||
SetEndOfFile(handle);
|
||||
SetFilePointerEx(handle, tell, NULL, kNtFileBegin);
|
||||
return ok ? 0 : __winerr();
|
||||
} else {
|
||||
return __winerr();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue