• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: what happend of the .hidden file in Tiger?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what happend of the .hidden file in Tiger?


  • Subject: Re: what happend of the .hidden file in Tiger?
  • From: Mason Mark <email@hidden>
  • Date: Sat, 27 Aug 2005 05:32:10 +0900

On Aug 27, 2005, at 1:54 AM, James Bucanek wrote:

Giovanni Donelli wrote on Friday, August 26, 2005:

Hi Folks,
    I'm trying to remove the hidden files from the content of a
directory.

1st.    I'm first checking if the name start with a dot: "."
2nd.   I'm using the launch services to determine whether the hidden
flag is on

Still few hidden files are left out from this (such as the mach
kernel in the disk root)

now... there was suppose to be a file called ".hidden" in the
directory which would have listed other hidden files... however I
can't find this file anywhere in Tiger

Anybody any suggestions?


Stop trying to second guess the OS and just ask Launch Services if the item is hidden or not:



LSItemInfoRecord itemInfo;
err = LSCopyItemInfoForRef (&itemRef,kLSRequestBasicFlagsOnly,&itemInfo);
if ( (itemInfo.flags&kLSItemInfoIsInvisible) != 0 )
{
// item is invisible...


This is the exact same interface the Finder and most other system frameworks use. It applies all of the rules that OS X uses to determine if a file should normally be hidden from the user. And will continue to do so in the future, even if those rules change.


Hi guys,

My quibble with the above statement is that Launch Services couldn't really "continue to work" unless it worked now, which it doesn't.

While it does seem to work somewhat *better* than in pre-10.4 OS versions (for example, it seems to now know that files which start with "." are invisible), it still misses some files which should be presented the user as invisible, as Givanni points out.

To wit, here's some test code (based on the above snippet), and its (incorrect) output:


----------- TEST CODE -----------

NSMutableArray *invisibleItems = [NSMutableArray array];
NSMutableArray *visibleItems = [NSMutableArray array];
NSArray *contents = [[NSFileManager defaultManager] directoryContentsAtPath:@"/"];
NSEnumerator *e = [contents objectEnumerator];
NSString *path = nil;
OSStatus err = -1;


while (path = [e nextObject]) {
LSItemInfoRecord itemInfo;
FSRef itemRef;
NSString *realpath = [@"/" stringByAppendingPathComponent:path];
err = FSPathMakeRef([realpath fileSystemRepresentation], &itemRef, NULL);
err = err || LSCopyItemInfoForRef (&itemRef,kLSRequestAllInfo,&itemInfo);
if (err != noErr)
NSLog(@"Got an error for %@, skipping...", realpath);
else if ((itemInfo.flags&kLSItemInfoIsInvisible) != 0)
[invisibleItems addObject:realpath];
else
[visibleItems addObject:realpath];
}


NSLog(@"VISIBLE ITEMS: %@", visibleItems);
NSLog(@"INVISIBLE ITEMS: %@", invisibleItems);

------- END TEST CODE --------



----------- OUTPUT -----------

2005-08-27 05:17:03.154 FiveSpeedCoreTestsApp[491] Got an error for /.vol, skipping...
2005-08-27 05:17:03.155 FiveSpeedCoreTestsApp[491] Got an error for / dev, skipping...
2005-08-27 05:17:03.158 FiveSpeedCoreTestsApp[491] VISIBLE ITEMS: (
"/Applications",
"/Developer",
"/etc",
"/home",
"/Library",
"/mach",
"/mach.sym",
"/Network",
"/PowerBook",
"/System",
"/tmp",
"/Users",
"/var"
)
2005-08-27 05:17:03.158 FiveSpeedCoreTestsApp[491] INVISIBLE ITEMS: (
"/.DS_Store",
"/.hotfiles.btree",
"/.Spotlight-V100",
"/.TemporaryItems",
"/.Trashes",
"/automount",
"/bin",
"/cores",
"/Desktop DB",
"/Desktop DF",
"/mach_kernel",
"/private",
"/sbin",
"/usr",
"/Volumes"
)


---------- END OUTPUT ---------

I count five errors in the above output. (The "/home" in there is a symlink I made and is not invisible/hidden.)

So, it looks like in 10.4 you still need to hardcode in some "psychic abilities" if you want your app to display files consistently with the Finder.

Cheers,
--
Mason Mark
Five Speed Software, Inc.
http://www.fivespeed.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: what happend of the .hidden file in Tiger?
      • From: James Bucanek <email@hidden>
References: 
 >Re: what happend of the .hidden file in Tiger? (From: James Bucanek <email@hidden>)

  • Prev by Date: Re: NSTokenField
  • Next by Date: Re: NSTokenField
  • Previous by thread: Re: what happend of the .hidden file in Tiger?
  • Next by thread: Re: what happend of the .hidden file in Tiger?
  • Index(es):
    • Date
    • Thread