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: Philip Aker <email@hidden>
- Date: Sat, 13 Oct 2007 17:21:43 -0700
On 2007-13-10, at 16:35, Andrei Tchijov wrote:
actually, "ls -i" will report so-called inode-number, which is
unique and will work on most FS
ls -i build.xml
26173083 build.xml
That looks to be much more efficient for this purpose. Is the inode-
number unique per volume or across the whole system (as when one has
other drives are mounted)?
On Oct 13, 2007, at 7:11 PM, Philip Aker wrote:
On Oct 13, 2007, at 1:33, Richard Rönnbäck wrote:
So, how can I turn something like this:
/Some/Very/Long/POSIX/Path/
into a shorter number like this
1234
And be absolutely sure that no other path/sequence of characters
could get the same number?
It's not a number, but you can set up an association pair of a
path to a uuid. uuids are always 36 characters long.
set lib to POSIX path of (path to library folder from user domain)
set pic to POSIX path of (path to pictures folder)
set uuid to {lib, (do shell script "uuidgen"), pic, (do shell
script "uuidgen")}
Because uuids are unique (you can't get uuidgen to produce the
same one), you'll need to store the mapping pairs externally right
after they are first obtained. You can use the shell tool
'defaults' with an invented identifier (com.ronnback.filemaps
e.g.) for this purpose. Store them with the key set to the file
path and the value set to the uuid.
This kind of technique is used extensively at Apple for all sorts
of things. For example, Mail.app signatures are stored and
retrieved by via a mapping.
Philip Aker
email@hidden
_______________________________________________
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