Forks - GingerLi/Record GitHub Wiki

Resource fork vs. Data fork

  • Resource fork: The resource fork may contain the code of a program, the commands of a font file, etc. Some programs store a preview picture in the resource fork. The code of programs is stored in the resource fork. Program files often have an empty data fork. This explains why it can happen that a program, transferred through channels ignoring file forks and having lost its resource fork, can no longer be executed (error -39, meaning unexpected end of file). Against what is often said, even by knowledgeable persons, the resource fork doesn't contain the signature of Macintosh files (file type and file creator), which is stored in the disk catalog.

  • Data fork: Contains what we generally call a file on the PC, that is the text created by a word processor, the pixels building a picture, etc. When transferring data files between Macintosh and PC, the data fork is generally the only part of interest (the major exception being font files and programs [executable files], see below).

Refer 1

Refer 2

Set icons for os x file&folder

在Mac系统里面,文件的一些属性是存储在Resource Fork里面的,这个在其它的系统里面基本上是没有的,是Mac系统的特点。

Resource Fork是存储文件结构化数据的存储方式,是和Data Fork相对比而言的, Data Fork就是我们最普通的一个文件的内容的存储方式了。

Folder:

sips -i "a/image/path"

/usr/bin/DeRez -only icns "a/image/path" > tmpicns.rsrc

/usr/bin/Rez -append tmpicns.rsrc -o "a/folder/path"/Icon$'\r'

SetFile -a C "a/folder/path"

SetFile -a V "a/folder/path"/Icon$'\r'

File

sips -i "a/image/path"

/usr/bin/DeRez -only icns "a/image/path" > tmpicns.rsrc

/usr/bin/Rez -append tmpicns.rsrc -o "a/file/path"

SetFile -a C "a/file/path"