mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-04-11 00:30:47 +00:00
Fix FileUtils::touch() build on Mac.
The utimensat/futimens system calls were introduced in relatively recent Linux kernels and are not available on Mac. Use utimes/futimes instead - since microsecond precision is fine for our needs.
This commit is contained in:
parent
50faf07f00
commit
1c3cdde4c1
1 changed files with 7 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
|
@ -258,16 +259,20 @@ void FileUtils::touch(const char* path) throw (IOException)
|
|||
{
|
||||
#ifdef PLATFORM_UNIX
|
||||
// see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html
|
||||
//
|
||||
// we use utimes/futimes instead of utimensat/futimens for compatibility
|
||||
// with older Linux and Mac
|
||||
|
||||
if (fileExists(path))
|
||||
{
|
||||
utimensat(AT_FDCWD,path,0 /* use current date/time */,0);
|
||||
utimes(path,0 /* use current date/time */);
|
||||
}
|
||||
else
|
||||
{
|
||||
int fd = creat(path,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd != -1)
|
||||
{
|
||||
futimens(fd,0 /* use current date/time */);
|
||||
futimes(fd,0 /* use current date/time */);
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue