summaryrefslogtreecommitdiff
path: root/ext/pathname
diff options
context:
space:
mode:
authorAkinori MUSHA <knu@idaemons.org>2022-04-04 02:03:09 +0900
committergit <svn-admin@ruby-lang.org>2022-04-21 17:10:19 +0900
commitcb02324c4e5c7aae0add0a5c4e5adbf637d9acb0 (patch)
tree74c62daf0ff30dee952ed2ca5c950a1efd61375e /ext/pathname
parent3ddf6ad4d2f6dae4caa00b8c407768c7062099a0 (diff)
[ruby/pathname] Implement Pathname#lutime
https://github.com/ruby/pathname/commit/268cb5acff
Diffstat (limited to 'ext/pathname')
-rw-r--r--ext/pathname/pathname.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 00ca85205b..e2c3c36dbf 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -35,6 +35,7 @@ static ID id_lchmod;
static ID id_lchown;
static ID id_link;
static ID id_lstat;
+static ID id_lutime;
static ID id_mkdir;
static ID id_mtime;
static ID id_open;
@@ -765,6 +766,19 @@ path_utime(VALUE self, VALUE atime, VALUE mtime)
}
/*
+ * Update the access and modification times of the file.
+ *
+ * Same as Pathname#utime, but does not follow symbolic links.
+ *
+ * See File.lutime.
+ */
+static VALUE
+path_lutime(VALUE self, VALUE atime, VALUE mtime)
+{
+ return rb_funcall(rb_cFile, id_lutime, 3, atime, mtime, get_strpath(self));
+}
+
+/*
* Returns the last component of the path.
*
* See File.basename.
@@ -1465,6 +1479,7 @@ path_f_pathname(VALUE self, VALUE str)
* - #make_symlink(old)
* - #truncate(length)
* - #utime(atime, mtime)
+ * - #lutime(atime, mtime)
* - #basename(*args)
* - #dirname
* - #extname
@@ -1563,6 +1578,7 @@ Init_pathname(void)
rb_define_method(rb_cPathname, "make_symlink", path_make_symlink, 1);
rb_define_method(rb_cPathname, "truncate", path_truncate, 1);
rb_define_method(rb_cPathname, "utime", path_utime, 2);
+ rb_define_method(rb_cPathname, "lutime", path_lutime, 2);
rb_define_method(rb_cPathname, "basename", path_basename, -1);
rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
rb_define_method(rb_cPathname, "extname", path_extname, 0);
@@ -1646,6 +1662,7 @@ InitVM_pathname(void)
id_lchown = rb_intern("lchown");
id_link = rb_intern("link");
id_lstat = rb_intern("lstat");
+ id_lutime = rb_intern("lutime");
id_mkdir = rb_intern("mkdir");
id_mtime = rb_intern("mtime");
id_open = rb_intern("open");