586 lines
32 KiB
HTML
586 lines
32 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="#M000115">cd</a>,</li>
|
||
|
|
||
|
<li><a href="#M000116">chdir</a>,</li>
|
||
|
|
||
|
<li><a href="#M000112">chown</a>,</li>
|
||
|
|
||
|
<li><a href="#M000113">chown_R</a>,</li>
|
||
|
|
||
|
<li><a href="#M000100">cp</a>,</li>
|
||
|
|
||
|
<li><a href="#M000102">cp_r</a></li>
|
||
|
|
||
|
</ul>
|
||
|
</dd>
|
||
|
|
||
|
<dt>L</dt>
|
||
|
<dd>
|
||
|
<ul>
|
||
|
|
||
|
<li><a href="#M000099">ln_s</a></li>
|
||
|
|
||
|
</ul>
|
||
|
</dd>
|
||
|
|
||
|
<dt>M</dt>
|
||
|
<dd>
|
||
|
<ul>
|
||
|
|
||
|
<li><a href="#M000084">mkdir_p</a>,</li>
|
||
|
|
||
|
<li><a href="#M000086">mkpath</a>,</li>
|
||
|
|
||
|
<li><a href="#M000111">mv</a></li>
|
||
|
|
||
|
</ul>
|
||
|
</dd>
|
||
|
|
||
|
<dt>R</dt>
|
||
|
<dd>
|
||
|
<ul>
|
||
|
|
||
|
<li><a href="#M000092">rm</a>,</li>
|
||
|
|
||
|
<li><a href="#M000098">rm_r</a>,</li>
|
||
|
|
||
|
<li><a href="#M000093">rm_rf</a>,</li>
|
||
|
|
||
|
<li><a href="#M000087">rmdir</a></li>
|
||
|
|
||
|
</ul>
|
||
|
</dd>
|
||
|
|
||
|
<dt>T</dt>
|
||
|
<dd>
|
||
|
<ul>
|
||
|
|
||
|
<li><a href="#M000114">touch</a></li>
|
||
|
|
||
|
</ul>
|
||
|
</dd>
|
||
|
|
||
|
</dl>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sectiontitle">Instance Public methods</div>
|
||
|
|
||
|
<div class="method">
|
||
|
<div class="title" id="M000115">
|
||
|
|
||
|
<a name="M000115"></a><b>cd</b>(dir)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div class="aka">
|
||
|
This method is also aliased as
|
||
|
|
||
|
<a href="FileUtils.html#M000116">chdir</a>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000115_source')" id="l_M000115_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L117" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000115_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 117</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="M000116">
|
||
|
|
||
|
<a name="M000116"></a><b>chdir</b>(dir)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="description">
|
||
|
<p>
|
||
|
Alias for <a href="FileUtils.html#M000115">cd</a>
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="method">
|
||
|
<div class="title" id="M000112">
|
||
|
|
||
|
<a name="M000112"></a><b>chown</b>(user, group, list, options={})
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000112_source')" id="l_M000112_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L91" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000112_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 91</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="M000113">
|
||
|
|
||
|
<a name="M000113"></a><b>chown_R</b>(user, group, list, options={})
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000113_source')" id="l_M000113_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L101" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000113_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 101</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="M000100">
|
||
|
|
||
|
<a name="M000100"></a><b>cp</b>(src, dest)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000100_source')" id="l_M000100_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L34" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000100_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 34</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">&&</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="M000102">
|
||
|
|
||
|
<a name="M000102"></a><b>cp_r</b>(src, dest)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000102_source')" id="l_M000102_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L54" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000102_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 54</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">"unknown file type: #{src}"</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">&&</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">&&</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="M000099">
|
||
|
|
||
|
<a name="M000099"></a><b>ln_s</b>(target, path)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000099_source')" id="l_M000099_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L29" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000099_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 29</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">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-keyword kw">if</span> <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</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="M000084">
|
||
|
|
||
|
<a name="M000084"></a><b>mkdir_p</b>(path)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div class="aka">
|
||
|
This method is also aliased as
|
||
|
|
||
|
<a href="FileUtils.html#M000086">mkpath</a>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000084_source')" id="l_M000084_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L5" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000084_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-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="M000086">
|
||
|
|
||
|
<a name="M000086"></a><b>mkpath</b>(path)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="description">
|
||
|
<p>
|
||
|
Alias for <a href="FileUtils.html#M000084">mkdir_p</a>
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="method">
|
||
|
<div class="title" id="M000111">
|
||
|
|
||
|
<a name="M000111"></a><b>mv</b>(src, dest)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000111_source')" id="l_M000111_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L82" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000111_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 82</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-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="M000092">
|
||
|
|
||
|
<a name="M000092"></a><b>rm</b>(path)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div class="aka">
|
||
|
This method is also aliased as
|
||
|
|
||
|
<a href="FileUtils.html#M000093">rm_rf</a>
|
||
|
|
||
|
<a href="FileUtils.html#M000098">rm_r</a>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000092_source')" id="l_M000092_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L22" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000092_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">path</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></pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="method">
|
||
|
<div class="title" id="M000098">
|
||
|
|
||
|
<a name="M000098"></a><b>rm_r</b>(path)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="description">
|
||
|
<p>
|
||
|
Alias for <a href="FileUtils.html#M000092">rm</a>
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="method">
|
||
|
<div class="title" id="M000093">
|
||
|
|
||
|
<a name="M000093"></a><b>rm_rf</b>(path)
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="description">
|
||
|
<p>
|
||
|
Alias for <a href="FileUtils.html#M000092">rm</a>
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="method">
|
||
|
<div class="title" id="M000087">
|
||
|
|
||
|
<a name="M000087"></a><b>rmdir</b>(list, options = {})
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000087_source')" id="l_M000087_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L10" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000087_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">"No such file or directory - #{l}"</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">""</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="M000114">
|
||
|
|
||
|
<a name="M000114"></a><b>touch</b>(list, options={})
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="sourcecode">
|
||
|
<p class="source-link">
|
||
|
Source: <a href="javascript:toggleSource('M000114_source')" id="l_M000114_source">show</a>
|
||
|
|
||
|
| <a href="http://github.com/defunkt/fakefs/blob/25e47887b0091d1afc9b87d832d0a61e40c6a7c3/lib/fakefs/fileutils.rb#L105" target="_blank" class="github_url">on GitHub</a>
|
||
|
|
||
|
</p>
|
||
|
<div id="M000114_source" class="dyn-source">
|
||
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/fileutils.rb, line 105</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>
|