fakefs/classes/FakeFS/FileUtils.html
2010-12-18 14:22:02 -05:00

640 lines
35 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>FakeFS::FileUtils</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="banner">
<h1>
<span class="type">Module</span>
FakeFS::FileUtils
</h1>
<ul class="files">
<li><a href="../../files/lib/fakefs/fileutils_rb.html">lib/fakefs/fileutils.rb</a></li>
</ul>
</div>
<div id="bodyContent">
<div id="content">
<div class="sectiontitle">Methods</div>
<dl class="methods">
<dt>C</dt>
<dd>
<ul>
<li><a href="#M000137">cd</a>,</li>
<li><a href="#M000138">chdir</a>,</li>
<li><a href="#M000134">chown</a>,</li>
<li><a href="#M000135">chown_R</a>,</li>
<li><a href="#M000128">cp</a>,</li>
<li><a href="#M000129">cp_r</a></li>
</ul>
</dd>
<dt>L</dt>
<dd>
<ul>
<li><a href="#M000126">ln_s</a>,</li>
<li><a href="#M000127">ln_sf</a></li>
</ul>
</dd>
<dt>M</dt>
<dd>
<ul>
<li><a href="#M000119">mkdir_p</a>,</li>
<li><a href="#M000120">mkpath</a>,</li>
<li><a href="#M000133">mv</a></li>
</ul>
</dd>
<dt>R</dt>
<dd>
<ul>
<li><a href="#M000122">rm</a>,</li>
<li><a href="#M000125">rm_f</a>,</li>
<li><a href="#M000124">rm_r</a>,</li>
<li><a href="#M000123">rm_rf</a>,</li>
<li><a href="#M000121">rmdir</a></li>
</ul>
</dd>
<dt>T</dt>
<dd>
<ul>
<li><a href="#M000136">touch</a></li>
</ul>
</dd>
</dl>
<div class="sectiontitle">Instance Public methods</div>
<div class="method">
<div class="title" id="M000137">
<a name="M000137"></a><b>cd</b>(dir)
</div>
<div class="aka">
This method is also aliased as
<a href="FileUtils.html#M000138">chdir</a>
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000137_source')" id="l_M000137_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L124" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000137_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 124</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cd</span>(<span class="ruby-identifier">dir</span>)
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">dir</span>)
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000138">
<a name="M000138"></a><b>chdir</b>(dir)
</div>
<div class="description">
<p>
Alias for <a href="FileUtils.html#M000137">cd</a>
</p>
</div>
</div>
<div class="method">
<div class="title" id="M000134">
<a name="M000134"></a><b>chown</b>(user, group, list, options={})
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000134_source')" id="l_M000134_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L98" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000134_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 98</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chown</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>, <span class="ruby-identifier">list</span>, <span class="ruby-identifier">options</span>={})
<span class="ruby-identifier">list</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">list</span>)
<span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
<span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">f</span>)
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-identifier">f</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-identifier">list</span>
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000135">
<a name="M000135"></a><b>chown_R</b>(user, group, list, options={})
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000135_source')" id="l_M000135_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L108" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000135_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 108</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chown_R</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>, <span class="ruby-identifier">list</span>, <span class="ruby-identifier">options</span>={})
<span class="ruby-identifier">chown</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>, <span class="ruby-identifier">list</span>, <span class="ruby-identifier">options</span>={})
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000128">
<a name="M000128"></a><b>cp</b>(src, dest)
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000128_source')" id="l_M000128_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L41" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000128_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 41</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cp</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>)
<span class="ruby-identifier">dst_file</span> = <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">dest</span>)
<span class="ruby-identifier">src_file</span> = <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">src</span>)
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">src_file</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-identifier">src</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">src_file</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EISDIR</span>, <span class="ruby-identifier">src</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dst_file</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">dst_file</span>)
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">src</span>), <span class="ruby-identifier">src_file</span>.<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">clone</span>(<span class="ruby-identifier">dst_file</span>))
<span class="ruby-keyword kw">else</span>
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">dest</span>)
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">src_file</span>.<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">clone</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000129">
<a name="M000129"></a><b>cp_r</b>(src, dest)
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000129_source')" id="l_M000129_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L61" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000129_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 61</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cp_r</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>)
<span class="ruby-comment cmt"># This error sucks, but it conforms to the original Ruby</span>
<span class="ruby-comment cmt"># method.</span>
<span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;unknown file type: #{src}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">dir</span> = <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">src</span>)
<span class="ruby-identifier">new_dir</span> = <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">dest</span>)
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_dir</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">dest</span>)
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EEXIST</span>, <span class="ruby-identifier">dest</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">new_dir</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">dest</span><span class="ruby-operator">+</span><span class="ruby-value str">'/../'</span>)
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-identifier">dest</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-comment cmt"># This last bit is a total abuse and should be thought hard</span>
<span class="ruby-comment cmt"># about and cleaned up.</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_dir</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">src</span>[<span class="ruby-value">-2</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'/.'</span>
<span class="ruby-identifier">dir</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">new_dir</span>[<span class="ruby-identifier">f</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">clone</span>(<span class="ruby-identifier">new_dir</span>) }
<span class="ruby-keyword kw">else</span>
<span class="ruby-identifier">new_dir</span>[<span class="ruby-identifier">dir</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">clone</span>(<span class="ruby-identifier">new_dir</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">else</span>
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">clone</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000126">
<a name="M000126"></a><b>ln_s</b>(target, path, options = {})
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000126_source')" id="l_M000126_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L32" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000126_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 32</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ln_s</span>(<span class="ruby-identifier">target</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {})
<span class="ruby-identifier">options</span> = { <span class="ruby-identifier">:force</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
(<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">path</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:force</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">raise</span>(<span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EEXIST</span>, <span class="ruby-identifier">path</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>)
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">path</span>, <span class="ruby-constant">FakeSymlink</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">target</span>))
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000127">
<a name="M000127"></a><b>ln_sf</b>(target, path)
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000127_source')" id="l_M000127_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L37" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000127_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 37</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ln_sf</span>(<span class="ruby-identifier">target</span>, <span class="ruby-identifier">path</span>)
<span class="ruby-identifier">ln_s</span>(<span class="ruby-identifier">target</span>, <span class="ruby-identifier">path</span>, { <span class="ruby-identifier">:force</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span> })
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000119">
<a name="M000119"></a><b>mkdir_p</b>(path, options = {})
</div>
<div class="aka">
This method is also aliased as
<a href="FileUtils.html#M000120">mkpath</a>
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000119_source')" id="l_M000119_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L5" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000119_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 5</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mkdir_p</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {})
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">path</span>, <span class="ruby-constant">FakeDir</span>.<span class="ruby-identifier">new</span>)
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000120">
<a name="M000120"></a><b>mkpath</b>(path, options = {})
</div>
<div class="description">
<p>
Alias for <a href="FileUtils.html#M000119">mkdir_p</a>
</p>
</div>
</div>
<div class="method">
<div class="title" id="M000133">
<a name="M000133"></a><b>mv</b>(src, dest, options={})
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000133_source')" id="l_M000133_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L89" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000133_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 89</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mv</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>={})
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">target</span> = <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">src</span>)
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">target</span>.<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">clone</span>)
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">src</span>)
<span class="ruby-keyword kw">else</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-identifier">src</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000122">
<a name="M000122"></a><b>rm</b>(list, options = {})
</div>
<div class="aka">
This method is also aliased as
<a href="FileUtils.html#M000123">rm_rf</a>
<a href="FileUtils.html#M000124">rm_r</a>
<a href="FileUtils.html#M000125">rm_f</a>
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000122_source')" id="l_M000122_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L22" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000122_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 22</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rm</span>(<span class="ruby-identifier">list</span>, <span class="ruby-identifier">options</span> = {})
<span class="ruby-constant">Array</span>(<span class="ruby-identifier">list</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000125">
<a name="M000125"></a><b>rm_f</b>(list, options = {})
</div>
<div class="description">
<p>
Alias for <a href="FileUtils.html#M000122">rm</a>
</p>
</div>
</div>
<div class="method">
<div class="title" id="M000124">
<a name="M000124"></a><b>rm_r</b>(list, options = {})
</div>
<div class="description">
<p>
Alias for <a href="FileUtils.html#M000122">rm</a>
</p>
</div>
</div>
<div class="method">
<div class="title" id="M000123">
<a name="M000123"></a><b>rm_rf</b>(list, options = {})
</div>
<div class="description">
<p>
Alias for <a href="FileUtils.html#M000122">rm</a>
</p>
</div>
</div>
<div class="method">
<div class="title" id="M000121">
<a name="M000121"></a><b>rmdir</b>(list, options = {})
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000121_source')" id="l_M000121_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L10" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000121_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 10</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rmdir</span>(<span class="ruby-identifier">list</span>, <span class="ruby-identifier">options</span> = {})
<span class="ruby-identifier">list</span> = [ <span class="ruby-identifier">list</span> ] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
<span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">l</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'/'</span>)
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">pop</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-node">&quot;No such file or directory - #{l}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">join</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-operator">||</span> <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'/'</span>))
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-identifier">l</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">l</span>)
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOTEMPTY</span>, <span class="ruby-identifier">l</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">l</span>).<span class="ruby-identifier">values</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-identifier">rm</span>(<span class="ruby-identifier">l</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title" id="M000136">
<a name="M000136"></a><b>touch</b>(list, options={})
</div>
<div class="sourcecode">
<p class="source-link">
Source: <a href="javascript:toggleSource('M000136_source')" id="l_M000136_source">show</a>
| <a href="http://github.com/defunkt/fakefs/blob/c2a9c13345ab2ec7a259401d9916e3aecc88489d/lib/fakefs/fileutils.rb#L112" target="_blank" class="github_url">on GitHub</a>
</p>
<div id="M000136_source" class="dyn-source">
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 112</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">touch</span>(<span class="ruby-identifier">list</span>, <span class="ruby-identifier">options</span>={})
<span class="ruby-constant">Array</span>(<span class="ruby-identifier">list</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">directory</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">f</span>)
<span class="ruby-comment cmt"># FIXME this explicit check for '.' shouldn't need to happen</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">directory</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">directory</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'.'</span>
<span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">f</span>, <span class="ruby-constant">FakeFile</span>.<span class="ruby-identifier">new</span>)
<span class="ruby-keyword kw">else</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-identifier">f</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>