[2/6] ntdll: Add support to NtWriteFile for special offset -1.

Dmitry Timoshkov dmitry at baikal.ru
Fri Sep 6 03:03:52 CDT 2013


---
 dlls/ntdll/file.c       |  3 +++
 dlls/ntdll/tests/file.c | 15 ---------------
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 9420df5..9d5b02a 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -967,6 +967,9 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
             goto done;
         }
 
+        if (offset && offset->QuadPart == (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */)
+            offset->QuadPart = lseek( unix_handle, 0, SEEK_END );
+
         if (offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */)
         {
             /* async I/O doesn't make sense on regular files */
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 86f8a77..0b2a764 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -1976,25 +1976,10 @@ static void test_read_write(void)
     iob.Information = -1;
     offset.QuadPart = (LONGLONG)-1 /* FILE_WRITE_TO_END_OF_FILE */;
     status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents + 7, sizeof(contents) - 7, &offset, NULL);
-todo_wine
     ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
-todo_wine
     ok(iob.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iob.Status);
-todo_wine
     ok(iob.Information == sizeof(contents) - 7, "expected sizeof(contents)-7, got %lu\n", iob.Information);
 
-    /* FIXME: Remove once Wine is fixed */
-    if (status != STATUS_SUCCESS)
-    {
-        iob.Status = -1;
-        iob.Information = -1;
-        offset.QuadPart = 7;
-        status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents + 7, sizeof(contents) - 7, &offset, NULL);
-        ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
-        ok(iob.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iob.Status);
-        ok(iob.Information == sizeof(contents) - 7, "expected sizeof(contents)-7, got %lu\n", iob.Information);
-    }
-
     off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
     ok(off == sizeof(contents), "expected sizeof(contents), got %u\n", off);
 
-- 
1.8.3.4




More information about the wine-patches mailing list