title: mkdir in OS X does not create the full directory tree
body: <p>I am trying to use the mkdir API in OS X (and would like to use it in linux) with C++ to create a directory path.</p>
  
  <p>Say I want to create a directory like: "/Users/luca/Subject/Data". "/Users/luca" structure already exists. So, I do something like:</p>
  
  <pre><code>struct stat st = {0};
  if (stat(path, &amp;st) == -1) {
      return mkdir(path, S_IRWXU);
  }
  </code></pre>
  
  <p>This always returns -1. If I try ""/Users/luca/Subject", it works fine. </p>
  
  <p>Does anyone know how I can get the mkdir -p like behaviour without invoking the system() process call.</p>