From eac8defeed7e44b6d024dd9f18e8bb11a65edb96 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Sun, 4 Jun 2006 17:24:37 +0000 Subject: [PATCH] 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. svn path=/trunk/; revision=22216 --- reactos/lib/crt/io/chsize.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/lib/crt/io/chsize.c b/reactos/lib/crt/io/chsize.c index 6275f290e9d..78410c0debd 100644 --- a/reactos/lib/crt/io/chsize.c +++ b/reactos/lib/crt/io/chsize.c @@ -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; }