summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1995-04-05 11:35:21 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 22:09:32 +0900
commit11e21a36bc935088f88a7cd1548f8c74c3bf6099 (patch)
tree250c579beedb2a35708b0cea682bbad2280bdfd0 /file.c
parent4e65eab7abf53838579600e3dcc99a43012c45c2 (diff)
version 0.72v0_72
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.71-0.72.diff.gz Wed Apr 5 11:35:21 1995 Yukihiro Matsumoto (matz@ix-02) * version 0.72 * EWS4800対応 * file.c: utimesがない時はutimeを使うように.
Diffstat (limited to 'file.c')
-rw-r--r--file.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/file.c b/file.c
index 3c861da..5f46814 100644
--- a/file.c
+++ b/file.c
@@ -18,6 +18,11 @@
#include <unistd.h>
#endif
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
+
+
char *strdup();
extern VALUE C_IO;
@@ -889,6 +894,8 @@ Ffile_chown(obj, owner, group)
struct timeval *time_timeval();
+#ifdef HAVE_UTIME
+
static void
utime_internal(path, tvp)
char *path;
@@ -917,6 +924,55 @@ Sfile_utime(argc, argv, obj)
return INT2FIX(n);
}
+#else
+
+static void
+utime_internal(path, utp)
+ char *path;
+#ifdef HAVE_UTIME_H
+ struct utimbuf *utp;
+#else
+ struct {
+ long actime;
+ long modtime;
+ } *utp;
+#endif
+{
+ if (utime(path, utp) < 0)
+ rb_sys_fail(path);
+}
+
+static VALUE
+Sfile_utime(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE atime, mtime, rest;
+ int n;
+ struct timeval *tv;
+#ifdef HAVE_UTIME_H
+ struct utimbuf utbuf;
+#else
+ struct {
+ long actime;
+ long modtime;
+ } utbuf;
+#endif
+
+ rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
+
+ tv = time_timeval(atime);
+ utbuf.actime = tv->tv_sec;
+ tv = time_timeval(mtime);
+ utbuf.modtime = tv->tv_sec;
+
+ n = apply2files(utime_internal, rest, &utbuf);
+ return INT2FIX(n);
+}
+
+#endif
+
static VALUE
Sfile_link(obj, from, to)
VALUE obj;