Swift FileManager on iOS device: wrong/different resourceValues for execute/read/write

Yes, that surely will be the smartest thing to do.

Thanks for your help! :slight_smile: :+1:

Just for my understanding:
The isXxxFile(atPath:) methods as well as the resourceValues(forKeys:) method are based on access and should (theoretically) return the same permissions. Or am I misunderstanding?

EDIT (12.02.21):
@Eskimo's answer was an important clue for my research.
I have now researched the following:

  • isXxxFile(atPath:) methods are based on real user ID (RUID) and real group ID (RGID) (see here).
  • The resourceValues(forKeys:) method is based on the effective user (EUID) and group IDs (EGID) (see here).

Thus different access values can be returned.

Informations for EUID vs RUID see here or here.

Regarding @eskimo's hint:

you should instead try that thing and then deal with the error

Found this on developer documentation:
Attempting to predicate behavior based on the current state of the file system or a particular file on the file system is not recommended. Doing so can cause odd behavior or race conditions. It's far better to attempt an operation (such as loading a file or creating a directory), check for errors, and handle those errors gracefully than it is to try to figure out ahead of time whether the operation will succeed. For more information on file system race conditions, see Race Conditions and Secure File Operations in Secure Coding Guide.

Further helpful hints and answers are welcome.