diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-03-03 13:37:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-03-03 13:37:02 +0000 |
commit | 566b460705d0b58d0e5288dc73cfb80a59ace26e (patch) | |
tree | 79ce08b67c9a883ba54904b0887924293ab76b33 /file.c | |
parent | 44a1d06e1af5dc1e734a7201c33b17304cba2296 (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/branches/ruby_1_8@11973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -2008,13 +2008,16 @@ rb_file_s_utime(argc, argv) 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); @@ -2047,7 +2050,7 @@ rb_file_s_utime(argc, 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); |