MAC OS X alias folder/file do not persist on Windows

让人想犯罪 __ 提交于 2021-02-10 13:15:48

问题


I have one Folder and I have created an Alias (Short-cut) on my MAC OS Desktop. Now, when I copy that Alias from MAC OS to Windows, then it shows me a type of file as "File".

Now if I again copy that Alias from Windows to Mac OS, then that alias is now Unix Executable file and Not an Alias.

I have tried zipping that Alias, and still having the same issue. Is it possible to persist MAC Alias on Windows and when i copy that Alias back to Mac then it remains Alias.


回答1:


Mac filesystems can attach a several kinds of metadata to files that are not supported by other filesystems, such as those Windows uses. Depending on exactly how the file is moved between systems, this metadata may or may not be preserved; if it gets lost, the file may become unusable.

In the case of alias files, there are two relevant pieces of metadata: the type code (which identifies the file as an alias), and the resource fork (which in the case of alias files, stores the info about where to find the original item). Alias files created by older versions of OS X actually had no regular contents (the "data fork") at all -- if their metadata got lost, you were left with an empty file of unknown type. More recent versions store the original item info in both the resource and data forks, so if the resource fork gets lost it's still usable; but if the type code is lost, the OS has no idea it's an alias, it just sees some unidentifiable data (which it mistakes for a unix executable).

In some cases, if you use the right OS X tools to copy/move files to foreign filesystems (that don't support type codes, resource forks, etc), the OS X tool will encode & store the metadata in some alternate form:

  • If you use the Finder to copy a file to a FAT32 flash drive, it'll store the metadata as a separate file with a "._" prefix on the name, using AppleDouble format. If you look at this on Windows, you'll see e.g. "alias file" and "._alias file". As long as the two files are kept together, when they get back to a Mac, it'll logically reassemble them into a single file with all its metadata.

  • If you use the Finder to create a zip archive, it'll do a very similar trick where it stores the metadata as "._" files inside the zip archive (in a __MACOSX subfolder); and if you expand the archive with the Finder (actually Archive Utility), it'll reassemble the files.

    But OS X's command-line zip tools do not support this AppleDouble/"." trick. If you use zip to create an archive, it will simply leave off the Mac-only metadata, and if you use unzip on an archive that contains "." files, it will not reassemble them. If you need to create zip archives at the command line, ditto is actually the way to go.

  • If you use the Finder to copy the files to a Windows server that uses the NTFS filesystem, it'll hide the metadata in an alternate data stream (a Windows-only form of advanced metadata) attached to the file, and if you use the Finder to copy it back it'll be reassembled properly. But if you use something else, or move/copy the file in a way that doesn't preserve the alternate data stream, it'll get lost.



来源:https://stackoverflow.com/questions/21771273/mac-os-x-alias-folder-file-do-not-persist-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!