On Windows, files opened with _O_RDONLY receive the read-only attribute and hence can't be unlinked. What's more, errno is set to ENOENT on XP, contrary to MSDN. So we have to change the mode before attempting the deletion. ChangeLog: Fix undeleted temporary file. Feri. Index: dlls/msvcrt/tests/file.c =================================================================== RCS file: /home/wine/wine/dlls/msvcrt/tests/file.c,v retrieving revision 1.6 diff -u -r1.6 file.c --- dlls/msvcrt/tests/file.c 24 Oct 2003 00:24:08 -0000 1.6 +++ dlls/msvcrt/tests/file.c 16 Dec 2003 23:56:40 -0000 @@ -213,7 +213,8 @@ ok( memcmp(mytext,btext,strlen(mytext)) == 0,"problems with _O_TEXT _write / _write"); _close(tempfd); - unlink(tempf); + ok(_chmod (tempf, _S_IREAD | _S_IWRITE) == 0, "Can't chmod to read-write: %d", errno); + ok(unlink(tempf) !=-1 ,"Can't unlink '%s': %d", tempf, errno); } static void test_tmpnam( void )