 |
 |
Carbon woes
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Status:
Offline
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Status:
Offline
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|