fix aesgcm on cygwin

This fixes #372
This commit is contained in:
Steffen Jaeckel 2018-04-06 10:19:53 +02:00
parent fa759d8ee9
commit ba54b891b9

View File

@ -39,15 +39,27 @@ static off_t fsize(const char *filename)
return -1;
}
#if defined(__linux__) && defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 14)
#define HAS_SYNCFS
#endif
#endif
static int mv(const char *old_name, const char *new_name)
{
int fd;
if (rename(old_name, new_name) == -1) return -1;
fd = open(new_name, 0);
if (fd == -1) return -1;
#if !defined(_WIN32)
if (fsync(fd) != 0) goto OUT;
#if defined(HAS_SYNCFS)
syncfs(fd);
#else
sync();
#endif
OUT:
#endif
close(fd);
return 0;
}