I just ran into this question. I think there must be a plist file or something similar. Here is what I found:
When customizing a plain folder with my own icon file, there is an invisible file created in the folder called "Icon^M", which I think is a kind of icon file?
But system "special" folder like /Applications, /Users/Documents, and so on, do not have this kind of file in it, and are displayed as special icons instead of stock plain blue icon.
So, how does Apple associate special folders and their special icons? I think there is some system plist file to associate these two, like:
...
< key >/User/Documents< /key >
< value >pathToIcon or binaryRepOfFileAndPath< /value >
...
Where can I find the file? Thank you!