• 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: File system visiblilty
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File system visiblilty


  • Subject: Re: File system visiblilty
  • From: Justin Hawkwood <email@hidden>
  • Date: Thu, 15 Nov 2007 08:19:33 -0800

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:
This email sent to email@hidden


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

  • Prev by Date: Re: [Q] capture or assign global hot key like spotlight or quicksilver
  • Next by Date: Re: [SOLVED] Resetting of property values after completion of a CABasicAnimation
  • Previous by thread: Re: File system visiblilty
  • Next by thread: How to get absolute x?
  • Index(es):
    • Date
    • Thread