mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* win32/win32.c (rb_chsize): no need to get the current file size.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d3f8488b1c
commit
688d00d23b
2 changed files with 7 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Mon Jan 16 11:22:38 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (rb_chsize): no need to get the current file size.
|
||||||
|
|
||||||
Mon Jan 16 00:41:33 2012 Sokolov Yura <funny.falcon@gmail.com>
|
Mon Jan 16 00:41:33 2012 Sokolov Yura <funny.falcon@gmail.com>
|
||||||
|
|
||||||
* st.c: st use function instead of macro. In my current
|
* st.c: st use function instead of macro. In my current
|
||||||
|
|
|
@ -4676,18 +4676,15 @@ rb_w32_uaccess(const char *path, int mode)
|
||||||
static int
|
static int
|
||||||
rb_chsize(HANDLE h, off_t size)
|
rb_chsize(HANDLE h, off_t size)
|
||||||
{
|
{
|
||||||
long upos, lpos, usize, lsize, uend, lend;
|
long upos, lpos, usize, lsize;
|
||||||
off_t end;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
DWORD e;
|
DWORD e;
|
||||||
|
|
||||||
if (((lpos = SetFilePointer(h, 0, (upos = 0, &upos), SEEK_CUR)) == -1L &&
|
if ((lpos = SetFilePointer(h, 0, (upos = 0, &upos), SEEK_CUR)) == -1L &&
|
||||||
(e = GetLastError())) ||
|
(e = GetLastError())) {
|
||||||
((lend = GetFileSize(h, (DWORD *)&uend)) == -1L && (e = GetLastError()))) {
|
|
||||||
errno = map_errno(e);
|
errno = map_errno(e);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
end = ((off_t)uend << 32) | (unsigned long)lend;
|
|
||||||
usize = (long)(size >> 32);
|
usize = (long)(size >> 32);
|
||||||
lsize = (long)size;
|
lsize = (long)size;
|
||||||
if (SetFilePointer(h, lsize, &usize, SEEK_SET) == (DWORD)-1L &&
|
if (SetFilePointer(h, lsize, &usize, SEEK_SET) == (DWORD)-1L &&
|
||||||
|
|
Loading…
Reference in a new issue