Permalink
Browse files

Remove utime and utimeSync (utimes and utimesSync are in Node core) (#71

)
  • Loading branch information...
1 parent de78dda commit 500be8514729c194ac7ca2b30b5bc7eaf812670d @davedoesdev davedoesdev committed with Sep 19, 2017
Showing with 1,109 additions and 804 deletions.
  1. +3 −16 README.md
  2. +0 −63 fs-ext.cc
  3. +0 −27 fs-ext.js
  4. +1,105 −0 package-lock.json
  5. +1 −1 package.json
  6. +0 −2 run_tests.js
  7. +0 −394 tests/test-fs-utime.js
  8. +0 −301 tests/test-fs-utime_stress.js
View
@@ -7,6 +7,9 @@ fs-ext
Extras not included in Node's fs module.
+**Note**: From v1.0.0 onwards, fs.utime and fs.utimeSync have been removed.
+Use fs.utimes and fs.utimesSync instead.
+
Installation
------------
@@ -97,22 +100,6 @@ Synchronous lseek(2). Throws an exception on error. Returns current
file position.
-### fs.utime(path [, atime, mtime] [, callback])
-
-Asynchronous utime(2).
-
-Arguments `atime` and `mtime` are in seconds as for the system call. Note
-that the number value of Date() is in milliseconds, so to use the 'now'
-value with `fs.utime()` you would have to divide by 1000 first, e.g.
-Date.now()/1000
-
-Just like for utime(2), the absence of the `atime` and `mtime` means 'now'.
-
-### fs.utimeSync(path [, atime, mtime])
-
-Synchronous version of utime(). Throws an exception on error.
-
-
[ci-img]: https://travis-ci.org/baudehlo/node-fs-ext.svg?branch=master
[ci-url]: https://travis-ci.org/baudehlo/node-fs-ext
View
@@ -31,14 +31,12 @@
#ifndef _WIN32
#include <sys/file.h>
#include <unistd.h>
-#include <utime.h>
#include <sys/statvfs.h>
#endif
#ifdef _WIN32
#include <io.h>
#include <windows.h>
-#include <sys/utime.h>
#define off_t LONGLONG
#define _LARGEFILE_SOURCE
#endif
@@ -55,7 +53,6 @@ struct store_data_t {
int oper;
int arg;
off_t offset;
- struct utimbuf utime_buf;
#ifndef _WIN32
struct statvfs statvfs_buf;
#endif
@@ -89,7 +86,6 @@ enum
{
FS_OP_FLOCK,
FS_OP_SEEK,
- FS_OP_UTIME,
FS_OP_STATVFS,
#ifndef _WIN32
FS_OP_FCNTL,
@@ -119,7 +115,6 @@ static void EIO_After(uv_work_t *req) {
switch (store_data->fs_op) {
// These operations have no data to pass other than "error".
case FS_OP_FLOCK:
- case FS_OP_UTIME:
argc = 1;
break;
@@ -471,63 +466,6 @@ static NAN_METHOD(Fcntl) {
}
#endif
-static void EIO_UTime(uv_work_t *req) {
- store_data_t* utime_data = static_cast<store_data_t *>(req->data);
-
- int i = utime(utime_data->path, &utime_data->utime_buf);
- free( utime_data->path );
-
- if (i == (off_t)-1) {
- utime_data->result = -1;
- utime_data->error = errno;
- } else {
- utime_data->result = i;
- }
-
-}
-
-// Wrapper for utime(2).
-// fs.utime( path, atime, mtime, [callback] )
-
-static NAN_METHOD(UTime) {
- if (info.Length() < 3 ||
- info.Length() > 4 ||
- !info[0]->IsString() ||
- !info[1]->IsNumber() ||
- !info[2]->IsNumber() ) {
- return THROW_BAD_ARGS;
- }
-
- String::Utf8Value path(info[0]->ToString());
- time_t atime = info[1]->IntegerValue();
- time_t mtime = info[2]->IntegerValue();
-
- // Synchronous call needs much less work
- if ( ! info[3]->IsFunction()) {
- struct utimbuf buf;
- buf.actime = atime;
- buf.modtime = mtime;
- int ret = utime(*path, &buf);
- if (ret != 0) return Nan::ThrowError(Nan::ErrnoException(errno, "utime", "", *path));
- info.GetReturnValue().SetUndefined();
- return;
- }
-
- store_data_t* utime_data = new store_data_t();
-
- utime_data->cb = new Nan::Callback((Local<Function>) info[3].As<Function>());
- utime_data->fs_op = FS_OP_UTIME;
- utime_data->path = strdup(*path);
- utime_data->utime_buf.actime = atime;
- utime_data->utime_buf.modtime = mtime;
-
- uv_work_t *req = new uv_work_t;
- req->data = utime_data;
- uv_queue_work(uv_default_loop(), req, EIO_UTime, (uv_after_work_cb)EIO_After);
-
- info.GetReturnValue().SetUndefined();
-}
-
// Wrapper for statvfs(2).
// fs.statVFS( path, [callback] )
@@ -654,7 +592,6 @@ NAN_MODULE_INIT(init)
target->Set(Nan::New<String>("fcntl").ToLocalChecked(), Nan::New<FunctionTemplate>(Fcntl)->GetFunction());
#endif
target->Set(Nan::New<String>("flock").ToLocalChecked(), Nan::New<FunctionTemplate>(Flock)->GetFunction());
- target->Set(Nan::New<String>("utime").ToLocalChecked(), Nan::New<FunctionTemplate>(UTime)->GetFunction());
target->Set(Nan::New<String>("statVFS").ToLocalChecked(), Nan::New<FunctionTemplate>(StatVFS)->GetFunction());
#ifndef _WIN32
View
@@ -125,33 +125,6 @@ exports.seekSync = function(fd, position, whence) {
return binding.seek(fd, position, whence);
};
-
-// fs.utime('foo' [, atime, mtime] [, func] )
-
-exports.utime = function(path, atime, mtime, callback) {
- callback = arguments[arguments.length - 1];
- if (typeof(callback) !== 'function') {
- callback = noop;
- }
-
- if (typeof(atime) !== 'number' && typeof(mtime) !== 'number') {
- atime = mtime = Date.now() / 1000;
- }
-
- binding.utime(path, atime, mtime, callback);
-};
-
-// fs.utimeSync('foo' [, atime, mtime] )
-
-exports.utimeSync = function(path, atime, mtime) {
-
- if (typeof(atime) !== 'number' && typeof(mtime) !== 'number') {
- atime = mtime = Date.now() / 1000;
- }
-
- return binding.utime(path, atime, mtime);
-};
-
exports.statVFS = function(path, callback) {
path = path || '/';
return binding.statVFS(path, callback);
Oops, something went wrong.

0 comments on commit 500be85

Please sign in to comment.