summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-03 13:37:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-03 13:37:02 +0000
commit15dabe82163717bbdadab82d72e657f5fa731e99 (patch)
tree17ec00efc23db217de48cdaaf2ce297a8b259356 /file.c
parent5d8187d77250484e7f72cbe08d87083a125b9c58 (diff)
* file.c (rb_file_s_utime): allow nil to set the current time.
* lib/fileutils.rb (touch): ditto, and added :mtime and :nocreate options. fixed: [ruby-talk:219037] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/file.c b/file.c
index cbda4dd36f..843b170553 100644
--- a/file.c
+++ b/file.c
@@ -1989,13 +1989,16 @@ static VALUE
rb_file_s_utime(int argc, VALUE *argv)
{
VALUE atime, mtime, rest;
- struct timeval tvp[2];
+ struct timeval tvs[2], *tvp = NULL;
long n;
rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
- tvp[0] = rb_time_timeval(atime);
- tvp[1] = rb_time_timeval(mtime);
+ if (!NIL_P(atime) || !NIL_P(mtime)) {
+ tvp = tvs;
+ tvp[0] = rb_time_timeval(atime);
+ tvp[1] = rb_time_timeval(mtime);
+ }
n = apply2files(utime_internal, rest, tvp);
return LONG2FIX(n);
@@ -2024,7 +2027,7 @@ rb_file_s_utime(int argc, VALUE *argv)
VALUE atime, mtime, rest;
long n;
struct timeval tv;
- struct utimbuf utbuf;
+ struct utimbuf utbuf, *utp = NULL;
rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);