Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 619
taber Avatar asked Dec 17 '22 15:12

taber


2 Answers

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.

like image 135
hoha Avatar answered Dec 28 '22 23:12

hoha


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.

like image 26
Chuck Avatar answered Dec 28 '22 23:12

Chuck