title: FileManager.copyItem(at: URL, to: URL) fails without throwing an error
body: <p>I've noticed that <code>FileManager</code>'s methods for moving and copying items behave differently. <code>fileManager.moveItem(at: src, to: dst)</code> throws error if <code>dst</code> directory has immutable attribute:</p>
  
  <blockquote>
    <p>Error Domain=NSCocoaErrorDomain Code=513 "“src” couldn’t be moved because you don’t have permission to access “dst”." UserInfo={NSSourceFilePathErrorKey=dst, NSUserStringVariant=(
        Move
    ), NSDestinationFilePath=dst, NSFilePath=src, NSUnderlyingError=0x108b0e190 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}</p>
  </blockquote>
  
  <p>Instead <code>fileMangaer.copyItem(at: src, to: dst)</code> doesn't throw any errors. It's only output to console a message:</p>
  
  <blockquote>
    <p>Open on dst: Operation not permitted</p>
  </blockquote>
  
  <p>Is there are any way to copy file with better error handling?</p>
  
  <p>Running on macOS 10.12.5</p>
  
  <p>UPD:</p>
  
  <p>Code example:</p>
  
  <pre><code>let dir = "/private/tmp/file-manager-test"
  let file = "/private/tmp/file1"
  
  do {
      try FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true, attributes: nil)
      FileManager.default.createFile(atPath: file, contents: Data(), attributes: nil)
  
      try FileManager.default.setAttributes([.immutable: true], ofItemAtPath: dir)
  
      let fname = (file as NSString).lastPathComponent
      let dst = (dir as NSString).appendingPathComponent(fname)
      try FileManager.default.copyItem(atPath: file, toPath: dst)
  
  } catch let e {
  
      print("\(e)")
  }
  </code></pre>
  
  <p>It works as expected in playground. But if you run this code in <code>applicationDidFinishLaunching()</code> method you will see no exceptions.</p>
  
  <p>UPD2:</p>
  
  <p>I've found similar case on OpenRadar: <a href="https://openradar.appspot.com/32083596" rel="nofollow noreferrer">https://openradar.appspot.com/32083596</a></p>
  
  <p>Looks like this is system's bug related to <code>OS_ACTIVITY_DT_MODE</code> environment variable.</p>