Re: Creating unique numerical representation of file path?
Re: Creating unique numerical representation of file path?
- Subject: Re: Creating unique numerical representation of file path?
- From: Richard Rönnbäck <email@hidden>
- Date: Sun, 14 Oct 2007 09:08:33 +0200
- Thread-topic: Creating unique numerical representation of file path?
Title: Re: Creating unique numerical representation of file path?
Thank you all for some excellent suggestions!
Mark, Andrei, Deivy
This project has been going on for more than a year during which I have dived deep into some things, one of them the inode number system and how different applications make use of them. In case anyone else is going to use inodes, here is what I found out:
While inode numbers appear to be unique that is not entirely true, they are only unique in combination with their "inode generation number", which cannot be reliably retrieved in all cases (from clients connecting to a server etc)
Inodes also change if the files are restored, from let's say a backup copy, so the inode would no longer represent the path.
Inode numbers will NOT change if a file is moved and/or renamed, so for that reason too they do not serve well to represent a path.
I have however successfully been using inodes for locating files whose name or location has changed, which is very useful.
One thing that bit me badly before I realized what was going on is that some applications keep the inode when editing and saving a file, while other, such as Adobe Photoshop, creates a temp file which replaces the original file, thereby generating an entirely different inode for what to an end user appears to be the same file.
As you all have noted inode number can be obtained with various tools, including system events, with a slightly peculiar syntax
tell application "System Events"
set myInode to item 2 of (id of (disk item "/Users/richardr/Desktop/test.txt") as list)
end tell
Doug,
The file ID numbers look interesting, I will try to find out more and I would appreciate if you have more useful info on the subject!
Philip,
Uuids look very interesting but I see a potentially huge problem, in that it seems impossible to generate the same number for the same path again, which the pessimist in me can see would be needed if let's say the file etc holding the mapping pairs gets corrupted or destroyed. They will however come in very handy in another part of the project!
Adrei,
MD5 checksums seem to be exactly what I need! They are of course not numeric in the sense I thought of, but this will serve equally well (or I may convert them to a number). To reduce the (minimal) risk of non-unique numbers I will create an checksum for the entire path as well as for just the filename, and use them both as matching fields on my FileMaker import.
Thank you all! You are great guys - I just love this list and all you helpful people!
// Richard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden