Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix #382 #397

Closed
wants to merge 3 commits into from

2 participants

@Keno

This should fix #382

@piscisaureus
Collaborator

Cool. Can you sign the node.js CLA?

http://nodejs.org/cla.html

@Keno

Done

@piscisaureus
Collaborator

Hmm. It doesn't compile, but I'll fix it myself

@Keno

whoops you're right I had a stale commit lying around that I didn't push onto the proper branch

@piscisaureus
Collaborator

Ok, landed with some modifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 28, 2012
  1. @Keno

    Attempt to fix #382

    Keno authored
  2. @Keno
Commits on Apr 29, 2012
  1. @Keno

    fix typos

    Keno authored
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 3 deletions.
  1. +20 −3 src/win/fs.c
  2. +4 −0 src/win/winapi.h
View
23 src/win/fs.c
@@ -574,11 +574,28 @@ void fs__fsync(uv_fs_t* req, uv_file file) {
void fs__ftruncate(uv_fs_t* req, uv_file file, int64_t offset) {
int result;
-
+ HANDLE handle;
+ NTSTATUS nt_status;
+ IO_STATUS_BLOCK io_status;
+ FILE_END_OF_FILE_INFORMATION eof_info;
+
VERIFY_UV_FILE(file, req);
- result = _chsize_s(file, offset);
- SET_REQ_RESULT(req, result);
+ handle = (HANDLE)_get_osfhandle(file);
+
+ eof_info.EndOfFile.QuadPart = offset;
+
+ nt_status = pNtSetInformationFile(handle,
+ &io_status,
+ &eof_info,
+ sizeof eof_info,
+ FileEndOfFileInformation);
+
+ if (nt_status == STATUS_SUCCESS) {
+ SET_REQ_RESULT(req, 0);
+ } else {
+ SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status));
+ }
}
View
4 src/win/winapi.h
@@ -4141,6 +4141,10 @@ typedef struct _FILE_MODE_INFORMATION {
ULONG Mode;
} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
+typedef struct _FILE_END_OF_FILE_INFORMATION {
+ LARGE_INTEGER EndOfFile;
+} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
+
#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
Something went wrong with that request. Please try again.