1
0
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:
Yura Sokolov 2023-04-18 19:51:58 +03:00
parent 2538b5d91f
commit 2640ec6da0

View File

@ -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)
{