taber
taber

Reputation: 3240

will NSFileSystemFileNumber in iOS always be unique?

When using attributesOfItemAtPath:error:, is NSFileSystemFileNumber always guaranteed to be unique for the device?

For example, I have a file with a certain NSFileSystemFileNumber, but a few days later I delete this file. If I create another file later on, is it possible that this new file can ever re-use the other file's NSFileSystemFileNumber, or will the NSFileSystemFileNumber always be unique?

Thanks!

Upvotes: 5

Views: 1309

Answers (2)

Chuck
Chuck

Reputation: 237060

The NSFileSystemFileNumber is just the file's inode number. It's unique to the file while the file exists, but once the file is gone, it could be reused at any time.

Upvotes: 4

hoha
hoha

Reputation: 4428

NSFileManager Class Reference

NSFileSystemFileNumber

The key in a file attribute dictionary whose value indicates the file's filesystem file number. The corresponding value is an NSNumber object containing an unsigned long. The value corresponds to the value of st_ino, as returned by stat(2).

man 2 stat

ino_t st_ino; /* inode's number */

So this is an inode number. I believe inode can be reused by filesystem after original file is deleted.

Upvotes: 9

Related Questions