[前][次][番号順一覧][スレッド一覧]

ruby-changes:44509

From: naruse <ko1@a...>
Date: Sat, 5 Nov 2016 17:24:03 +0900 (JST)
Subject: [ruby-changes:44509] naruse:r56582 (trunk): * ext/-test/file/fs.c (get_atime_p): Updating of file access times

naruse	2016-11-05 17:23:57 +0900 (Sat, 05 Nov 2016)

  New Revision: 56582

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56582

  Log:
    * ext/-test/file/fs.c (get_atime_p): Updating of file access times
      is enabled or not.

  Modified files:
    trunk/ChangeLog
    trunk/ext/-test-/file/extconf.rb
    trunk/ext/-test-/file/fs.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56581)
+++ ChangeLog	(revision 56582)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Nov  5 17:18:24 2016  NARUSE, Yui  <naruse@r...>
+
+	* ext/-test/file/fs.c (get_atime_p): Updating of file access times
+	  is enabled or not.
+
 Sat Nov  5 16:28:07 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* io.c (extract_getline_opts): extract chomp option.
Index: ext/-test-/file/extconf.rb
===================================================================
--- ext/-test-/file/extconf.rb	(revision 56581)
+++ ext/-test-/file/extconf.rb	(revision 56582)
@@ -5,6 +5,7 @@ headers = %w[sys/param.h sys/mount.h sys https://github.com/ruby/ruby/blob/trunk/ext/-test-/file/extconf.rb#L5
 if have_type("struct statfs", headers)
   have_struct_member("struct statfs", "f_fstypename", headers)
   have_struct_member("struct statfs", "f_type", headers)
+  have_struct_member("struct statfs", "f_flags", headers)
 end
 
 headers = %w[sys/statvfs.h].select {|h| have_header(h)}
Index: ext/-test-/file/fs.c
===================================================================
--- ext/-test-/file/fs.c	(revision 56581)
+++ ext/-test-/file/fs.c	(revision 56582)
@@ -36,6 +36,12 @@ typedef struct statvfs statfs_t; https://github.com/ruby/ruby/blob/trunk/ext/-test-/file/fs.c#L36
 # if defined HAVE_STRUCT_STATVFS_F_TYPE
 #   define HAVE_STRUCT_STATFS_T_F_TYPE 1
 # endif
+#elif defined(HAVE_STRUCT_STATFS_F_TYPE) /* Linux */
+typedef struct statfs statfs_t;
+# define STATFS(f, s) statfs((f), (s))
+# if defined HAVE_STRUCT_STATFS_F_TYPE
+#   define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
 #endif
 
 VALUE
@@ -72,9 +78,31 @@ get_fsname(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/-test-/file/fs.c#L78
     return Qnil;
 }
 
+VALUE
+get_atime_p(VALUE self, VALUE str)
+{
+#ifdef STATFS
+    statfs_t st;
+    FilePathValue(str);
+    str = rb_str_encode_ospath(str);
+    if (STATFS(StringValueCStr(str), &st) == -1) {
+       rb_sys_fail_str(str);
+    }
+# ifdef HAVE_STRUCT_STATFS_F_FLAGS
+#  ifdef MNT_NOATIME
+    return st.f_flags & MNT_NOATIME ? Qtrue : Qfalse;
+#  elif defined(ST_NOATIME)
+    return st.f_flags & ST_NOATIME ? Qtrue : Qfalse;
+#  endif
+# endif
+#endif
+    return Qnil;
+}
+
 void
 Init_fs(VALUE module)
 {
     VALUE fs = rb_define_module_under(module, "Fs");
     rb_define_module_function(fs, "fsname", get_fsname, 1);
+    rb_define_module_function(fs, "atime?", get_atime_p, 1);
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]