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

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

<title>class Dir - 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="Enumerable.html">Enumerable</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-5B-5D">::[]</a>
    
    <li ><a href="#method-c-chdir">::chdir</a>
    
    <li ><a href="#method-c-children">::children</a>
    
    <li ><a href="#method-c-chroot">::chroot</a>
    
    <li ><a href="#method-c-delete">::delete</a>
    
    <li ><a href="#method-c-each_child">::each_child</a>
    
    <li ><a href="#method-c-empty-3F">::empty?</a>
    
    <li ><a href="#method-c-entries">::entries</a>
    
    <li ><a href="#method-c-exist-3F">::exist?</a>
    
    <li ><a href="#method-c-exists-3F">::exists?</a>
    
    <li ><a href="#method-c-foreach">::foreach</a>
    
    <li ><a href="#method-c-getwd">::getwd</a>
    
    <li ><a href="#method-c-glob">::glob</a>
    
    <li ><a href="#method-c-home">::home</a>
    
    <li ><a href="#method-c-mkdir">::mkdir</a>
    
    <li ><a href="#method-c-mktmpdir">::mktmpdir</a>
    
    <li ><a href="#method-c-new">::new</a>
    
    <li ><a href="#method-c-open">::open</a>
    
    <li ><a href="#method-c-pwd">::pwd</a>
    
    <li ><a href="#method-c-rmdir">::rmdir</a>
    
    <li ><a href="#method-c-tmpdir">::tmpdir</a>
    
    <li ><a href="#method-c-unlink">::unlink</a>
    
    <li ><a href="#method-i-children">#children</a>
    
    <li ><a href="#method-i-close">#close</a>
    
    <li ><a href="#method-i-each">#each</a>
    
    <li ><a href="#method-i-each_child">#each_child</a>
    
    <li ><a href="#method-i-fileno">#fileno</a>
    
    <li ><a href="#method-i-inspect">#inspect</a>
    
    <li ><a href="#method-i-path">#path</a>
    
    <li ><a href="#method-i-pos">#pos</a>
    
    <li ><a href="#method-i-pos-3D">#pos=</a>
    
    <li ><a href="#method-i-read">#read</a>
    
    <li ><a href="#method-i-rewind">#rewind</a>
    
    <li ><a href="#method-i-seek">#seek</a>
    
    <li ><a href="#method-i-tell">#tell</a>
    
    <li ><a href="#method-i-to_path">#to_path</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-Dir">
  <h1 id="class-Dir" class="class">
    class Dir
  </h1>

  <section class="description">
    
<p>Objects of class <a href="Dir.html"><code>Dir</code></a> are directory streams representing directories in the underlying file system. They provide a variety of ways to list directories and their contents. See also <a href="File.html"><code>File</code></a>.</p>

<p>The directory used in these examples contains the two regular files (<code>config.h</code> and <code>main.rb</code>), the parent directory (<code>..</code>), and the directory itself (<code>.</code>).</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-5B-5D" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            Dir[ string [, string ...] [, base: path] ] &rarr; array
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Equivalent to calling <code>Dir.glob([string,...], 0)</code>.</p>
          
          

          
          <div class="method-source-code" id="5B-5D-source">
            <pre>static VALUE
dir_s_aref(int argc, VALUE *argv, VALUE obj)
{
    VALUE opts, base;
    argc = rb_scan_args(argc, argv, &quot;*:&quot;, NULL, &amp;opts);
    dir_glob_options(opts, &amp;base, NULL);
    if (argc == 1) {
        return rb_push_glob(argv[0], base, 0);
    }
    return dir_globs(argc, argv, base, 0);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-chdir" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            chdir( [ string] ) &rarr; 0
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            chdir( [ string] ) {| path | block }  &rarr; anObject
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Changes the current working directory of the process to the given string. When called without an argument, changes the directory to the value of the environment variable <code>HOME</code>, or <code>LOGDIR</code>. <a href="SystemCallError.html"><code>SystemCallError</code></a> (probably Errno::ENOENT) if the target directory does not exist.</p>

<p>If a block is given, it is passed the name of the new current directory, and the block is executed with that as the current directory. The original working directory is restored when the block exits. The return value of <code>chdir</code> is the value of the block. <code>chdir</code> blocks can be nested, but in a multi-threaded program an error will be raised if a thread attempts to open a <code>chdir</code> block while another thread has one open.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-string">&quot;/var/spool/mail&quot;</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-string">&quot;/tmp&quot;</span>) <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-string">&quot;/usr&quot;</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">puts</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
</pre>

<p><em>produces:</em></p>

<pre>/var/spool/mail
/tmp
/usr
/tmp
/var/spool/mail</pre>
          
          

          
          <div class="method-source-code" id="chdir-source">
            <pre>static VALUE
dir_s_chdir(int argc, VALUE *argv, VALUE obj)
{
    VALUE path = Qnil;

    if (rb_check_arity(argc, 0, 1) == 1) {
        path = rb_str_encode_ospath(rb_get_path(argv[0]));
    }
    else {
        const char *dist = getenv(&quot;HOME&quot;);
        if (!dist) {
            dist = getenv(&quot;LOGDIR&quot;);
            if (!dist) rb_raise(rb_eArgError, &quot;HOME/LOGDIR not set&quot;);
        }
        path = rb_str_new2(dist);
    }

    if (chdir_blocking &gt; 0) {
        if (!rb_block_given_p() || rb_thread_current() != chdir_thread)
            rb_warn(&quot;conflicting chdir during another chdir block&quot;);
    }

    if (rb_block_given_p()) {
        struct chdir_data args;

        args.old_path = rb_str_encode_ospath(rb_dir_getwd());
        args.new_path = path;
        args.done = FALSE;
        return rb_ensure(chdir_yield, (VALUE)&amp;args, chdir_restore, (VALUE)&amp;args);
    }
    else {
        char *p = RSTRING_PTR(path);
        int r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p,
                                                        RUBY_UBF_IO, 0);
        if (r &lt; 0)
            rb_sys_fail_path(path);
    }

    return INT2FIX(0);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-children" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            children( dirname )                &rarr; array
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            children( dirname, encoding: enc ) &rarr; array
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns an array containing all of the filenames except for “.” and “..” in the given directory. Will raise a <a href="SystemCallError.html"><code>SystemCallError</code></a> if the named directory doesn&#39;t exist.</p>

<p>The optional <em>encoding</em> keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&quot;testdir&quot;</span>)   <span class="ruby-comment">#=&gt; [&quot;config.h&quot;, &quot;main.rb&quot;]</span>
</pre>
          
          

          
          <div class="method-source-code" id="children-source">
            <pre>static VALUE
dir_s_children(int argc, VALUE *argv, VALUE io)
{
    VALUE dir;

    dir = dir_open_dir(argc, argv);
    return rb_ensure(dir_collect_children, dir, dir_close, dir);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-chroot" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            chroot( string ) &rarr; 0
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Changes this process&#39;s idea of the file system root. Only a privileged process may make this call. Not available on all platforms. On Unix systems, see <code>chroot(2)</code> for more information.</p>
          
          

          
          <div class="method-source-code" id="chroot-source">
            <pre>static VALUE
dir_s_chroot(VALUE dir, VALUE path)
{
    path = check_dirname(path);
    if (chroot(RSTRING_PTR(path)) == -1)
        rb_sys_fail_path(path);

    return INT2FIX(0);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-delete" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            delete( string ) &rarr; 0
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Deletes the named directory. Raises a subclass of <a href="SystemCallError.html"><code>SystemCallError</code></a> if the directory isn&#39;t empty.</p>
          
          

          
          <div class="method-source-code" id="delete-source">
            <pre>static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
{
    const char *p;
    int r;

    dir = check_dirname(dir);
    p = RSTRING_PTR(dir);
    r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_rmdir, (void *)p, RUBY_UBF_IO, 0);
    if (r &lt; 0)
        rb_sys_fail_path(dir);

    return INT2FIX(0);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-each_child" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            each_child( dirname ) {| filename | block }                 &rarr; nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            each_child( dirname, encoding: enc ) {| filename | block }  &rarr; nil
          </span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            each_child( dirname )                                       &rarr; an_enumerator
          </span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            each_child( dirname, encoding: enc )                        &rarr; an_enumerator
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Calls the block once for each entry except for “.” and “..” in the named directory, passing the filename of each entry as a parameter to the block.</p>

<p>If no block is given, an enumerator is returned instead.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">each_child</span>(<span class="ruby-string">&quot;testdir&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Got #{x}&quot;</span> }
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Got</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">h</span>
<span class="ruby-constant">Got</span> <span class="ruby-identifier">main</span>.<span class="ruby-identifier">rb</span>
</pre>
          
          

          
          <div class="method-source-code" id="each_child-source">
            <pre>static VALUE
dir_s_each_child(int argc, VALUE *argv, VALUE io)
{
    VALUE dir;

    RETURN_ENUMERATOR(io, argc, argv);
    dir = dir_open_dir(argc, argv);
    rb_ensure(dir_each_child, dir, dir_close, dir);
    return Qnil;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-empty-3F" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            empty?(path_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 an empty directory, <code>false</code> if it is not a directory or non-empty.</p>
          
          

          
          <div class="method-source-code" id="empty-3F-source">
            <pre>static VALUE
rb_dir_s_empty_p(VALUE obj, VALUE dirname)
{
    VALUE result, orig;
    const char *path;
    enum {false_on_notdir = 1};

    FilePathValue(dirname);
    orig = rb_str_dup_frozen(dirname);
    dirname = rb_str_encode_ospath(dirname);
    dirname = rb_str_dup_frozen(dirname);
    path = RSTRING_PTR(dirname);

#if defined HAVE_GETATTRLIST &amp;&amp; defined ATTR_DIR_ENTRYCOUNT
    {
        u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)];
        struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,};
        if (getattrlist(path, &amp;al, attrbuf, sizeof(attrbuf), 0) != 0)
            rb_sys_fail_path(orig);
        if (*(const fsobj_tag_t *)(attrbuf+1) == VT_HFS) {
            al.commonattr = 0;
            al.dirattr = ATTR_DIR_ENTRYCOUNT;
            if (getattrlist(path, &amp;al, attrbuf, sizeof(attrbuf), 0) == 0) {
                if (attrbuf[0] &gt;= 2 * sizeof(u_int32_t))
                    return attrbuf[1] ? Qfalse : Qtrue;
                if (false_on_notdir) return Qfalse;
            }
            rb_sys_fail_path(orig);
        }
    }
#endif

    result = (VALUE)rb_thread_call_without_gvl(nogvl_dir_empty_p, (void *)path,
                                            RUBY_UBF_IO, 0);
    if (result == Qundef) {
        rb_sys_fail_path(orig);
    }
    return result;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-entries" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            entries( dirname )                &rarr; array
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            entries( dirname, encoding: enc ) &rarr; array
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns an array containing all of the filenames in the given directory. Will raise a <a href="SystemCallError.html"><code>SystemCallError</code></a> if the named directory doesn&#39;t exist.</p>

<p>The optional <em>encoding</em> keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-string">&quot;testdir&quot;</span>)   <span class="ruby-comment">#=&gt; [&quot;.&quot;, &quot;..&quot;, &quot;config.h&quot;, &quot;main.rb&quot;]</span>
</pre>
          
          

          
          <div class="method-source-code" id="entries-source">
            <pre>static VALUE
dir_entries(int argc, VALUE *argv, VALUE io)
{
    VALUE dir;

    dir = dir_open_dir(argc, argv);
    return rb_ensure(dir_collect, dir, dir_close, dir);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-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>Returns <code>true</code> if the named file is a directory, <code>false</code> otherwise.</p>
          
          

          
          <div class="method-source-code" id="exist-3F-source">
            <pre>VALUE
rb_file_directory_p(void)
{
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-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_dir_exists_p(VALUE obj, VALUE fname)
{
    rb_warning(&quot;Dir.exists? is a deprecated name, use Dir.exist? instead&quot;);
    return rb_file_directory_p(obj, fname);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-foreach" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            foreach( dirname ) {| filename | block }                 &rarr; nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            foreach( dirname, encoding: enc ) {| filename | block }  &rarr; nil
          </span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            foreach( dirname )                                       &rarr; an_enumerator
          </span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            foreach( dirname, encoding: enc )                        &rarr; an_enumerator
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Calls the block once for each entry in the named directory, passing the filename of each entry as a parameter to the block.</p>

<p>If no block is given, an enumerator is returned instead.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">foreach</span>(<span class="ruby-string">&quot;testdir&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Got #{x}&quot;</span> }
</pre>

<p><em>produces:</em></p>

<pre>Got .
Got ..
Got config.h
Got main.rb</pre>
          
          

          
          <div class="method-source-code" id="foreach-source">
            <pre>static VALUE
dir_foreach(int argc, VALUE *argv, VALUE io)
{
    VALUE dir;

    RETURN_ENUMERATOR(io, argc, argv);
    dir = dir_open_dir(argc, argv);
    rb_ensure(dir_each, dir, dir_close, dir);
    return Qnil;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the path to the current working directory of this process as a string.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-string">&quot;/tmp&quot;</span>)   <span class="ruby-comment">#=&gt; 0</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">getwd</span>           <span class="ruby-comment">#=&gt; &quot;/tmp&quot;</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>             <span class="ruby-comment">#=&gt; &quot;/tmp&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="getwd-source">
            <pre>static VALUE
dir_s_getwd(VALUE dir)
{
    return rb_dir_getwd();
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-glob" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            glob( pattern, [flags], [base: path] )                       &rarr; array
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            glob( pattern, [flags], [base: path] ) { |filename| block }  &rarr; nil
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Expands <code>pattern</code>, which is a pattern string or an <a href="Array.html"><code>Array</code></a> of pattern strings, and returns an array containing the matching filenames. If a block is given, calls the block once for each matching filename, passing the filename as a parameter to the block.</p>

<p>The optional <code>base</code> keyword argument specifies the base directory for interpreting relative pathnames instead of the current working directory. As the results are not prefixed with the base directory name in this case, you will need to prepend the base directory name if you want real paths.</p>

<p>Note that the pattern is not a regexp, it&#39;s closer to a shell glob. See <a href="File.html#method-c-fnmatch"><code>File::fnmatch</code></a> for the meaning of the <code>flags</code> parameter. Case sensitivity depends on your system (File::FNM_CASEFOLD is ignored), as does the order in which the results are returned.</p>
<dl class="rdoc-list note-list"><dt><code>*</code>
<dd>
<p>Matches any file. Can be restricted by other values in the glob. Equivalent to <code>/ .* /mx</code> in regexp.</p>
<dl class="rdoc-list note-list"><dt><code>*</code>
<dd>
<p>Matches all files</p>
</dd><dt><code>c*</code>
<dd>
<p>Matches all files beginning with <code>c</code></p>
</dd><dt><code>*c</code>
<dd>
<p>Matches all files ending with <code>c</code></p>
</dd><dt><code>*c*</code>
<dd>
<p>Match all files that have <code>c</code> in them (including at the beginning or end).</p>
</dd></dl>

<p>Note, this will not match Unix-like hidden files (dotfiles).  In order to include those in the match results, you must use the File::FNM_DOTMATCH flag or something like <code>&quot;{*,.*}&quot;</code>.</p>
</dd><dt><code>**</code>
<dd>
<p>Matches directories recursively.</p>
</dd><dt><code>?</code>
<dd>
<p>Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.</p>
</dd><dt><code>[set]</code>
<dd>
<p>Matches any one character in <code>set</code>.  Behaves exactly like character sets in <a href="Regexp.html"><code>Regexp</code></a>, including set negation (<code>[^a-z]</code>).</p>
</dd><dt><code>{p,q}</code>
<dd>
<p>Matches either literal <code>p</code> or literal <code>q</code>. Equivalent to pattern alternation in regexp.</p>

<p>Matching literals may be more than one character in length.  More than two literals may be specified.</p>
</dd><dt><code> \ </code>
<dd>
<p>Escapes the next metacharacter.</p>

<p>Note that this means you cannot use backslash on windows as part of a glob, i.e.  <code>Dir["c:\foo*"]</code> will not work, use <code>Dir["c:/foo*"]</code> instead.</p>
</dd></dl>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>[<span class="ruby-string">&quot;config.?&quot;</span>]                     <span class="ruby-comment">#=&gt; [&quot;config.h&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-string">&quot;config.?&quot;</span>)                <span class="ruby-comment">#=&gt; [&quot;config.h&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-string">&quot;*.[a-z][a-z]&quot;</span>)            <span class="ruby-comment">#=&gt; [&quot;main.rb&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-string">&quot;*.[^r]*&quot;</span>)                 <span class="ruby-comment">#=&gt; [&quot;config.h&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-string">&quot;*.{rb,h}&quot;</span>)                <span class="ruby-comment">#=&gt; [&quot;main.rb&quot;, &quot;config.h&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-string">&quot;*&quot;</span>)                       <span class="ruby-comment">#=&gt; [&quot;config.h&quot;, &quot;main.rb&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-string">&quot;*&quot;</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">FNM_DOTMATCH</span>)   <span class="ruby-comment">#=&gt; [&quot;.&quot;, &quot;..&quot;, &quot;config.h&quot;, &quot;main.rb&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>([<span class="ruby-string">&quot;*.rb&quot;</span>, <span class="ruby-string">&quot;*.h&quot;</span>])           <span class="ruby-comment">#=&gt; [&quot;main.rb&quot;, &quot;config.h&quot;]</span>

<span class="ruby-identifier">rbfiles</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;**&quot;</span>, <span class="ruby-string">&quot;*.rb&quot;</span>)
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">rbfiles</span>)                   <span class="ruby-comment">#=&gt; [&quot;main.rb&quot;,</span>
                                    <span class="ruby-comment">#    &quot;lib/song.rb&quot;,</span>
                                    <span class="ruby-comment">#    &quot;lib/song/karaoke.rb&quot;]</span>

<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">rbfiles</span>, <span class="ruby-value">base:</span> <span class="ruby-string">&quot;lib&quot;</span>)      <span class="ruby-comment">#=&gt; [&quot;song.rb&quot;,</span>
                                    <span class="ruby-comment">#    &quot;song/karaoke.rb&quot;]</span>

<span class="ruby-identifier">libdirs</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;**&quot;</span>, <span class="ruby-string">&quot;lib&quot;</span>)
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">libdirs</span>)                   <span class="ruby-comment">#=&gt; [&quot;lib&quot;]</span>

<span class="ruby-identifier">librbfiles</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;**&quot;</span>, <span class="ruby-string">&quot;lib&quot;</span>, <span class="ruby-string">&quot;**&quot;</span>, <span class="ruby-string">&quot;*.rb&quot;</span>)
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">librbfiles</span>)                <span class="ruby-comment">#=&gt; [&quot;lib/song.rb&quot;,</span>
                                    <span class="ruby-comment">#    &quot;lib/song/karaoke.rb&quot;]</span>

<span class="ruby-identifier">librbfiles</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;**&quot;</span>, <span class="ruby-string">&quot;lib&quot;</span>, <span class="ruby-string">&quot;*.rb&quot;</span>)
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">librbfiles</span>)                <span class="ruby-comment">#=&gt; [&quot;lib/song.rb&quot;]</span>
</pre>
          
          

          
          <div class="method-source-code" id="glob-source">
            <pre>static VALUE
dir_s_glob(int argc, VALUE *argv, VALUE obj)
{
    VALUE str, rflags, ary, opts, base;
    int flags;

    argc = rb_scan_args(argc, argv, &quot;11:&quot;, &amp;str, &amp;rflags, &amp;opts);
    if (argc == 2)
        flags = NUM2INT(rflags);
    else
        flags = 0;
    dir_glob_options(opts, &amp;base, &amp;flags);

    ary = rb_check_array_type(str);
    if (NIL_P(ary)) {
        ary = rb_push_glob(str, base, flags);
    }
    else {
        VALUE v = ary;
        ary = dir_globs(RARRAY_LEN(v), RARRAY_CONST_PTR(v), base, flags);
        RB_GC_GUARD(v);
    }

    if (rb_block_given_p()) {
        rb_ary_each(ary);
        return Qnil;
    }
    return ary;
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-home" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            home()       &rarr; &quot;/home/me&quot;
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            home(&quot;root&quot;) &rarr; &quot;/root&quot;
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns the home directory of the current user or the named user if given.</p>
          
          

          
          <div class="method-source-code" id="home-source">
            <pre>static VALUE
dir_s_home(int argc, VALUE *argv, VALUE obj)
{
    VALUE user;
    const char *u = 0;

    rb_check_arity(argc, 0, 1);
    user = (argc &gt; 0) ? argv[0] : Qnil;
    if (!NIL_P(user)) {
        SafeStringValue(user);
        rb_must_asciicompat(user);
        u = StringValueCStr(user);
        if (*u) {
            return rb_home_dir_of(user, rb_str_new(0, 0));
        }
    }
    return rb_default_home_dir(rb_str_new(0, 0));

}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-mkdir" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            mkdir( string [, integer] ) &rarr; 0
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Makes a new directory named by <em>string</em>, with permissions specified by the optional parameter <em>anInteger</em>. The permissions may be modified by the value of <a href="File.html#method-c-umask"><code>File::umask</code></a>, and are ignored on NT. Raises a <a href="SystemCallError.html"><code>SystemCallError</code></a> if the directory cannot be created. See also the discussion of permissions in the class documentation for <a href="File.html"><code>File</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">home</span>, <span class="ruby-string">&quot;.foo&quot;</span>), <span class="ruby-value">0700</span>) <span class="ruby-comment">#=&gt; 0</span>
</pre>
          
          

          
          <div class="method-source-code" id="mkdir-source">
            <pre>static VALUE
dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
{
    struct mkdir_arg m;
    VALUE path, vmode;
    int r;

    if (rb_scan_args(argc, argv, &quot;11&quot;, &amp;path, &amp;vmode) == 2) {
        m.mode = NUM2MODET(vmode);
    }
    else {
        m.mode = 0777;
    }

    path = check_dirname(path);
    m.path = RSTRING_PTR(path);
    r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_mkdir, &amp;m, RUBY_UBF_IO, 0);
    if (r &lt; 0)
        rb_sys_fail_path(path);

    return INT2FIX(0);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-mktmpdir" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">mktmpdir</span><span
            class="method-args">(prefix_suffix=nil, *rest, **options) { |dup| ... }</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p><a href="Dir.html#method-c-mktmpdir"><code>Dir.mktmpdir</code></a> creates a temporary directory.</p>

<p>The directory is created with 0700 permission. Application should not change the permission to make the temporary directory accessible from other users.</p>

<p>The prefix and suffix of the name of the directory is specified by the optional first argument, <em>prefix_suffix</em>.</p>
<ul><li>
<p>If it is not specified or nil, “d” is used as the prefix and no suffix is used.</p>
</li><li>
<p>If it is a string, it is used as the prefix and no suffix is used.</p>
</li><li>
<p>If it is an array, first element is used as the prefix and second element is used as a suffix.</p>
</li></ul>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mktmpdir</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dir</span> <span class="ruby-identifier">is</span> <span class="ruby-string">&quot;.../d...&quot;</span> }
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mktmpdir</span>(<span class="ruby-string">&quot;foo&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dir</span> <span class="ruby-identifier">is</span> <span class="ruby-string">&quot;.../foo...&quot;</span> }
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mktmpdir</span>([<span class="ruby-string">&quot;foo&quot;</span>, <span class="ruby-string">&quot;bar&quot;</span>]) {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dir</span> <span class="ruby-identifier">is</span> <span class="ruby-string">&quot;.../foo...bar&quot;</span> }
</pre>

<p>The directory is created under <a href="Dir.html#method-c-tmpdir"><code>Dir.tmpdir</code></a> or the optional second argument <em>tmpdir</em> if non-nil value is given.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mktmpdir</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dir</span> <span class="ruby-identifier">is</span> <span class="ruby-node">&quot;#{Dir.tmpdir}/d...&quot;</span> }
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mktmpdir</span>(<span class="ruby-keyword">nil</span>, <span class="ruby-string">&quot;/var/tmp&quot;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dir</span> <span class="ruby-identifier">is</span> <span class="ruby-string">&quot;/var/tmp/d...&quot;</span> }
</pre>

<p>If a block is given, it is yielded with the path of the directory. The directory and its contents are removed using <a href="FileUtils.html#method-c-remove_entry"><code>FileUtils.remove_entry</code></a> before <a href="Dir.html#method-c-mktmpdir"><code>Dir.mktmpdir</code></a> returns. The value of the block is returned.</p>

<pre>Dir.mktmpdir {|dir|
  # use the directory...
  open(&quot;#{dir}/foo&quot;, &quot;w&quot;) { ... }
}</pre>

<p>If a block is not given, The path of the directory is returned. In this case, <a href="Dir.html#method-c-mktmpdir"><code>Dir.mktmpdir</code></a> doesn&#39;t remove the directory.</p>

<pre>dir = Dir.mktmpdir
begin
  # use the directory...
  open(&quot;#{dir}/foo&quot;, &quot;w&quot;) { ... }
ensure
  # remove the directory.
  FileUtils.remove_entry dir
end</pre>
          
          

          
          <div class="method-source-code" id="mktmpdir-source">
            <pre><span class="ruby-comment"># File lib/tmpdir.rb, line 81</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">mktmpdir</span>(<span class="ruby-identifier">prefix_suffix</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">rest</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">base</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">path</span> = <span class="ruby-constant">Tmpname</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">prefix_suffix</span> <span class="ruby-operator">||</span> <span class="ruby-string">&quot;d&quot;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">rest</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">options</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">base</span> = <span class="ruby-identifier">d</span>
    <span class="ruby-identifier">mkdir</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value">0700</span>)
  }
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">base</span>
        <span class="ruby-identifier">stat</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">path</span>))
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">world_writable?</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">stat</span>.<span class="ruby-identifier">sticky?</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;parent directory is world writable but not sticky&quot;</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-new" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            new( string ) &rarr; aDir
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            new( string, encoding: enc ) &rarr; aDir
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns a new directory object for the named directory.</p>

<p>The optional <em>encoding</em> keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used.</p>
          
          

          
          <div class="method-source-code" id="new-source">
            <pre>static VALUE
dir_initialize(int argc, VALUE *argv, VALUE dir)
{
    struct dir_data *dp;
    rb_encoding  *fsenc;
    VALUE dirname, opt, orig;
    static ID keyword_ids[1];
    const char *path;

    if (!keyword_ids[0]) {
        keyword_ids[0] = rb_id_encoding();
    }

    fsenc = rb_filesystem_encoding();

    rb_scan_args(argc, argv, &quot;1:&quot;, &amp;dirname, &amp;opt);

    if (!NIL_P(opt)) {
        VALUE enc;
        rb_get_kwargs(opt, keyword_ids, 0, 1, &amp;enc);
        if (enc != Qundef &amp;&amp; !NIL_P(enc)) {
            fsenc = rb_to_encoding(enc);
        }
    }

    FilePathValue(dirname);
    orig = rb_str_dup_frozen(dirname);
    dirname = rb_str_encode_ospath(dirname);
    dirname = rb_str_dup_frozen(dirname);

    TypedData_Get_Struct(dir, struct dir_data, &amp;dir_data_type, dp);
    if (dp-&gt;dir) closedir(dp-&gt;dir);
    dp-&gt;dir = NULL;
    RB_OBJ_WRITE(dir, &amp;dp-&gt;path, Qnil);
    dp-&gt;enc = fsenc;
    path = RSTRING_PTR(dirname);
    dp-&gt;dir = opendir_without_gvl(path);
    if (dp-&gt;dir == NULL) {
        int e = errno;
        if (rb_gc_for_fd(e)) {
            dp-&gt;dir = opendir_without_gvl(path);
        }
#ifdef HAVE_GETATTRLIST
        else if (e == EIO) {
            u_int32_t attrbuf[1];
            struct attrlist al = {ATTR_BIT_MAP_COUNT, 0};
            if (getattrlist(path, &amp;al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW) == 0) {
                dp-&gt;dir = opendir_without_gvl(path);
            }
        }
#endif
        if (dp-&gt;dir == NULL) {
            RB_GC_GUARD(dirname);
            rb_syserr_fail_path(e, orig);
        }
    }
    RB_OBJ_WRITE(dir, &amp;dp-&gt;path, orig);

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

        

        
      </div>

    
      <div id="method-c-open" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            open( string ) &rarr; aDir
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            open( string, encoding: enc ) &rarr; aDir
          </span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            open( string ) {| aDir | block } &rarr; anObject
          </span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            open( string, encoding: enc ) {| aDir | block } &rarr; anObject
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>The optional <em>encoding</em> keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used.</p>

<p>With no block, <code>open</code> is a synonym for <a href="Dir.html#method-c-new"><code>Dir::new</code></a>. If a block is present, it is passed <em>aDir</em> as a parameter. The directory is closed at the end of the block, and <a href="Dir.html#method-c-open"><code>Dir::open</code></a> returns the value of the block.</p>
          
          

          
          <div class="method-source-code" id="open-source">
            <pre>static VALUE
dir_s_open(int argc, VALUE *argv, VALUE klass)
{
    struct dir_data *dp;
    VALUE dir = TypedData_Make_Struct(klass, struct dir_data, &amp;dir_data_type, dp);

    dir_initialize(argc, argv, dir);
    if (rb_block_given_p()) {
        return rb_ensure(rb_yield, dir, dir_close, dir);
    }

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

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the path to the current working directory of this process as a string.</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-string">&quot;/tmp&quot;</span>)   <span class="ruby-comment">#=&gt; 0</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">getwd</span>           <span class="ruby-comment">#=&gt; &quot;/tmp&quot;</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>             <span class="ruby-comment">#=&gt; &quot;/tmp&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="pwd-source">
            <pre>static VALUE
dir_s_getwd(VALUE dir)
{
    return rb_dir_getwd();
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-rmdir" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            rmdir( string ) &rarr; 0
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Deletes the named directory. Raises a subclass of <a href="SystemCallError.html"><code>SystemCallError</code></a> if the directory isn&#39;t empty.</p>
          
          

          
          <div class="method-source-code" id="rmdir-source">
            <pre>static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
{
    const char *p;
    int r;

    dir = check_dirname(dir);
    p = RSTRING_PTR(dir);
    r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_rmdir, (void *)p, RUBY_UBF_IO, 0);
    if (r &lt; 0)
        rb_sys_fail_path(dir);

    return INT2FIX(0);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-tmpdir" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">tmpdir</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Returns the operating system&#39;s temporary file path.</p>
          
          

          
          <div class="method-source-code" id="tmpdir-source">
            <pre><span class="ruby-comment"># File lib/tmpdir.rb, line 21</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">tmpdir</span>
  <span class="ruby-identifier">tmp</span> = <span class="ruby-keyword">nil</span>
  [<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;TMPDIR&#39;</span>], <span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;TMP&#39;</span>], <span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;TEMP&#39;</span>], <span class="ruby-identifier">@@systmpdir</span>, <span class="ruby-string">&#39;/tmp&#39;</span>, <span class="ruby-string">&#39;.&#39;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dir</span>
    <span class="ruby-identifier">dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">dir</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">stat</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">dir</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">writable?</span> <span class="ruby-keyword">and</span>
        (<span class="ruby-operator">!</span><span class="ruby-identifier">stat</span>.<span class="ruby-identifier">world_writable?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">sticky?</span>)
      <span class="ruby-identifier">tmp</span> = <span class="ruby-identifier">dir</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span> <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;could not find a temporary directory&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">tmp</span>
  <span class="ruby-identifier">tmp</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-c-unlink" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            unlink( string ) &rarr; 0
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Deletes the named directory. Raises a subclass of <a href="SystemCallError.html"><code>SystemCallError</code></a> if the directory isn&#39;t empty.</p>
          
          

          
          <div class="method-source-code" id="unlink-source">
            <pre>static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
{
    const char *p;
    int r;

    dir = check_dirname(dir);
    p = RSTRING_PTR(dir);
    r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_rmdir, (void *)p, RUBY_UBF_IO, 0);
    if (r &lt; 0)
        rb_sys_fail_path(dir);

    return INT2FIX(0);
}</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-children" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            children  &rarr; array
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Returns an array containing all of the filenames except for “.” and “..” in this directory.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">children</span>   <span class="ruby-comment">#=&gt; [&quot;config.h&quot;, &quot;main.rb&quot;]</span>
</pre>
          
          

          
          <div class="method-source-code" id="children-source">
            <pre>static VALUE
dir_collect_children(VALUE dir)
{
    VALUE ary = rb_ary_new();
    dir_each_entry(dir, rb_ary_push, ary, TRUE);
    return ary;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Closes the directory stream. Calling this method on closed <a href="Dir.html"><code>Dir</code></a> object is ignored since Ruby 2.3.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">close</span>   <span class="ruby-comment">#=&gt; nil</span>
</pre>
          
          

          
          <div class="method-source-code" id="close-source">
            <pre>static VALUE
dir_close(VALUE dir)
{
    struct dir_data *dirp;

    dirp = dir_get(dir);
    if (!dirp-&gt;dir) return Qnil;
    closedir(dirp-&gt;dir);
    dirp-&gt;dir = NULL;

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

        

        
      </div>

    
      <div id="method-i-each" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            each { |filename| block }  &rarr; dir
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            each                       &rarr; an_enumerator
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Calls the block once for each entry in this directory, passing the filename of each entry as a parameter to the block.</p>

<p>If no block is given, an enumerator is returned instead.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">each</span>  {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Got #{x}&quot;</span> }
</pre>

<p><em>produces:</em></p>

<pre>Got .
Got ..
Got config.h
Got main.rb</pre>
          
          

          
          <div class="method-source-code" id="each-source">
            <pre>static VALUE
dir_each(VALUE dir)
{
    RETURN_ENUMERATOR(dir, 0, 0);
    return dir_each_entry(dir, dir_yield, Qnil, FALSE);
}</pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-each_child" class="method-detail ">
        
        
        <div class="method-heading">
          <span class="method-callseq">
            each_child {| filename | block }  &rarr; nil
          </span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        
        <div class="method-heading">
          <span class="method-callseq">
            each_child                        &rarr; an_enumerator
          </span>
          
        </div>
        
        

        <div class="method-description">
          
          <p>Calls the block once for each entry except for “.” and “..” in this directory, passing the filename of each entry as a parameter to the block.</p>

<p>If no block is given, an enumerator is returned instead.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">each_child</span>  {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Got #{x}&quot;</span> }
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Got</span> <span class="ruby-identifier">config</span>.<span class="ruby-identifier">h</span>
<span class="ruby-constant">Got</span> <span class="ruby-identifier">main</span>.<span class="ruby-identifier">rb</span>
</pre>
          
          

          
          <div class="method-source-code" id="each_child-source">
            <pre>static VALUE
dir_each_child_m(VALUE dir)
{
    RETURN_ENUMERATOR(dir, 0, 0);
    return dir_each_entry(dir, dir_yield, Qnil, TRUE);
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the file descriptor used in <em>dir</em>.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;..&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">fileno</span>   <span class="ruby-comment">#=&gt; 8</span>
</pre>

<p>This method uses dirfd() function defined by POSIX 2008. <a href="NotImplementedError.html"><code>NotImplementedError</code></a> is raised on other platforms, such as Windows, which doesn&#39;t provide the function.</p>
          
          

          
          <div class="method-source-code" id="fileno-source">
            <pre>static VALUE
dir_fileno(VALUE dir)
{
    struct dir_data *dirp;
    int fd;

    GetDIR(dir, dirp);
    fd = dirfd(dirp-&gt;dir);
    if (fd == -1)
        rb_sys_fail(&quot;dirfd&quot;);
    return INT2NUM(fd);
}</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>Return a string describing this <a href="Dir.html"><code>Dir</code></a> object.</p>
          
          

          
          <div class="method-source-code" id="inspect-source">
            <pre>static VALUE
dir_inspect(VALUE dir)
{
    struct dir_data *dirp;

    TypedData_Get_Struct(dir, struct dir_data, &amp;dir_data_type, dirp);
    if (!NIL_P(dirp-&gt;path)) {
        VALUE str = rb_str_new_cstr(&quot;#&lt;&quot;);
        rb_str_append(str, rb_class_name(CLASS_OF(dir)));
        rb_str_cat2(str, &quot;:&quot;);
        rb_str_append(str, dirp-&gt;path);
        rb_str_cat2(str, &quot;&gt;&quot;);
        return str;
    }
    return rb_funcallv(dir, idTo_s, 0, 0);
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the path parameter passed to <em>dir</em>&#39;s constructor.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;..&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">path</span>   <span class="ruby-comment">#=&gt; &quot;..&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="path-source">
            <pre>static VALUE
dir_path(VALUE dir)
{
    struct dir_data *dirp;

    TypedData_Get_Struct(dir, struct dir_data, &amp;dir_data_type, dirp);
    if (NIL_P(dirp-&gt;path)) return Qnil;
    return rb_str_dup(dirp-&gt;path);
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the current position in <em>dir</em>. See also <a href="Dir.html#method-i-seek"><code>Dir#seek</code></a>.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">tell</span>   <span class="ruby-comment">#=&gt; 0</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>   <span class="ruby-comment">#=&gt; &quot;.&quot;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">tell</span>   <span class="ruby-comment">#=&gt; 12</span>
</pre>
          
          

          
          <div class="method-source-code" id="pos-source">
            <pre>static VALUE
dir_tell(VALUE dir)
{
    struct dir_data *dirp;
    long pos;

    GetDIR(dir, dirp);
    pos = telldir(dirp-&gt;dir);
    return rb_int2inum(pos);
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Synonym for <a href="Dir.html#method-i-seek"><code>Dir#seek</code></a>, but returns the position parameter.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)   <span class="ruby-comment">#=&gt; #&lt;Dir:0x401b3c40&gt;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>                   <span class="ruby-comment">#=&gt; &quot;.&quot;</span>
<span class="ruby-identifier">i</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">pos</span>                <span class="ruby-comment">#=&gt; 12</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>                   <span class="ruby-comment">#=&gt; &quot;..&quot;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">pos</span> = <span class="ruby-identifier">i</span>                <span class="ruby-comment">#=&gt; 12</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>                   <span class="ruby-comment">#=&gt; &quot;..&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="pos-3D-source">
            <pre>static VALUE
dir_set_pos(VALUE dir, VALUE pos)
{
    dir_seek(dir, pos);
    return pos;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Reads the next entry from <em>dir</em> and returns it as a string. Returns <code>nil</code> at the end of the stream.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>   <span class="ruby-comment">#=&gt; &quot;.&quot;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>   <span class="ruby-comment">#=&gt; &quot;..&quot;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>   <span class="ruby-comment">#=&gt; &quot;config.h&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="read-source">
            <pre>static VALUE
dir_read(VALUE dir)
{
    struct dir_data *dirp;
    struct dirent *dp;

    GetDIR(dir, dirp);
    errno = 0;
    if ((dp = READDIR(dirp-&gt;dir, dirp-&gt;enc)) != NULL) {
        return rb_external_str_new_with_enc(dp-&gt;d_name, NAMLEN(dp), dirp-&gt;enc);
    }
    else {
        int e = errno;
        if (e != 0) rb_syserr_fail(e, 0);
        return Qnil;           /* end of stream */
    }
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Repositions <em>dir</em> to the first entry.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>     <span class="ruby-comment">#=&gt; &quot;.&quot;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">rewind</span>   <span class="ruby-comment">#=&gt; #&lt;Dir:0x401b3fb0&gt;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>     <span class="ruby-comment">#=&gt; &quot;.&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="rewind-source">
            <pre>static VALUE
dir_rewind(VALUE dir)
{
    struct dir_data *dirp;

    GetDIR(dir, dirp);
    rewinddir(dirp-&gt;dir);
    return dir;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Seeks to a particular location in <em>dir</em>. <em>integer</em> must be a value returned by <a href="Dir.html#method-i-tell"><code>Dir#tell</code></a>.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)   <span class="ruby-comment">#=&gt; #&lt;Dir:0x401b3c40&gt;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>                   <span class="ruby-comment">#=&gt; &quot;.&quot;</span>
<span class="ruby-identifier">i</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">tell</span>               <span class="ruby-comment">#=&gt; 12</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>                   <span class="ruby-comment">#=&gt; &quot;..&quot;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">seek</span>(<span class="ruby-identifier">i</span>)                <span class="ruby-comment">#=&gt; #&lt;Dir:0x401b3c40&gt;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>                   <span class="ruby-comment">#=&gt; &quot;..&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="seek-source">
            <pre>static VALUE
dir_seek(VALUE dir, VALUE pos)
{
    struct dir_data *dirp;
    long p = NUM2LONG(pos);

    GetDIR(dir, dirp);
    seekdir(dirp-&gt;dir, p);
    return dir;
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the current position in <em>dir</em>. See also <a href="Dir.html#method-i-seek"><code>Dir#seek</code></a>.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;testdir&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">tell</span>   <span class="ruby-comment">#=&gt; 0</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">read</span>   <span class="ruby-comment">#=&gt; &quot;.&quot;</span>
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">tell</span>   <span class="ruby-comment">#=&gt; 12</span>
</pre>
          
          

          
          <div class="method-source-code" id="tell-source">
            <pre>static VALUE
dir_tell(VALUE dir)
{
    struct dir_data *dirp;
    long pos;

    GetDIR(dir, dirp);
    pos = telldir(dirp-&gt;dir);
    return rb_int2inum(pos);
}</pre>
          </div>
          
        </div>

        

        
      </div>

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

        <div class="method-description">
          
          <p>Returns the path parameter passed to <em>dir</em>&#39;s constructor.</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;..&quot;</span>)
<span class="ruby-identifier">d</span>.<span class="ruby-identifier">path</span>   <span class="ruby-comment">#=&gt; &quot;..&quot;</span>
</pre>
          
          

          
          <div class="method-source-code" id="to_path-source">
            <pre>static VALUE
dir_path(VALUE dir)
{
    struct dir_data *dirp;

    TypedData_Get_Struct(dir, struct dir_data, &amp;dir_data_type, dirp);
    if (NIL_P(dirp-&gt;path)) return Qnil;
    return rb_str_dup(dirp-&gt;path);
}</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>