Odd, outdated misdirection concept

Discussion in 'Mac Programming' started by Sydde, Jan 9, 2010.

  1. Sydde macrumors 68020


    Aug 17, 2009
    I wonder if anyone has ever done this.

    First, one would create an alias to an existing file or directory. The documentation says that the system does not support this, only Finder can do it. As far as I can tell, you would use the Alias Manager to make an alias handle that you would then put into a file as a resource of type 'alis', ID 0, in the resource fork, save the file, and set its alias flag. At this point, one should have a alias file that Finder, Open/Save and most other apps will follow to its target.

    But using NSFileManager, NSFileHandle or the Core Services file manager, your app has to go through extra steps to follow the alias. You could write code that stores data you want obscured into the data fork of the alias file, and only a very observant person will notice that the file is too big to be an alias.

    Of course, aliases are rather old school, only work on HFS volumes, and may be EoL'd at some point down the road, so this weak misdirection concept would not be viable in the long term. But it sure would be interesting to know if anyone ever tried it.
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    You could do it yourself. Simply use the >> operator in shell to append some text to the data-fork of an alias-file. The data-fork is normally empty, and >> won't delete or truncate an existing file.

    FWIW, it's not that hard to make an alias-file that works in Finder and elsewhere. I've written code that does it, and it works on at least 10.2 thru 10.6. However, I recommend dissecting actual alias files created by Finder, rather than speculating about their contents. It's not quite as simple as you outlined.

    OBTW, alias files work on any file-system, not just HFS. Copy some alias-files to a USB thumb drive formatted as FAT. I think you'll find they work fine. So do symlinks. They don't work outside Mac OS, but that's the OS, not the file-system.

Share This Page