• 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: paths for contents of a directory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: paths for contents of a directory


  • Subject: Re: paths for contents of a directory
  • From: Eric Jutras <email@hidden>
  • Date: Tue, 15 May 2007 01:09:38 -0400

Well then.... use this

With this code:
	NSArray* directoryContents =
		[[NSFileManager defaultManager]
directoryContentsAtPath:directoryPath];
	NSString* path;
	NSEnumerator *enumerator = [directoryContents objectEnumerator];
	while (path = [[enumerator nextObject]) {
	  path = [directoryPath stringByAppendingPathComponent:path];
}

I'm not sure I understand the problem....


On 15 mai 07, at 01:06, Roland Silver wrote:

On Tue, 15 May 2007 00:38:19 -0400 Eric Jutras wrote:
-------------------------
From: Eric Jutras <email@hidden>
Subject: Re: paths for contents of a directory
To: Roland Silver <email@hidden>
Cc: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

Have you tried NSFileManager's
- (NSDirectoryEnumerator *)enumeratorAtPath:(NSString *)path

?


On 15 mai 07, at 00:32, Roland Silver wrote:

Given a string directoryPath which is a path to a directory, is
there some simple way to iterate over the members of the directory
which yields not just the file name of the member, but its complete
path name?

With this code:
	NSArray* directoryContents =
		[[NSFileManager defaultManager]
directoryContentsAtPath:directoryPath];
	NSString* path;
	NSEnumerator *enumerator = [directoryContents objectEnumerator];
	while (path = [enumerator nextObject]) {
	  ...
	}
the variable "path" (surprisingly) is bound to the file names of
the successive entries of the directory, rather than to their path
names -- which are what I need to extract the contents of the files
in the directory.
------------------------
Yes, I did try enumeratorAtPath, with the same result: it produces file names, not complete paths.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Re: paths for contents of a directory (From: Roland Silver <email@hidden>)

  • Prev by Date: Re: paths for contents of a directory
  • Next by Date: Re: NSDictionary valueForKey: and @ character at start of NSString
  • Previous by thread: Re: paths for contents of a directory
  • Next by thread: Re: paths for contents of a directory
  • Index(es):
    • Date
    • Thread