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/FileTest.html
<!DOCTYPE html>

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

<title>module FileTest - 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="module">
<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">
    
    
    
    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-i-blockdev-3F">#blockdev?</a>
    
    <li ><a href="#method-i-chardev-3F">#chardev?</a>
    
    <li ><a href="#method-i-directory-3F">#directory?</a>
    
    <li ><a href="#method-i-empty-3F">#empty?</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-exist-3F">#exist?</a>
    
    <li ><a href="#method-i-exists-3F">#exists?</a>
    
    <li ><a href="#method-i-file-3F">#file?</a>
    
    <li ><a href="#method-i-grpowned-3F">#grpowned?</a>
    
    <li ><a href="#method-i-identical-3F">#identical?</a>
    
    <li ><a href="#method-i-owned-3F">#owned?</a>
    
    <li ><a href="#method-i-pipe-3F">#pipe?</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-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="module-FileTest">
  <h1 id="module-FileTest" class="module">
    module FileTest
  </h1>

  <section class="description">
    
<p><a href="FileTest.html"><code>FileTest</code></a> implements file test operations similar to those used in <a href="File/Stat.html"><code>File::Stat</code></a>. It exists as a standalone module, and its methods are also insinuated into the <a href="File.html"><code>File</code></a> class. (Note that this is not done by inclusion: the interpreter cheats).</p>

  </section>

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

    

    

    

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

    
      <div id="method-i-blockdev-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            blockdev?(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 block device.</p>

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

          
          <div class="method-source-code" id="blockdev-3F-source">
            <pre>static VALUE
rb_file_blockdev_p(VALUE obj, VALUE fname)
{
#ifndef S_ISBLK
#   ifdef S_IFBLK
#       define S_ISBLK(m) (((m) &amp; S_IFMT) == S_IFBLK)
#   else
#       define S_ISBLK(m) (0)  /* anytime false */
#   endif
#endif

#ifdef S_ISBLK
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (S_ISBLK(st.st_mode)) return Qtrue;

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

        

        
      </div>

    
      <div id="method-i-chardev-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            chardev?(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 character device.</p>

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

          
          <div class="method-source-code" id="chardev-3F-source">
            <pre>static VALUE
rb_file_chardev_p(VALUE obj, VALUE fname)
{
#ifndef S_ISCHR
#   define S_ISCHR(m) (((m) &amp; S_IFMT) == S_IFCHR)
#endif

    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (S_ISCHR(st.st_mode)) return Qtrue;

    return Qfalse;
}</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>VALUE
rb_file_directory_p(VALUE obj, VALUE fname)
{
#ifndef S_ISDIR
#   define S_ISDIR(m) (((m) &amp; S_IFMT) == S_IFDIR)
#endif

    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (S_ISDIR(st.st_mode)) return Qtrue;
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-empty-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            zero?(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 exists and has a zero size.</p>

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

          
          <div class="method-source-code" id="empty-3F-source">
            <pre>static VALUE
rb_file_zero_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (st.st_size == 0) 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?(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 executable by the effective user and group id of this process. See eaccess(3).</p>

<p>Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe.</p>

<p>Note that some OS-level security features may cause this to return true even though the file is not executable by the effective user/group.</p>
          
          

          
          <div class="method-source-code" id="executable-3F-source">
            <pre>static VALUE
rb_file_executable_p(VALUE obj, VALUE fname)
{
    if (rb_eaccess(fname, X_OK) &lt; 0) return Qfalse;
    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?(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 executable by the real user and group id of this process. See access(3).</p>

<p>Windows does not support execute permissions separately from read permissions. On Windows, a file is only considered executable if it ends in .bat, .cmd, .com, or .exe.</p>

<p>Note that some OS-level security features may cause this to return true even though the file is not executable by the real user/group.</p>
          
          

          
          <div class="method-source-code" id="executable_real-3F-source">
            <pre>static VALUE
rb_file_executable_real_p(VALUE obj, VALUE fname)
{
    if (rb_access(fname, X_OK) &lt; 0) return Qfalse;
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Return <code>true</code> if the named file exists.</p>

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

<p>“file exists” means that stat() or fstat() system call is successful.</p>
          
          

          
          <div class="method-source-code" id="exist-3F-source">
            <pre>static VALUE
rb_file_exist_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Deprecated method. Don&#39;t use.</p>
          
          

          
          <div class="method-source-code" id="exists-3F-source">
            <pre>static VALUE
rb_file_exists_p(VALUE obj, VALUE fname)
{
    const char *s = &quot;FileTest#&quot;;
    if (obj == rb_mFileTest) {
        s = &quot;FileTest.&quot;;
    }
    else if (obj == rb_cFile ||
             (RB_TYPE_P(obj, T_CLASS) &amp;&amp;
              RTEST(rb_class_inherited_p(obj, rb_cFile)))) {
        s = &quot;File.&quot;;
    }
    rb_warning(&quot;%sexists? is a deprecated name, use %sexist? instead&quot;, s, s);
    return rb_file_exist_p(obj, fname);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-file-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            file?(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 the named <code>file</code> exists and is a regular file.</p>

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

<p>If the <code>file</code> argument is a symbolic link, it will resolve the symbolic link and use the file referenced by the link.</p>
          
          

          
          <div class="method-source-code" id="file-3F-source">
            <pre>static VALUE
rb_file_file_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (S_ISREG(st.st_mode)) return Qtrue;
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-grpowned-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            grpowned?(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 exists and the effective group id of the calling process is the owner of the file. Returns <code>false</code> on Windows.</p>

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

          
          <div class="method-source-code" id="grpowned-3F-source">
            <pre>static VALUE
rb_file_grpowned_p(VALUE obj, VALUE fname)
{
#ifndef _WIN32
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (rb_group_member(st.st_gid)) return Qtrue;
#endif
    return Qfalse;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-identical-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            identical?(file_1, file_2)   &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 files are identical.</p>

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

<pre class="ruby"><span class="ruby-identifier">open</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;w&quot;</span>) {}
<span class="ruby-identifier">p</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">identical?</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;a&quot;</span>)      <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">identical?</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;./a&quot;</span>)    <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">link</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;b&quot;</span>)
<span class="ruby-identifier">p</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">identical?</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;b&quot;</span>)      <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;c&quot;</span>)
<span class="ruby-identifier">p</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">identical?</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;c&quot;</span>)      <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-identifier">open</span>(<span class="ruby-string">&quot;d&quot;</span>, <span class="ruby-string">&quot;w&quot;</span>) {}
<span class="ruby-identifier">p</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">identical?</span>(<span class="ruby-string">&quot;a&quot;</span>, <span class="ruby-string">&quot;d&quot;</span>)      <span class="ruby-comment">#=&gt; false</span>
</pre>
          
          

          
          <div class="method-source-code" id="identical-3F-source">
            <pre>static VALUE
rb_file_identical_p(VALUE obj, VALUE fname1, VALUE fname2)
{
#ifndef _WIN32
    struct stat st1, st2;

    if (rb_stat(fname1, &amp;st1) &lt; 0) return Qfalse;
    if (rb_stat(fname2, &amp;st2) &lt; 0) return Qfalse;
    if (st1.st_dev != st2.st_dev) return Qfalse;
    if (st1.st_ino != st2.st_ino) return Qfalse;
    return Qtrue;
#else
    extern VALUE rb_w32_file_identical_p(VALUE, VALUE);
    return rb_w32_file_identical_p(fname1, fname2);
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-owned-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            owned?(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 exists and the effective used id of the calling process is the owner of the file.</p>

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

          
          <div class="method-source-code" id="owned-3F-source">
            <pre>static VALUE
rb_file_owned_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (st.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?(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 pipe.</p>

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

          
          <div class="method-source-code" id="pipe-3F-source">
            <pre>static VALUE
rb_file_pipe_p(VALUE obj, VALUE fname)
{
#ifdef S_IFIFO
#  ifndef S_ISFIFO
#    define S_ISFIFO(m) (((m) &amp; S_IFMT) == S_IFIFO)
#  endif

    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (S_ISFIFO(st.st_mode)) return Qtrue;

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

        

        
      </div>

    
      <div id="method-i-readable-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            readable?(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 readable by the effective user and group id of this process. See eaccess(3).</p>

<p>Note that some OS-level security features may cause this to return true even though the file is not readable by the effective user/group.</p>
          
          

          
          <div class="method-source-code" id="readable-3F-source">
            <pre>static VALUE
rb_file_readable_p(VALUE obj, VALUE fname)
{
    if (rb_eaccess(fname, R_OK) &lt; 0) return Qfalse;
    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?(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 readable by the real user and group id of this process. See access(3).</p>

<p>Note that some OS-level security features may cause this to return true even though the file is not readable by the real user/group.</p>
          
          

          
          <div class="method-source-code" id="readable_real-3F-source">
            <pre>static VALUE
rb_file_readable_real_p(VALUE obj, VALUE fname)
{
    if (rb_access(fname, R_OK) &lt; 0) return Qfalse;
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-setgid-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            setgid?(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 has the setgid bit set.</p>

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

          
          <div class="method-source-code" id="setgid-3F-source">
            <pre>static VALUE
rb_file_sgid_p(VALUE obj, VALUE fname)
{
#ifdef S_ISGID
    return check3rdbyte(fname, S_ISGID);
#else
    return Qfalse;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-setuid-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            setuid?(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 has the setuid bit set.</p>

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

          
          <div class="method-source-code" id="setuid-3F-source">
            <pre>static VALUE
rb_file_suid_p(VALUE obj, VALUE fname)
{
#ifdef S_ISUID
    return check3rdbyte(fname, S_ISUID);
#else
    return Qfalse;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the size of <code>file_name</code>.</p>

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

          
          <div class="method-source-code" id="size-source">
            <pre>static VALUE
rb_file_s_size(VALUE klass, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) {
        int e = errno;
        FilePathValue(fname);
        rb_syserr_fail_path(e, fname);
    }
    return OFFT2NUM(st.st_size);
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns <code>nil</code> if <code>file_name</code> doesn&#39;t exist or has zero size, the size of the file otherwise.</p>

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

          
          <div class="method-source-code" id="size-3F-source">
            <pre>static VALUE
rb_file_size_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qnil;
    if (st.st_size == 0) return Qnil;
    return OFFT2NUM(st.st_size);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-socket-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            socket?(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 socket.</p>

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

          
          <div class="method-source-code" id="socket-3F-source">
            <pre>static VALUE
rb_file_socket_p(VALUE obj, VALUE fname)
{
#ifndef S_ISSOCK
#  ifdef _S_ISSOCK
#    define S_ISSOCK(m) _S_ISSOCK(m)
#  else
#    ifdef _S_IFSOCK
#      define S_ISSOCK(m) (((m) &amp; S_IFMT) == _S_IFSOCK)
#    else
#      ifdef S_IFSOCK
#        define S_ISSOCK(m) (((m) &amp; S_IFMT) == S_IFSOCK)
#      endif
#    endif
#  endif
#endif

#ifdef S_ISSOCK
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (S_ISSOCK(st.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?(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 has the sticky bit set.</p>

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

          
          <div class="method-source-code" id="sticky-3F-source">
            <pre>static VALUE
rb_file_sticky_p(VALUE obj, VALUE fname)
{
#ifdef S_ISVTX
    return check3rdbyte(fname, S_ISVTX);
#else
    return Qnil;
#endif
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-symlink-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            symlink?(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 symbolic link.</p>
          
          

          
          <div class="method-source-code" id="symlink-3F-source">
            <pre>static VALUE
rb_file_symlink_p(VALUE obj, VALUE fname)
{
#ifndef S_ISLNK
#  ifdef _S_ISLNK
#    define S_ISLNK(m) _S_ISLNK(m)
#  else
#    ifdef _S_IFLNK
#      define S_ISLNK(m) (((m) &amp; S_IFMT) == _S_IFLNK)
#    else
#      ifdef S_IFLNK
#        define S_ISLNK(m) (((m) &amp; S_IFMT) == S_IFLNK)
#      endif
#    endif
#  endif
#endif

#ifdef S_ISLNK
    struct stat st;

    FilePathValue(fname);
    fname = rb_str_encode_ospath(fname);
    if (lstat_without_gvl(StringValueCStr(fname), &amp;st) &lt; 0) return Qfalse;
    if (S_ISLNK(st.st_mode)) return Qtrue;
#endif

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

        

        
      </div>

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

        <div class="method-description">
          
          <p>If <em>file_name</em> is readable by others, returns an integer representing the file permission bits of <em>file_name</em>. Returns <code>nil</code> otherwise. The meaning of the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.</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">world_readable?</span>(<span class="ruby-string">&quot;/etc/passwd&quot;</span>)           <span class="ruby-comment">#=&gt; 420</span>
<span class="ruby-identifier">m</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">world_readable?</span>(<span class="ruby-string">&quot;/etc/passwd&quot;</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_file_world_readable_p(VALUE obj, VALUE fname)
{
#ifdef S_IROTH
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qnil;
    if ((st.st_mode &amp; (S_IROTH)) == S_IROTH) {
        return UINT2NUM(st.st_mode &amp; (S_IRUGO|S_IWUGO|S_IXUGO));
    }
#endif
    return Qnil;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>If <em>file_name</em> is writable by others, returns an integer representing the file permission bits of <em>file_name</em>. Returns <code>nil</code> otherwise. The meaning of the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.</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">world_writable?</span>(<span class="ruby-string">&quot;/tmp&quot;</span>)                  <span class="ruby-comment">#=&gt; 511</span>
<span class="ruby-identifier">m</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">world_writable?</span>(<span class="ruby-string">&quot;/tmp&quot;</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_file_world_writable_p(VALUE obj, VALUE fname)
{
#ifdef S_IWOTH
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qnil;
    if ((st.st_mode &amp; (S_IWOTH)) == S_IWOTH) {
        return UINT2NUM(st.st_mode &amp; (S_IRUGO|S_IWUGO|S_IXUGO));
    }
#endif
    return Qnil;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-writable-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            writable?(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 writable by the effective user and group id of this process. See eaccess(3).</p>

<p>Note that some OS-level security features may cause this to return true even though the file is not writable by the effective user/group.</p>
          
          

          
          <div class="method-source-code" id="writable-3F-source">
            <pre>static VALUE
rb_file_writable_p(VALUE obj, VALUE fname)
{
    if (rb_eaccess(fname, W_OK) &lt; 0) return Qfalse;
    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?(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 writable by the real user and group id of this process. See access(3).</p>

<p>Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group.</p>
          
          

          
          <div class="method-source-code" id="writable_real-3F-source">
            <pre>static VALUE
rb_file_writable_real_p(VALUE obj, VALUE fname)
{
    if (rb_access(fname, W_OK) &lt; 0) return Qfalse;
    return Qtrue;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-zero-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            zero?(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 exists and has a zero size.</p>

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

          
          <div class="method-source-code" id="zero-3F-source">
            <pre>static VALUE
rb_file_zero_p(VALUE obj, VALUE fname)
{
    struct stat st;

    if (rb_stat(fname, &amp;st) &lt; 0) return Qfalse;
    if (st.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>