mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-11-28 09:33:54 +02:00
use _chsize_s on windows to grow file
This commit is contained in:
parent
2538b5d91f
commit
2640ec6da0
@ -2717,21 +2717,19 @@ fio_send_file_write(FILE* out, send_file_state* st, char *buf, size_t len)
|
||||
if (len == 0)
|
||||
return true;
|
||||
|
||||
#ifndef WIN32
|
||||
#ifdef WIN32
|
||||
if (st->read_size > st->write_size &&
|
||||
_chsize_s(fileno(out), st->read_size) != 0)
|
||||
{
|
||||
elog(WARNING, "Could not change file size to %lld: %m", st->read_size)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (st->read_size > st->write_size &&
|
||||
fseeko(out, st->read_size, SEEK_SET) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
while (st->read_size > st->write_size)
|
||||
{
|
||||
size_t wr = st->read_size - st->write_size;
|
||||
wr = Min(wr, sizeof(zerobuf));
|
||||
fwrite(zerobuf, 1, wr, out);
|
||||
st->write_size += wr;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fwrite(buf, 1, len, out) != len)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user