Commit a6a5fb7a authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

Fix initial position for files opened with O_APPEND flag.

parent 9e18b7ef
...@@ -1480,13 +1480,6 @@ int MSVCRT__sopen( const char *path, int oflags, int shflags, ... ) ...@@ -1480,13 +1480,6 @@ int MSVCRT__sopen( const char *path, int oflags, int shflags, ... )
fd = msvcrt_alloc_fd(hand, wxflag); fd = msvcrt_alloc_fd(hand, wxflag);
TRACE(":fd (%d) handle (%p)\n",fd, hand); TRACE(":fd (%d) handle (%p)\n",fd, hand);
if (fd > 0)
{
if (oflags & MSVCRT__O_APPEND)
_lseek(fd, 0, FILE_END);
}
return fd; return fd;
} }
......
...@@ -242,6 +242,14 @@ static void test_file_write_read( void ) ...@@ -242,6 +242,14 @@ static void test_file_write_read( void )
ok( memcmp(mytext,btext,strlen(mytext)) == 0, ok( memcmp(mytext,btext,strlen(mytext)) == 0,
"problems with _O_TEXT _write / _read\n"); "problems with _O_TEXT _write / _read\n");
_close(tempfd); _close(tempfd);
memset(btext, 0, LLEN);
tempfd = _open(tempf,_O_APPEND|_O_RDWR); /* open for APPEND in default mode */
ok(tell(tempfd) == 0, "bad position %lu expecting 0\n", tell(tempfd));
ok(_read(tempfd,btext,LLEN) == lstrlenA(mytext), "_read _O_APPEND got bad length\n");
ok( memcmp(mytext,btext,strlen(mytext)) == 0, "problems with _O_APPEND _read\n");
_close(tempfd);
ret = unlink(tempf); ret = unlink(tempf);
ok( ret !=-1 ,"Can't unlink '%s': %d\n", tempf, errno); ok( ret !=-1 ,"Can't unlink '%s': %d\n", tempf, errno);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment