Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
sunos: implement uv_fs_futime()
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Oct 12, 2011
1 parent 014394d commit 721ad8c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/unix/eio/config_sunos.h
Expand Up @@ -11,7 +11,7 @@
#define HAVE_UTIMES 1

/* futimes(2) is available */
/* #undef HAVE_FUTIMES */
#define HAVE_FUTIMES 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
Expand Down
4 changes: 4 additions & 0 deletions src/unix/eio/eio.c
Expand Up @@ -108,6 +108,10 @@ static void eio_destroy (eio_req *req);

#define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1)

#ifdef __sun
# define futimes(fd, times) futimesat (fd, NULL, times)
#endif

#ifdef _WIN32

#include <direct.h>
Expand Down
8 changes: 6 additions & 2 deletions src/unix/fs.c
Expand Up @@ -496,7 +496,7 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
}


#if defined(HAVE_FUTIMES)
#if HAVE_FUTIMES
static int _futime(const uv_file file, double atime, double mtime) {
struct timeval tv[2];

Expand All @@ -507,14 +507,18 @@ static int _futime(const uv_file file, double atime, double mtime) {
tv[1].tv_sec = mtime;
tv[1].tv_usec = (unsigned long)(mtime * 1000000) % 1000000;

#ifdef __sun
return futimesat(file, NULL, tv);
#else
return futimes(file, tv);
#endif
}
#endif


int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
double mtime, uv_fs_cb cb) {
#if defined(HAVE_FUTIMES)
#if HAVE_FUTIMES
const char* path = NULL;

uv_fs_req_init(loop, req, UV_FS_FUTIME, path, cb);
Expand Down
6 changes: 1 addition & 5 deletions src/unix/internal.h
Expand Up @@ -49,11 +49,7 @@

#endif /* __linux__ */

#ifdef __APPLE__
# define HAVE_FUTIMES 1
#endif

#ifdef __FreeBSD__
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun)
# define HAVE_FUTIMES 1
#endif

Expand Down

0 comments on commit 721ad8c

Please sign in to comment.