NSFileManager Write File As Hidden File (Without Naming ".File")?

Discussion in 'Mac Programming' started by Darkroom, Aug 1, 2008.

  1. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #1
    i've noticed that NSFileManager has an attribute to hide the files extension, but what if i want to make the whole file hidden?

    i understand i could simply add a "." to the beginning of the file name, but how are hidden files written that don't have "." at the beginning of their name? i read somewhere it has to do with setting the hidden attribute in the resource fork of the file, but how can i access/set that resource fork from my cocoa app?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    I've been reading for quite a while since I read your question... and it doesn't seem like there is a Cocoa way to do this. There is a pair of calls, getattrlist and setattrlist that seem to do this, but I cannot find any real example on how to do this. These get called by SetFile when you run it with -a V <filename> (I found this with ktrace/kdump). They're called through some carbon calls, namely:
    http://developer.apple.com/document...ence.html#//apple_ref/c/func/FSSetCatalogInfo
    (found this breaking on getattrlist and setattrlist in gdb and doing a backtrace)

    I don't think there is a Cocoa way to do this.

    Maybe there's a different tact you can take? Put the file in an already hidden directory?

    -Lee
     
  3. Darkroom thread starter Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #3
    thanks for looking into the issue for me Lee.
     

Share This Page