Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Carbon woes

Carbon woes
Thread Tools
Mac Elite
Join Date: Aug 2001
Status: Offline
Reply With Quote
May 22, 2004, 07:40 PM
 
I'm writing a Cocoa program that uses some Carbon functions for lower level file access, and I'm having trouble getting it to behave properly. this line:
Code:
[self setInvisible: ((flags1 & kLSItemInfoIsInvisible) == kLSItemInfoIsInvisible) || ((flags2 & kIsInvisible) == kIsInvisible)];
should make all invisible files invisible (I realize it's redundant, I'll take one or the other out once it all works properly). flags1 is the LSItemInfoFlags for the file, gotten via
Code:
LSCopyItemInfoForRef(&ref, kLSRequestAllInfo, &info);
and flags2 is the finder flags from the file's FInfo struct, gotten via
Code:
FSGetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, NULL);
ref is a valid FSRef, catalogInfo is an FSCatalogInfo.

What happens is this: Some files become invisible correctly, others (mach_sym, for example) don't. I haven't been able to find any pattern to this.
(Last edited by Catfish_Man; May 22, 2004 at 07:53 PM. )
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
May 22, 2004, 11:11 PM
 
If the user doesn't have write permission for the file in question, he can't change a file's visibility. mach_sym seems like it'd fall into this category unless your app is running as root.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
May 22, 2004, 11:13 PM
 
There are three ways for a file to become invisible in the Finder's (and Open/Save dialogs, etc) presentation of the filesystem:
1. A HFS-style metadata flag (what you get from FSGetCatalogInfo)
2. The Unix-style way, a filename that begins with a period
3. Files at the root level of a volume whose names are listed in a ".hidden" file, which is also at the root level of that volume.

I'm not sure either API catches the last case... you might have to read .hidden yourself.
Rick Roe
icons.cx | weblog
     
Mac Elite
Join Date: Aug 2001
Status: Offline
Reply With Quote
May 23, 2004, 12:15 AM
 
Originally posted by Rickster:
There are three ways for a file to become invisible in the Finder's (and Open/Save dialogs, etc) presentation of the filesystem:
1. A HFS-style metadata flag (what you get from FSGetCatalogInfo)
2. The Unix-style way, a filename that begins with a period
3. Files at the root level of a volume whose names are listed in a ".hidden" file, which is also at the root level of that volume.

I'm not sure either API catches the last case... you might have to read .hidden yourself.
Ah, ok. Thanks, the first two are easy enough to implement, so I'll do those and see if the third is necessary.

smeger: I'm not actually trying to set the visibility at this point, the setInvisible call is only reflecting the state of the file on the disk. In retrospect, though, I think I'd better just set it directly and keep setInvisible for when I actually want to change the file on the disk.

<edit> curses... .hidden reading time. Thankfully it's just a list of names, not something horrendous to figure out.

On a somewhat related note, how many ways are there to store whether a file/folder has a custom icon? I've been having similar troubles getting them to display. </edit>
(Last edited by Catfish_Man; May 23, 2004 at 12:21 AM. )
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
May 23, 2004, 04:31 AM
 
Uh, if you want to just check if it's visible or not, use LaunchServices. That copes with "any known method" (according to headers and my experience).
     
Mac Elite
Join Date: Aug 2001
Status: Offline
Reply With Quote
May 23, 2004, 01:03 PM
 
Originally posted by Angus_D:
Uh, if you want to just check if it's visible or not, use LaunchServices. That copes with "any known method" (according to headers and my experience).
That's what I thought too. It doesn't (or else I'm using it wrong). flags1 in the code I posted originally is the launch services info flags for the file.

Anyway, reading .hidden does work, except for /Network, and I'm not really concerned about that. If it's the only one I can just special case that one directory.

Thanks for all the help everyone.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:32 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2