title: FileManager.createDirectory fails with NSCocoaErrorDomain Code: 518
body: <p>I'm doing</p>
  
  <pre><code>    let tempDirectory = URL(string: "\(NSTemporaryDirectory())video/")!
      do {
          try FileManager.default.createDirectory(
              at: tempDirectory,
              withIntermediateDirectories: true)
      } catch { report(error) }
  </code></pre>
  
  <p>and that's often throwing an NSCocoaErrorDomain Code: 518.</p>
  
  <p>Any idea of the reason? I thought that could because there's already something there, so I added</p>
  
  <pre><code>    var isDir: ObjCBool = false
      if FileManager.default.fileExists(
          atPath: tempDirectory.absoluteString,
          isDirectory: &amp;isDir
      ) {
          if isDir.boolValue {
              print("Temp directory exists on launch")
          }
          else {
              print("Temp directory exists on launch and is a file")
          }
          return
      }
  </code></pre>
  
  <p>but that doesn't seem to catch anything</p>