HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/share/doc/ruby/html/File/Stat.html
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class File::Stat - RDoc Documentation</title>

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
</script>

<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">




<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    <div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  
  <p class="link"><a href="../Object.html">Object</a>
  
</div>

    <div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
  
  
    <li><a class="include" href="../Comparable.html">Comparable</a>
  
  
  </ul>
</div>

    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-c-new">::new</a>
    
    <li ><a href="#method-i-3C-3D-3E">#&lt;=&gt;</a>
    
    <li ><a href="#method-i-atime">#atime</a>
    
    <li ><a href="#method-i-birthtime">#birthtime</a>
    
    <li ><a href="#method-i-blksize">#blksize</a>
    
    <li ><a href="#method-i-blockdev-3F">#blockdev?</a>
    
    <li ><a href="#method-i-blocks">#blocks</a>
    
    <li ><a href="#method-i-chardev-3F">#chardev?</a>
    
    <li ><a href="#method-i-ctime">#ctime</a>
    
    <li ><a href="#method-i-dev">#dev</a>
    
    <li ><a href="#method-i-dev_major">#dev_major</a>
    
    <li ><a href="#method-i-dev_minor">#dev_minor</a>
    
    <li ><a href="#method-i-directory-3F">#directory?</a>
    
    <li ><a href="#method-i-executable-3F">#executable?</a>
    
    <li ><a href="#method-i-executable_real-3F">#executable_real?</a>
    
    <li ><a href="#method-i-file-3F">#file?</a>
    
    <li ><a href="#method-i-ftype">#ftype</a>
    
    <li ><a href="#method-i-gid">#gid</a>
    
    <li ><a href="#method-i-grpowned-3F">#grpowned?</a>
    
    <li ><a href="#method-i-ino">#ino</a>
    
    <li ><a href="#method-i-inspect">#inspect</a>
    
    <li ><a href="#method-i-mode">#mode</a>
    
    <li ><a href="#method-i-mtime">#mtime</a>
    
    <li ><a href="#method-i-nlink">#nlink</a>
    
    <li ><a href="#method-i-owned-3F">#owned?</a>
    
    <li ><a href="#method-i-pipe-3F">#pipe?</a>
    
    <li ><a href="#method-i-rdev">#rdev</a>
    
    <li ><a href="#method-i-rdev_major">#rdev_major</a>
    
    <li ><a href="#method-i-rdev_minor">#rdev_minor</a>
    
    <li ><a href="#method-i-readable-3F">#readable?</a>
    
    <li ><a href="#method-i-readable_real-3F">#readable_real?</a>
    
    <li ><a href="#method-i-setgid-3F">#setgid?</a>
    
    <li ><a href="#method-i-setuid-3F">#setuid?</a>
    
    <li ><a href="#method-i-size">#size</a>
    
    <li ><a href="#method-i-size-3F">#size?</a>
    
    <li ><a href="#method-i-socket-3F">#socket?</a>
    
    <li ><a href="#method-i-sticky-3F">#sticky?</a>
    
    <li ><a href="#method-i-symlink-3F">#symlink?</a>
    
    <li ><a href="#method-i-uid">#uid</a>
    
    <li ><a href="#method-i-world_readable-3F">#world_readable?</a>
    
    <li ><a href="#method-i-world_writable-3F">#world_writable?</a>
    
    <li ><a href="#method-i-writable-3F">#writable?</a>
    
    <li ><a href="#method-i-writable_real-3F">#writable_real?</a>
    
    <li ><a href="#method-i-zero-3F">#zero?</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-File::Stat">
  <h1 id="class-File::Stat" class="class">
    class File::Stat
  </h1>

  <section class="description">
    
<p>Objects of class <a href="Stat.html"><code>File::Stat</code></a> encapsulate common status information for <a href="../File.html"><code>File</code></a> objects. The information is recorded at the moment the <a href="Stat.html"><code>File::Stat</code></a> object is created; changes made to the file after that point will not be reflected. <a href="Stat.html"><code>File::Stat</code></a> objects are returned by <a href="../IO.html#method-i-stat"><code>IO#stat</code></a>, <a href="../File.html#method-c-stat"><code>File::stat</code></a>, <a href="../File.html#method-i-lstat"><code>File#lstat</code></a>, and <a href="../File.html#method-c-lstat"><code>File::lstat</code></a>. Many of these methods return platform-specific values, and not all values are meaningful on all systems. See also <a href="../Kernel.html#method-i-test"><code>Kernel#test</code></a>.</p>

  </section>

  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

    
      <div id="method-c-new" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            File::Stat.new(file_name)  &rarr; stat
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Create a <a href="Stat.html"><code>File::Stat</code></a> object for the given file name (raising an exception if the file doesn&#39;t exist).</p>
          
          

          
          <div class="method-source-code" id="new-source">
            <pre>static VALUE
rb_stat_init(VALUE obj, VALUE fname)
{
    struct stat st, *nst;

    FilePathValue(fname);
    fname = rb_str_encode_ospath(fname);
    if (STAT(StringValueCStr(fname), &amp;st) == -1) {
        rb_sys_fail_path(fname);
    }
    if (DATA_PTR(obj)) {
        xfree(DATA_PTR(obj));
        DATA_PTR(obj) = NULL;
    }
    nst = ALLOC(struct stat);
    *nst = st;
    DATA_PTR(obj) = nst;

    return Qnil;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-3C-3D-3E" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            stat &lt;=&gt; other_stat    &rarr; -1, 0, 1, nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Compares <a href="Stat.html"><code>File::Stat</code></a> objects by comparing their respective modification times.</p>

<p><code>nil</code> is returned if <code>other_stat</code> is not a <a href="Stat.html"><code>File::Stat</code></a> object</p>

<pre class="ruby"><span class="ruby-identifier">f1</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;f1&quot;</span>, <span class="ruby-string">&quot;w&quot;</span>)
<span class="ruby-identifier">sleep</span> <span class="ruby-value">1</span>
<span class="ruby-identifier">f2</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;f2&quot;</span>, <span class="ruby-string">&quot;w&quot;</span>)
<span class="ruby-identifier">f1</span>.<span class="ruby-identifier">stat</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">f2</span>.<span class="ruby-identifier">stat</span>   <span class="ruby-comment">#=&gt; -1</span>
</pre>
          
          

          
          <div class="method-source-code" id="3C-3D-3E-source">
            <pre>static VALUE
rb_stat_cmp(VALUE self, VALUE other)
{
    if (rb_obj_is_kind_of(other, rb_obj_class(self))) {
        struct timespec ts1 = stat_mtimespec(get_stat(self));
        struct timespec ts2 = stat_mtimespec(get_stat(other));
        if (ts1.tv_sec == ts2.tv_sec) {
            if (ts1.tv_nsec == ts2.tv_nsec) return INT2FIX(0);
            if (ts1.tv_nsec &lt; ts2.tv_nsec) return INT2FIX(-1);
            return INT2FIX(1);
        }
        if (ts1.tv_sec &lt; ts2.tv_sec) return INT2FIX(-1);
        return INT2FIX(1);
    }
    return Qnil;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-atime" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            atime   &rarr; time
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the last access time for this file as an object of class <a href="../Time.html"><code>Time</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">atime</span>   <span class="ruby-comment">#=&gt; Wed Dec 31 18:00:00 CST 1969</span>
</pre>
          
          

          
          <div class="method-source-code" id="atime-source">
            <pre>static VALUE
rb_stat_atime(VALUE self)
{
    return stat_atime(get_stat(self));
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-birthtime" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            birthtime  &rarr;  aTime
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the birth time for <em>stat</em>.</p>

<p>If the platform doesn&#39;t have birthtime, raises <a href="../NotImplementedError.html"><code>NotImplementedError</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">write</span>(<span class="ruby-string">&quot;testfile&quot;</span>, <span class="ruby-string">&quot;foo&quot;</span>)
<span class="ruby-identifier">sleep</span> <span class="ruby-value">10</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">write</span>(<span class="ruby-string">&quot;testfile&quot;</span>, <span class="ruby-string">&quot;bar&quot;</span>)
<span class="ruby-identifier">sleep</span> <span class="ruby-value">10</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0644</span>, <span class="ruby-string">&quot;testfile&quot;</span>)
<span class="ruby-identifier">sleep</span> <span class="ruby-value">10</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&quot;testfile&quot;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">birthtime</span>   <span class="ruby-comment">#=&gt; 2014-02-24 11:19:17 +0900</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">mtime</span>       <span class="ruby-comment">#=&gt; 2014-02-24 11:19:27 +0900</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">ctime</span>       <span class="ruby-comment">#=&gt; 2014-02-24 11:19:37 +0900</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">atime</span>       <span class="ruby-comment">#=&gt; 2014-02-24 11:19:47 +0900</span>
</pre>
          
          

          
          <div class="method-source-code" id="birthtime-source">
            <pre>static VALUE
rb_stat_birthtime(VALUE self)
{
    return stat_birthtime(get_stat(self));
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-blksize" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            blksize   &rarr; integer or nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the native file system&#39;s block size. Will return <code>nil</code> on platforms that don&#39;t support this information.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">blksize</span>   <span class="ruby-comment">#=&gt; 4096</span>
</pre>
          
          

          
          <div class="method-source-code" id="blksize-source">
            <pre>static VALUE
rb_stat_blksize(VALUE self)
{
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
    return ULONG2NUM(get_stat(self)-&gt;st_blksize);
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-blockdev-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            blockdev?   &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if the file is a block device, <code>false</code> if it isn&#39;t or if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">blockdev?</span>    <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/hda1&quot;</span>).<span class="ruby-identifier">blockdev?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="blockdev-3F-source">
            <pre>static VALUE
rb_stat_b(VALUE obj)
{
#ifdef S_ISBLK
    if (S_ISBLK(get_stat(obj)-&gt;st_mode)) return Qtrue;

#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-blocks" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            blocks    &rarr; integer or nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the number of native file system blocks allocated for this file, or <code>nil</code> if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">blocks</span>   <span class="ruby-comment">#=&gt; 2</span>
</pre>
          
          

          
          <div class="method-source-code" id="blocks-source">
            <pre>static VALUE
rb_stat_blocks(VALUE self)
{
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
# if SIZEOF_STRUCT_STAT_ST_BLOCKS &gt; SIZEOF_LONG
    return ULL2NUM(get_stat(self)-&gt;st_blocks);
# else
    return ULONG2NUM(get_stat(self)-&gt;st_blocks);
# endif
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-chardev-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            chardev?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if the file is a character device, <code>false</code> if it isn&#39;t or if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/tty&quot;</span>).<span class="ruby-identifier">chardev?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="chardev-3F-source">
            <pre>static VALUE
rb_stat_c(VALUE obj)
{
    if (S_ISCHR(get_stat(obj)-&gt;st_mode)) return Qtrue;

    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-ctime" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            ctime  &rarr;  aTime
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the change time for <em>stat</em> (that is, the time directory information about the file was changed, not the file itself).</p>

<p>Note that on Windows (NTFS), returns creation time (birth time).</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">ctime</span>   <span class="ruby-comment">#=&gt; Wed Apr 09 08:53:14 CDT 2003</span>
</pre>
          
          

          
          <div class="method-source-code" id="ctime-source">
            <pre>static VALUE
rb_stat_ctime(VALUE self)
{
    return stat_ctime(get_stat(self));
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-dev" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            dev    &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns an integer representing the device on which <em>stat</em> resides.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">dev</span>   <span class="ruby-comment">#=&gt; 774</span>
</pre>
          
          

          
          <div class="method-source-code" id="dev-source">
            <pre>static VALUE
rb_stat_dev(VALUE self)
{
    return DEVT2NUM(get_stat(self)-&gt;st_dev);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-dev_major" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            dev_major   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the major part of <code>File_Stat#dev</code> or <code>nil</code>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/fd1&quot;</span>).<span class="ruby-identifier">dev_major</span>   <span class="ruby-comment">#=&gt; 2</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/tty&quot;</span>).<span class="ruby-identifier">dev_major</span>   <span class="ruby-comment">#=&gt; 5</span>
</pre>
          
          

          
          <div class="method-source-code" id="dev_major-source">
            <pre>static VALUE
rb_stat_dev_major(VALUE self)
{
#if defined(major)
    return UINT2NUM(major(get_stat(self)-&gt;st_dev));
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-dev_minor" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            dev_minor   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the minor part of <code>File_Stat#dev</code> or <code>nil</code>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/fd1&quot;</span>).<span class="ruby-identifier">dev_minor</span>   <span class="ruby-comment">#=&gt; 1</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/tty&quot;</span>).<span class="ruby-identifier">dev_minor</span>   <span class="ruby-comment">#=&gt; 0</span>
</pre>
          
          

          
          <div class="method-source-code" id="dev_minor-source">
            <pre>static VALUE
rb_stat_dev_minor(VALUE self)
{
#if defined(minor)
    return UINT2NUM(minor(get_stat(self)-&gt;st_dev));
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-directory-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            directory?(file_name)   &rarr;  true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if the named file is a directory, or a symlink that points at a directory, and <code>false</code> otherwise.</p>

<p><em>file_name</em> can be an <a href="../IO.html"><code>IO</code></a> object.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-string">&quot;.&quot;</span>)
</pre>
          
          

          
          <div class="method-source-code" id="directory-3F-source">
            <pre>static VALUE
rb_stat_d(VALUE obj)
{
    if (S_ISDIR(get_stat(obj)-&gt;st_mode)) return Qtrue;
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-executable-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            executable?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is executable or if the operating system doesn&#39;t distinguish executable files from nonexecutable files. The tests are made using the effective owner of the process.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">executable?</span>   <span class="ruby-comment">#=&gt; false</span>
</pre>
          
          

          
          <div class="method-source-code" id="executable-3F-source">
            <pre>static VALUE
rb_stat_x(VALUE obj)
{
    struct stat *st = get_stat(obj);

#ifdef USE_GETEUID
    if (geteuid() == 0) {
        return st-&gt;st_mode &amp; S_IXUGO ? Qtrue : Qfalse;
    }
#endif
#ifdef S_IXUSR
    if (rb_stat_owned(obj))
        return st-&gt;st_mode &amp; S_IXUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IXGRP
    if (rb_stat_grpowned(obj))
        return st-&gt;st_mode &amp; S_IXGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IXOTH
    if (!(st-&gt;st_mode &amp; S_IXOTH)) return Qfalse;
#endif
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-executable_real-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            executable_real?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Same as <code>executable?</code>, but tests using the real owner of the process.</p>
          
          

          
          <div class="method-source-code" id="executable_real-3F-source">
            <pre>static VALUE
rb_stat_X(VALUE obj)
{
    struct stat *st = get_stat(obj);

#ifdef USE_GETEUID
    if (getuid() == 0) {
        return st-&gt;st_mode &amp; S_IXUGO ? Qtrue : Qfalse;
    }
#endif
#ifdef S_IXUSR
    if (rb_stat_rowned(obj))
        return st-&gt;st_mode &amp; S_IXUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IXGRP
    if (rb_group_member(get_stat(obj)-&gt;st_gid))
        return st-&gt;st_mode &amp; S_IXGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IXOTH
    if (!(st-&gt;st_mode &amp; S_IXOTH)) return Qfalse;
#endif
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-file-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            file?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is a regular file (not a device file, pipe, socket, etc.).</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">file?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="file-3F-source">
            <pre>static VALUE
rb_stat_f(VALUE obj)
{
    if (S_ISREG(get_stat(obj)-&gt;st_mode)) return Qtrue;
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-ftype" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            ftype   &rarr; string
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Identifies the type of <em>stat</em>. The return string is one of: “<code>file</code>&#39;&#39;, “<code>directory</code>&#39;&#39;, “<code>characterSpecial</code>&#39;&#39;, “<code>blockSpecial</code>&#39;&#39;, “<code>fifo</code>&#39;&#39;, “<code>link</code>&#39;&#39;, “<code>socket</code>&#39;&#39;, or “<code>unknown</code>&#39;&#39;.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/tty&quot;</span>).<span class="ruby-identifier">ftype</span>   <span class="ruby-comment">#=&gt; &quot;characterSpecial&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="ftype-source">
            <pre>static VALUE
rb_stat_ftype(VALUE obj)
{
    return rb_file_ftype(get_stat(obj));
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-gid" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            gid   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the numeric group id of the owner of <em>stat</em>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">gid</span>   <span class="ruby-comment">#=&gt; 500</span>
</pre>
          
          

          
          <div class="method-source-code" id="gid-source">
            <pre>static VALUE
rb_stat_gid(VALUE self)
{
    return GIDT2NUM(get_stat(self)-&gt;st_gid);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-grpowned-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            grpowned?   &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns true if the effective group id of the process is the same as the group id of <em>stat</em>. On Windows NT, returns <code>false</code>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">grpowned?</span>      <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/etc/passwd&quot;</span>).<span class="ruby-identifier">grpowned?</span>   <span class="ruby-comment">#=&gt; false</span>
</pre>
          
          

          
          <div class="method-source-code" id="grpowned-3F-source">
            <pre>static VALUE
rb_stat_grpowned(VALUE obj)
{
#ifndef _WIN32
    if (rb_group_member(get_stat(obj)-&gt;st_gid)) return Qtrue;
#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-ino" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            ino   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the inode number for <em>stat</em>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">ino</span>   <span class="ruby-comment">#=&gt; 1083669</span>
</pre>
          
          

          
          <div class="method-source-code" id="ino-source">
            <pre>static VALUE
rb_stat_ino(VALUE self)
{
#ifdef HAVE_STRUCT_STAT_ST_INOHIGH
    /* assume INTEGER_PACK_LSWORD_FIRST and st_inohigh is just next of st_ino */
    return rb_integer_unpack(&amp;get_stat(self)-&gt;st_ino, 2,
            SIZEOF_STRUCT_STAT_ST_INO, 0,
            INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER|
            INTEGER_PACK_2COMP);
#elif SIZEOF_STRUCT_STAT_ST_INO &gt; SIZEOF_LONG
    return ULL2NUM(get_stat(self)-&gt;st_ino);
#else
    return ULONG2NUM(get_stat(self)-&gt;st_ino);
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-inspect" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            inspect  &rarr;  string
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Produce a nicely formatted description of <em>stat</em>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/etc/passwd&quot;</span>).<span class="ruby-identifier">inspect</span>
   <span class="ruby-comment">#=&gt; &quot;#&lt;File::Stat dev=0xe000005, ino=1078078, mode=0100644,</span>
   <span class="ruby-comment">#    nlink=1, uid=0, gid=0, rdev=0x0, size=1374, blksize=4096,</span>
   <span class="ruby-comment">#    blocks=8, atime=Wed Dec 10 10:16:12 CST 2003,</span>
   <span class="ruby-comment">#    mtime=Fri Sep 12 15:41:41 CDT 2003,</span>
   <span class="ruby-comment">#    ctime=Mon Oct 27 11:20:27 CST 2003,</span>
   <span class="ruby-comment">#    birthtime=Mon Aug 04 08:13:49 CDT 2003&gt;&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="inspect-source">
            <pre>static VALUE
rb_stat_inspect(VALUE self)
{
    VALUE str;
    size_t i;
    static const struct {
        const char *name;
        VALUE (*func)(VALUE);
    } member[] = {
        {&quot;dev&quot;,            rb_stat_dev},
        {&quot;ino&quot;,            rb_stat_ino},
        {&quot;mode&quot;,    rb_stat_mode},
        {&quot;nlink&quot;,   rb_stat_nlink},
        {&quot;uid&quot;,            rb_stat_uid},
        {&quot;gid&quot;,            rb_stat_gid},
        {&quot;rdev&quot;,    rb_stat_rdev},
        {&quot;size&quot;,    rb_stat_size},
        {&quot;blksize&quot;, rb_stat_blksize},
        {&quot;blocks&quot;,  rb_stat_blocks},
        {&quot;atime&quot;,   rb_stat_atime},
        {&quot;mtime&quot;,   rb_stat_mtime},
        {&quot;ctime&quot;,   rb_stat_ctime},
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC)
        {&quot;birthtime&quot;,   rb_stat_birthtime},
#endif
    };

    struct stat* st;
    TypedData_Get_Struct(self, struct stat, &amp;stat_data_type, st);
    if (!st) {
        return rb_sprintf(&quot;#&lt;%s: uninitialized&gt;&quot;, rb_obj_classname(self));
    }

    str = rb_str_buf_new2(&quot;#&lt;&quot;);
    rb_str_buf_cat2(str, rb_obj_classname(self));
    rb_str_buf_cat2(str, &quot; &quot;);

    for (i = 0; i &lt; sizeof(member)/sizeof(member[0]); i++) {
        VALUE v;

        if (i &gt; 0) {
            rb_str_buf_cat2(str, &quot;, &quot;);
        }
        rb_str_buf_cat2(str, member[i].name);
        rb_str_buf_cat2(str, &quot;=&quot;);
        v = (*member[i].func)(self);
        if (i == 2) {          /* mode */
            rb_str_catf(str, &quot;0%lo&quot;, (unsigned long)NUM2ULONG(v));
        }
        else if (i == 0 || i == 6) { /* dev/rdev */
            rb_str_catf(str, &quot;0x%&quot;PRI_DEVT_PREFIX&quot;x&quot;, NUM2DEVT(v));
        }
        else {
            rb_str_append(str, rb_inspect(v));
        }
    }
    rb_str_buf_cat2(str, &quot;&gt;&quot;);

    return str;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-mode" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            mode   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns an integer representing the permission bits of <em>stat</em>. The meaning of the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0644</span>, <span class="ruby-string">&quot;testfile&quot;</span>)   <span class="ruby-comment">#=&gt; 1</span>
<span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>)
<span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&quot;%o&quot;</span>, <span class="ruby-identifier">s</span>.<span class="ruby-identifier">mode</span>)          <span class="ruby-comment">#=&gt; &quot;100644&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="mode-source">
            <pre>static VALUE
rb_stat_mode(VALUE self)
{
    return UINT2NUM(ST2UINT(get_stat(self)-&gt;st_mode));
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-mtime" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            mtime  &rarr;  aTime
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the modification time of <em>stat</em>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">mtime</span>   <span class="ruby-comment">#=&gt; Wed Apr 09 08:53:14 CDT 2003</span>
</pre>
          
          

          
          <div class="method-source-code" id="mtime-source">
            <pre>static VALUE
rb_stat_mtime(VALUE self)
{
    return stat_mtime(get_stat(self));
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-nlink" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            nlink   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the number of hard links to <em>stat</em>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">nlink</span>             <span class="ruby-comment">#=&gt; 1</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">link</span>(<span class="ruby-string">&quot;testfile&quot;</span>, <span class="ruby-string">&quot;testfile.bak&quot;</span>)   <span class="ruby-comment">#=&gt; 0</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">nlink</span>             <span class="ruby-comment">#=&gt; 2</span>
</pre>
          
          

          
          <div class="method-source-code" id="nlink-source">
            <pre>static VALUE
rb_stat_nlink(VALUE self)
{
    return UINT2NUM(get_stat(self)-&gt;st_nlink);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-owned-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            owned?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if the effective user id of the process is the same as the owner of <em>stat</em>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">owned?</span>      <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/etc/passwd&quot;</span>).<span class="ruby-identifier">owned?</span>   <span class="ruby-comment">#=&gt; false</span>
</pre>
          
          

          
          <div class="method-source-code" id="owned-3F-source">
            <pre>static VALUE
rb_stat_owned(VALUE obj)
{
    if (get_stat(obj)-&gt;st_uid == geteuid()) return Qtrue;
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-pipe-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            pipe?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if the operating system supports pipes and <em>stat</em> is a pipe; <code>false</code> otherwise.</p>
          
          

          
          <div class="method-source-code" id="pipe-3F-source">
            <pre>static VALUE
rb_stat_p(VALUE obj)
{
#ifdef S_IFIFO
    if (S_ISFIFO(get_stat(obj)-&gt;st_mode)) return Qtrue;

#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-rdev" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            rdev   &rarr;  integer or nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns an integer representing the device type on which <em>stat</em> resides. Returns <code>nil</code> if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/fd1&quot;</span>).<span class="ruby-identifier">rdev</span>   <span class="ruby-comment">#=&gt; 513</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/tty&quot;</span>).<span class="ruby-identifier">rdev</span>   <span class="ruby-comment">#=&gt; 1280</span>
</pre>
          
          

          
          <div class="method-source-code" id="rdev-source">
            <pre>static VALUE
rb_stat_rdev(VALUE self)
{
#ifdef HAVE_STRUCT_STAT_ST_RDEV
    return DEVT2NUM(get_stat(self)-&gt;st_rdev);
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-rdev_major" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            rdev_major   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the major part of <code>File_Stat#rdev</code> or <code>nil</code>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/fd1&quot;</span>).<span class="ruby-identifier">rdev_major</span>   <span class="ruby-comment">#=&gt; 2</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/tty&quot;</span>).<span class="ruby-identifier">rdev_major</span>   <span class="ruby-comment">#=&gt; 5</span>
</pre>
          
          

          
          <div class="method-source-code" id="rdev_major-source">
            <pre>static VALUE
rb_stat_rdev_major(VALUE self)
{
#if defined(HAVE_STRUCT_STAT_ST_RDEV) &amp;&amp; defined(major)
    return UINT2NUM(major(get_stat(self)-&gt;st_rdev));
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-rdev_minor" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            rdev_minor   &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the minor part of <code>File_Stat#rdev</code> or <code>nil</code>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/fd1&quot;</span>).<span class="ruby-identifier">rdev_minor</span>   <span class="ruby-comment">#=&gt; 1</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/dev/tty&quot;</span>).<span class="ruby-identifier">rdev_minor</span>   <span class="ruby-comment">#=&gt; 0</span>
</pre>
          
          

          
          <div class="method-source-code" id="rdev_minor-source">
            <pre>static VALUE
rb_stat_rdev_minor(VALUE self)
{
#if defined(HAVE_STRUCT_STAT_ST_RDEV) &amp;&amp; defined(minor)
    return UINT2NUM(minor(get_stat(self)-&gt;st_rdev));
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-readable-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            readable?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is readable by the effective user id of this process.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">readable?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="readable-3F-source">
            <pre>static VALUE
rb_stat_r(VALUE obj)
{
    struct stat *st = get_stat(obj);

#ifdef USE_GETEUID
    if (geteuid() == 0) return Qtrue;
#endif
#ifdef S_IRUSR
    if (rb_stat_owned(obj))
        return st-&gt;st_mode &amp; S_IRUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
    if (rb_stat_grpowned(obj))
        return st-&gt;st_mode &amp; S_IRGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
    if (!(st-&gt;st_mode &amp; S_IROTH)) return Qfalse;
#endif
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-readable_real-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            readable_real?  &rarr;  true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is readable by the real user id of this process.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">readable_real?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="readable_real-3F-source">
            <pre>static VALUE
rb_stat_R(VALUE obj)
{
    struct stat *st = get_stat(obj);

#ifdef USE_GETEUID
    if (getuid() == 0) return Qtrue;
#endif
#ifdef S_IRUSR
    if (rb_stat_rowned(obj))
        return st-&gt;st_mode &amp; S_IRUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
    if (rb_group_member(get_stat(obj)-&gt;st_gid))
        return st-&gt;st_mode &amp; S_IRGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
    if (!(st-&gt;st_mode &amp; S_IROTH)) return Qfalse;
#endif
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-setgid-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            setgid?   &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> has the set-group-id permission bit set, <code>false</code> if it doesn&#39;t or if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/usr/sbin/lpc&quot;</span>).<span class="ruby-identifier">setgid?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="setgid-3F-source">
            <pre>static VALUE
rb_stat_sgid(VALUE obj)
{
#ifdef S_ISGID
    if (get_stat(obj)-&gt;st_mode &amp; S_ISGID) return Qtrue;
#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-setuid-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            setuid?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> has the set-user-id permission bit set, <code>false</code> if it doesn&#39;t or if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/bin/su&quot;</span>).<span class="ruby-identifier">setuid?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="setuid-3F-source">
            <pre>static VALUE
rb_stat_suid(VALUE obj)
{
#ifdef S_ISUID
    if (get_stat(obj)-&gt;st_mode &amp; S_ISUID) return Qtrue;
#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-size" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            size    &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the size of <em>stat</em> in bytes.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">size</span>   <span class="ruby-comment">#=&gt; 66</span>
</pre>
          
          

          
          <div class="method-source-code" id="size-source">
            <pre>static VALUE
rb_stat_size(VALUE self)
{
    return OFFT2NUM(get_stat(self)-&gt;st_size);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-size-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            size    &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the size of <em>stat</em> in bytes.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">size</span>   <span class="ruby-comment">#=&gt; 66</span>
</pre>
          
          

          
          <div class="method-source-code" id="size-3F-source">
            <pre>static VALUE
rb_stat_s(VALUE obj)
{
    off_t size = get_stat(obj)-&gt;st_size;

    if (size == 0) return Qnil;
    return OFFT2NUM(size);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-socket-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            socket?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is a socket, <code>false</code> if it isn&#39;t or if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">socket?</span>   <span class="ruby-comment">#=&gt; false</span>
</pre>
          
          

          
          <div class="method-source-code" id="socket-3F-source">
            <pre>static VALUE
rb_stat_S(VALUE obj)
{
#ifdef S_ISSOCK
    if (S_ISSOCK(get_stat(obj)-&gt;st_mode)) return Qtrue;

#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-sticky-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            sticky?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> has its sticky bit set, <code>false</code> if it doesn&#39;t or if the operating system doesn&#39;t support this feature.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">sticky?</span>   <span class="ruby-comment">#=&gt; false</span>
</pre>
          
          

          
          <div class="method-source-code" id="sticky-3F-source">
            <pre>static VALUE
rb_stat_sticky(VALUE obj)
{
#ifdef S_ISVTX
    if (get_stat(obj)-&gt;st_mode &amp; S_ISVTX) return Qtrue;
#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-symlink-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            symlink?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is a symbolic link, <code>false</code> if it isn&#39;t or if the operating system doesn&#39;t support this feature. As <a href="../File.html#method-c-stat"><code>File::stat</code></a> automatically follows symbolic links, <a href="Stat.html#method-i-symlink-3F"><code>symlink?</code></a> will always be <code>false</code> for an object returned by <a href="../File.html#method-c-stat"><code>File::stat</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink</span>(<span class="ruby-string">&quot;testfile&quot;</span>, <span class="ruby-string">&quot;alink&quot;</span>)   <span class="ruby-comment">#=&gt; 0</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;alink&quot;</span>).<span class="ruby-identifier">symlink?</span>         <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-string">&quot;alink&quot;</span>).<span class="ruby-identifier">symlink?</span>        <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="symlink-3F-source">
            <pre>static VALUE
rb_stat_l(VALUE obj)
{
#ifdef S_ISLNK
    if (S_ISLNK(get_stat(obj)-&gt;st_mode)) return Qtrue;
#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-uid" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            uid    &rarr; integer
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the numeric user id of the owner of <em>stat</em>.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">uid</span>   <span class="ruby-comment">#=&gt; 501</span>
</pre>
          
          

          
          <div class="method-source-code" id="uid-source">
            <pre>static VALUE
rb_stat_uid(VALUE self)
{
    return UIDT2NUM(get_stat(self)-&gt;st_uid);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-world_readable-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            world_readable? &rarr; integer or nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>If <em>stat</em> is readable by others, returns an integer representing the file permission bits of <em>stat</em>. Returns <code>nil</code> otherwise. The meaning of the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/etc/passwd&quot;</span>).<span class="ruby-identifier">world_readable?</span>  <span class="ruby-comment">#=&gt; 420</span>
<span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&quot;%o&quot;</span>, <span class="ruby-identifier">m</span>)                              <span class="ruby-comment">#=&gt; &quot;644&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="world_readable-3F-source">
            <pre>static VALUE
rb_stat_wr(VALUE obj)
{
#ifdef S_IROTH
    struct stat *st = get_stat(obj);
    if ((st-&gt;st_mode &amp; (S_IROTH)) == S_IROTH) {
        return UINT2NUM(st-&gt;st_mode &amp; (S_IRUGO|S_IWUGO|S_IXUGO));
    }
    else {
        return Qnil;
    }
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-world_writable-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            world_writable?  &rarr;  integer or nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>If <em>stat</em> is writable by others, returns an integer representing the file permission bits of <em>stat</em>. Returns <code>nil</code> otherwise. The meaning of the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;/tmp&quot;</span>).<span class="ruby-identifier">world_writable?</span>         <span class="ruby-comment">#=&gt; 511</span>
<span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&quot;%o&quot;</span>, <span class="ruby-identifier">m</span>)                              <span class="ruby-comment">#=&gt; &quot;777&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="world_writable-3F-source">
            <pre>static VALUE
rb_stat_ww(VALUE obj)
{
#ifdef S_IROTH
    struct stat *st = get_stat(obj);
    if ((st-&gt;st_mode &amp; (S_IWOTH)) == S_IWOTH) {
        return UINT2NUM(st-&gt;st_mode &amp; (S_IRUGO|S_IWUGO|S_IXUGO));
    }
    else {
        return Qnil;
    }
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-writable-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            writable?  &rarr;  true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is writable by the effective user id of this process.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">writable?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="writable-3F-source">
            <pre>static VALUE
rb_stat_w(VALUE obj)
{
    struct stat *st = get_stat(obj);

#ifdef USE_GETEUID
    if (geteuid() == 0) return Qtrue;
#endif
#ifdef S_IWUSR
    if (rb_stat_owned(obj))
        return st-&gt;st_mode &amp; S_IWUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IWGRP
    if (rb_stat_grpowned(obj))
        return st-&gt;st_mode &amp; S_IWGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IWOTH
    if (!(st-&gt;st_mode &amp; S_IWOTH)) return Qfalse;
#endif
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-writable_real-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            writable_real?  &rarr;  true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is writable by the real user id of this process.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">writable_real?</span>   <span class="ruby-comment">#=&gt; true</span>
</pre>
          
          

          
          <div class="method-source-code" id="writable_real-3F-source">
            <pre>static VALUE
rb_stat_W(VALUE obj)
{
    struct stat *st = get_stat(obj);

#ifdef USE_GETEUID
    if (getuid() == 0) return Qtrue;
#endif
#ifdef S_IWUSR
    if (rb_stat_rowned(obj))
        return st-&gt;st_mode &amp; S_IWUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IWGRP
    if (rb_group_member(get_stat(obj)-&gt;st_gid))
        return st-&gt;st_mode &amp; S_IWGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IWOTH
    if (!(st-&gt;st_mode &amp; S_IWOTH)) return Qfalse;
#endif
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-zero-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            zero?    &rarr; true or false
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns <code>true</code> if <em>stat</em> is a zero-length file; <code>false</code> otherwise.</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&quot;testfile&quot;</span>).<span class="ruby-identifier">zero?</span>   <span class="ruby-comment">#=&gt; false</span>
</pre>
          
          

          
          <div class="method-source-code" id="zero-3F-source">
            <pre>static VALUE
rb_stat_z(VALUE obj)
{
    if (get_stat(obj)-&gt;st_size == 0) return Qtrue;
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>

</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>