Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File system visiblilty



Thanks! The missing "stringByAppendingPathComponent" made all the difference. In fact, I no longer needed to check for [aFile hasPrefix:@"."] as the rest of the function picks it up. These changes, along with changing the cStringUsingEncoding: to NSUTF8StringEncoding, has picked up almost all of the remaining files/ folders. The only two that I see off the bat that are not turning invisible are /net and /home.

Thanks all,

  Justin

On Nov 14, 2007, at 5:25 PM, Chris Campbell wrote:

On Nov 14, 2007, at 7:52 PM, Justin Hawkwood wrote:

...
NSMutableArray *pathCont = [NSMutableArray arrayWithArray:[fileMan contentsOfDirectoryAtPath:path error:&fmErr]];

Note that contentsOfDirectoryAtPath:error: will return an array of file/directory names ("MyWordFile.doc", "YayPlainText.txt"), not full paths ("/Users/chris/Documents/MyWordFile.doc", ...). So later on, when you loop through it:



	int i;
	for (i = 0; i < [pathCont count]; i++) {
		NSString *aFile = [pathCont objectAtIndex:i];
		if ([self isVisible:aFile])
			// code
	}

You should build a full path by concatenating the file/directory name to the end of the containing directory's path:


NSString *aFile = [path stringByAppendingPathComponent:[pathCont objectAtIndex:i]];

Knowing that, your logic in isVisible: would need to change:

- (BOOL)isVisible:(NSString *)path
{
if (([path hasPrefix:@"."]) || ([path characterAtIndex:([path length] - 1)] == 13)) return FALSE;

You don't need to test if the full path starts with ".", you want to test if the last component of the path starts with ".", like so:


  if (([[path lastPathComponent] hasPrefix:@"."]) || ...

Have fun!

- Chris


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >File system visiblilty (From: Justin Hawkwood <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.