title: Is there a safer way to create a directory if it does not exist?
body: <p>I've found this way of creating a directory if it does not exist. But it looks a bit wonky and I am afraid that this can go wrong in 1 of 1000 attempts.</p>
  
  <pre><code>if(![[NSFileManager defaultManager] fileExistsAtPath:bundlePath]) {
      [[NSFileManager defaultManager] createDirectoryAtPath:bundlePath withIntermediateDirectories:YES attributes:nil error:NULL];
  }
  </code></pre>
  
  <p>There is only this awkward method fileExistsAtPath which also looks for files and not only directories. But for me, the dangerous thing is: What if this goes wrong? What shall I do? What is best practice to guarantee that the directory is created, and only created when it does not exist?</p>
  
  <p>I know file system operations are never safe. Device could loose battery power suddenly just in the moment where it began shoveling the bits from A to B. Or it can stumble upon a bad bit and hang for a second. Maybe in some seldom cases it returns YES even if there is no directory. Simply put: I don't trust file system operations.</p>
  
  <p>How can I make this absolutely safe?</p>