Re: Identifying "LN" type aliases
Re: Identifying "LN" type aliases
- Subject: Re: Identifying "LN" type aliases
- From: "Adam K. Wuellner" <email@hidden>
- Date: Fri, 17 Sep 2004 11:00:33 -0500
On Sep 17, 2004, at 12:41 AM, Brian Johnson wrote:
So, how best to correctly identify
MacOS alias files and folders ("Info for" says "alias:true")
Unix 'alias' (LN) files and foldlers ??? (something with do shell
script and perl I suspect)
And, isn't there a distinction between 'hard' and 'soft' links?
All files are pretty much hard links. A hard link is a file name and
location, or directory entry, assigned to an inode. An inode stores
information about a file, including: user owner and group owner ids,
Unix file type, permissions, last access time, number of hard links
pointing to the inode, size of the file, disk location. Usually,
there's only directory entry for a given inode, but there's nothing
preventing you from adding more ways to address the same data. It's
explained in the manpage for the ln command ('man ln' in Terminal), and
in the chapter entitled "The Unix Way" in Essential System
Administration from O'Reilly.
I did a simple test. I created a folder and a text file in the folder.
Then I used Finder to create an alias to the file in the same folder.
Then I used the command line to create a soft link to the file and a
hard link to the file. So I had a folder ("temp") with four files
("top.txt", "softlink.top.txt", "hardlink.top.txt", "alias.top.txt").
Here's how Terminal displays the contents of "temp" (ls -l ~/temp):
-rw-r--r-- 1 akw akw 0 17 Sep 10:11 alias.top.txt
-rw-r--r-- 2 akw akw 566609 17 Sep 10:04 hardlink.top.txt
lrwxr-xr-x 1 akw akw 7 17 Sep 10:08 softlink.top.txt -> top.txt
-rw-r--r-- 2 akw akw 566609 17 Sep 10:04 top.txt
Notice that hardlink.top.txt and top.txt are identical except for the
filename. That is, in fact, the case. They are both 'files' pointing
to the exact same inode. (Notice that the second column shows that
there are 2 hard links to that file, too.) The alias and the soft link
(which APPEAR the same in Finder) are a bit different as shown by
Terminal. The first character of the listing is '-' for the Finder
alias, and 'l' for the soft link. The '-' indicates a normal file, the
'l' a symbolic (or soft) link. The listing for the soft link also
shows what file the link refers to ('-> top.txt').
I used this AppleScript code to get the info for each of these files:
--begin code
property WorkingDirectory : "Macadam:Users:akw:temp:"
property FileList : {"top.txt", "hardlink.top.txt", "softlink.top.txt",
"alias.top.txt"}
set s_ to ""
repeat with i from 1 to count of FileList
set file_info to info for file (WorkingDirectory & item i of FileList)
set name_ to name of file_info
set alias_ to alias of file_info
set creator_ to file creator of file_info
set type_ to file type of file_info
set kind_ to kind of file_info
set size_ to size of file_info
set s_ to (s_ & "
Name: " & name_ & "
Alias: " & alias_ as string) & "
Creator: " & creator_ & "
Type: " & type_ & "
Kind: " & kind_ & "
Size: " & size_
end repeat
s_
-- end code
The results (notice the difference between the Finder-style alias and
the Unix-style soft link):
Name: top.txt
Alias: false
Creator:
Type:
Kind: Plain text document
Size: 5.66609E+5
Name: hardlink.top.txt
Alias: false
Creator:
Type:
Kind: Plain text document
Size: 5.66609E+5
Name: softlink.top.txt
Alias: true
Creator: rhap
Type: slnk
Kind: Alias
Size: 7.0
Name: alias.top.txt
Alias: true
Creator:
Type:
Kind: Alias
Size: 4.2906E+4
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden