Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Alias (Mac OS)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== File structure == The alias files in macOS start by the [[magic number (programming)|magic number]] <code>62 6F 6F 6B 00 00 00 00 6D 61 72 6B 00 00 00 00</code> which is in [[ASCII]] <big><code>bookββββmarkββββ</code></big> (<big>β</big> representing the [[Null character]]). Following the magic number, it has been reported that an alias has a set of records inside it, each record is 150 bytes long and consists of the fields shown below (all integers are big endian).<ref>{{Cite web |title=Some information about MacOS aliases collected from the web. |url=http://sebastien.kirche.free.fr/python_stuff/MacOS-aliases.txt |url-status=live |archive-url=https://web.archive.org/web/20100120201512/http://sebastien.kirche.free.fr/python_stuff/MacOS-aliases.txt |archive-date=2010-01-20}}</ref> However, alias files are far larger than this would explain, and include other information at least including icons.<ref>{{cite web |title=Why are Finder alias files so huge lately? |url=https://discussions.apple.com/thread/3988292?start=0&tstart=0 |url-status=live |archive-url=https://web.archive.org/web/20210507014134/https://discussions.apple.com/thread/3988292 |archive-date=2021-05-07 |website=Apple Support Communities}}</ref><ref>{{Cite web |url=http://forums.macworld.com/index.php?%2Ftopic%2F142842-aliases-vs-symbolic-links%2F |title=Further details, including changes with various Mac OS versions. |access-date=2018-10-11 |archive-url=https://web.archive.org/web/20130430153741/http://forums.macworld.com/index.php?%2Ftopic%2F142842-aliases-vs-symbolic-links%2F |archive-date=2013-04-30 |url-status=dead }}</ref> # 4 bytes user type name/app creator code = long ASCII text string (none = 0) # 2 bytes record size = short unsigned total length # 2 bytes record version = short integer version (current version = 2) # 2 bytes alias kind = short integer value (file = 0; directory = 1) # 1 byte volume name string length = byte unsigned length # 27 bytes volume name string (if volume name string < 27 chars then pad with zeros) # 4 bytes volume created mac date = long unsigned value in seconds since beginning 1904 to 2040 # 2 bytes volume signature = short unsigned HFS value # 2 bytes volume type = short integer mac os value (types are Fixed HD = 0; Network Disk = 1; 400kB FD = 2;800kB FD = 3; 1.4MB FD = 4; Other Ejectable Media = 5 ) # 4 bytes parent directory id = long unsigned HFS value # 1 bytes file name string length = byte unsigned length # 63 bytes file name string (if file name string < 63 chars then pad with zeros) # 4 bytes file number = long unsigned HFS value # 4 bytes file created mac date = long unsigned value in seconds since beginning 1904 to 2040 # 4 bytes file type name = long ASCII text string # 4 bytes file creator name = long ASCII text string # 2 bytes nlvl From (directories from alias thru to root) = short integer range # 2 bytes nlvl To (directories from root thru to source) = short integer range (if alias on different volume then set above to -1) # 4 bytes volume attributes = long hex flags # 2 bytes volume file system id = short integer HFS value # 10 bytes reserved = 80-bit value set to zero # 4+ bytes optional extra data strings = short integer type + short unsigned string length (types are Extended Info End = -1; Directory Name = 0; Directory IDs = 1; Absolute Path = 2; AppleShare Zone Name = 3; AppleShare Server Name = 4; AppleShare User Name = 5; Driver Name = 6; Revised AppleShare info = 9; AppleRemoteAccess dialup info = 10) # string data = hex dump # odd lengths have a 1 byte odd string length pad = byte value set to zero === Alias record structure outside of size length === The following is for use with the Apple's Alias Resource Manager. # 4 bytes resource type name = long ASCII text string # 2 bytes resource ID = short integer value # 2 bytes resource end pad = short value set to zero '''Java code to flag an alias file''' <syntaxhighlight lang="java"> // This function checks whether a file matches the alias magic number. public static boolean checkForMacAliasFile(File inputFile) throws FileNotFoundException, IOException { // Only files can be aliases. // Do not test directories; they will be false. if (inputFile.isFile()) { byte[] bookmark = new byte[] { 0x62, 0x6F, 0x6F, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x61, 0x72, 0x6B, 0x00, 0x00, 0x00, 0x00 }; long length = inputFile.length(); if (length > 16) { byte[] result = new byte[16]; FileInputStream fis = new FileInputStream(inputFile); fis.read(result); fis.close(); return Arrays.equals(result, bookmark); } } return false; } </syntaxhighlight> There is a [https://github.com/davecotter/cftest/blob/main/source/shared/MacAlias.cpp github repo with working C++ code here].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)