Author: arty
Date: Sun Jun 4 21:24:37 2006
New Revision: 22216
URL:
http://svn.reactos.ru/svn/reactos?rev=22216&view=rev
Log:
Fix four winetests from msvcrt:file.c
- The winetests show that the pointer never moves after calling chsize.
- Using SetEndOfFile is the best way to do this. I wrote a test case that
uses WriteFile as we did before and it did not expand the file past eof.
Modified:
trunk/reactos/lib/crt/io/chsize.c
Modified: trunk/reactos/lib/crt/io/chsize.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/crt/io/chsize.c?rev=222…
==============================================================================
--- trunk/reactos/lib/crt/io/chsize.c (original)
+++ trunk/reactos/lib/crt/io/chsize.c Sun Jun 4 21:24:37 2006
@@ -10,9 +10,12 @@
int _chsize(int _fd, long size)
{
DPRINT("_chsize(fd %d, size %d)\n", _fd, size);
+ long location = _lseek(_fd, 0, SEEK_CUR);
+ if (location == -1) return -1;
if (_lseek(_fd, size, 0) == -1)
return -1;
- if (_write(_fd, 0, 0) < 0)
+ if (!SetEndOfFile((HANDLE)_get_osfhandle(_fd)))
return -1;
+ _lseek(_fd, location, SEEK_SET);
return 0;
}