Browse Source

remove unnecessary futimesat abstraction

pull/384/head
Antonio SJ Musumeci 9 years ago
parent
commit
cf567f11ce
  1. 5
      src/futimesat.cpp
  2. 9
      src/futimesat.hpp
  3. 35
      src/futimesat_osx.icpp

5
src/futimesat.cpp

@ -1,5 +0,0 @@
#include "futimesat.hpp"
#ifdef __APPLE__
#include "futimesat_osx.icpp"
#endif

9
src/futimesat.hpp

@ -1,9 +0,0 @@
#ifndef __UTIMESAT_HPP__
#define __UTIMESAT_HPP__
#if __APPLE__
int
_futimesat(int dirfd, const char* path, struct timeval *tvp);
#endif
#endif

35
src/futimesat_osx.icpp

@ -1,35 +0,0 @@
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <err.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <sys/param.h> /* MAXPATHLEN */
int
_futimesat(int fd, const char* path, struct timeval *tvp) {
char fullpath[MAXPATHLEN];
// Handle absolute paths
if(path[0] == '/') {
return ::utimes(path,tvp);
}
// OS X 10.12 (at least) has an issue with using AT_FDCWD in this specific call.
if (fd == AT_FDCWD) {
if (getcwd((char*)fullpath, MAXPATHLEN) == NULL) {
return -1;
}
} else {
if (fcntl(fd,F_GETPATH,fullpath) < 0) {
return -1;
}
}
if (strlcat(fullpath, "/", MAXPATHLEN) > MAXPATHLEN || strlcat(fullpath, path, MAXPATHLEN) > MAXPATHLEN) {
return (errno=ENAMETOOLONG,-1);
}
return ::utimes(fullpath,tvp);;
}
Loading…
Cancel
Save