title: Does Ruby have mkdir -p?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3686032/how-to-create-directories-recursively-in-ruby">How to create directories recursively in ruby?</a>  </p>
  </blockquote>
  
  
  
  <p>In Ruby, how could I do:</p>
  
  <pre><code>mkdir -p cool/beans
  </code></pre>
  
  <ol>
  <li><p>Here's what I came up with:</p>
  
  <pre><code>Dir.mkdir('cool') unless File.directory?('cool')
  cool_beans_path = File.join('cool', 'beans')
  Dir.mkdir(cool_beans_path) unless File.directory?(cool_beans_path)
  </code></pre>
  
  <p>But, isn't there a better way?</p></li>
  <li><p>I know I could do:</p>
  
  <pre><code>system('mkdir', '-p', File.join('cool', 'beans'))
  </code></pre>
  
  <p>But, that's not platform independent, is it? Like, it works on Mac but not on Windows, right?</p></li>
  </ol>