SwiftFoundation FileManager.isDeletableFile Implementation

Sure. Here is a rundown of the implementation:

  1. Get the parent directory of supplied path
  2. If the parent directory is not writeable return false
  3. stat the parent directory, and if that fails, return false
  4. Check if the parent is 'sticky' (S_ISVTX on Darwin) and if it exists. If so, and if the current user (getuid) owns the file, return true.
  5. Return true as the best guess after all of that
2 Likes