title: Create folder if it doesn't exist, do nothing if it does
body: <p>I want to create a folder named <code>sessionname</code>. If a folder with this name already exists it is fine, and I don't want to do anything.</p>
  
  <p>Right now I do this: </p>
  
  <pre><code>finalpath = "/home/Documents"    
  finalpath.append(path + "/" + sessionname);
      if (mkdir(finalpath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1)
      {
          //INVALID PATH
          std::cout &lt;&lt; "path is invalid, cannot create sessionnamefolder" &lt;&lt; std::endl;
          throw std::exception();
      }
  </code></pre>
  
  <p>This code errors, if the folder <code>/home/Documents/sessionname</code> exists because the folder couldn't be created.</p>
  
  <p>How can I check if <code>mkdir</code> fails because the string was invalid or because the string was vaild but the folder already exists ?</p>