Skip to content

Commit

Permalink
* win32/win32.c (rb_chsize): no need to get the current file size.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jan 16, 2012
1 parent d3f8488 commit 688d00d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Mon Jan 16 11:22:38 2012 Nobuyoshi Nakada <[email protected]>

* win32/win32.c (rb_chsize): no need to get the current file size.

Mon Jan 16 00:41:33 2012 Sokolov Yura <[email protected]>

* st.c: st use function instead of macro. In my current
Expand Down
9 changes: 3 additions & 6 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -4676,18 +4676,15 @@ rb_w32_uaccess(const char *path, int mode)
static int
rb_chsize(HANDLE h, off_t size)
{
long upos, lpos, usize, lsize, uend, lend;
off_t end;
long upos, lpos, usize, lsize;
int ret = -1;
DWORD e;

if (((lpos = SetFilePointer(h, 0, (upos = 0, &upos), SEEK_CUR)) == -1L &&
(e = GetLastError())) ||
((lend = GetFileSize(h, (DWORD *)&uend)) == -1L && (e = GetLastError()))) {
if ((lpos = SetFilePointer(h, 0, (upos = 0, &upos), SEEK_CUR)) == -1L &&
(e = GetLastError())) {
errno = map_errno(e);
return -1;
}
end = ((off_t)uend << 32) | (unsigned long)lend;
usize = (long)(size >> 32);
lsize = (long)size;
if (SetFilePointer(h, lsize, &usize, SEEK_SET) == (DWORD)-1L &&
Expand Down

0 comments on commit 688d00d

Please sign in to comment.