• 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: NSFileManager miscount
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileManager miscount


  • Subject: Re: NSFileManager miscount
  • From: John Stokes <email@hidden>
  • Date: Tue, 11 Mar 2003 11:21:00 -0800

Hmmm...

I meant to try NSDirectoryEnumerator, but had forgotten that option. Thanks
for the reminder.

I checked into the .DS_Store issue by going to the command line to access
the directory (bypassing the Finder). The presence or absence of .DS_Store
doesn't seem to have any bearing on it - the behavior is the the same. It
will report the directory count as 4, even though a command line ls -l
reports only 3 files.

And I did have some reason why I needed counter<=totalGroups instead of just
counter<totalGroups, though I've forgotten it, now.

Thanks for the help!

-John

On 3/11/03 10:58 AM, "Chris Ridd" <email@hidden> wrote:

> On 11/3/03 6:12 pm, John Stokes <email@hidden> wrote:
>> for(counter=0;counter<=totalGroups;counter++) {
>
> Hm, that should be 'counter < totalGroups' otherwise you're looping 4 times
> when totalGroups is 3.
>
>> -Here's my problem: After creating the directory programmatically, if I have
>> 3 files in the directory, "totalGroups" = 3. So far, so good.
>>
>> BUT, if I access the directory using the Finder, and then re-run my program,
>> suddenly "totalGroups" = 4. This results in my program creating an extra,
>
> Because the Finder has created a file called .DS_Store inside your
> directory?
>
>> Why? How do I get around this?
>
> Instead of using directoryContentsAtPath and counting the results, use
> enumeratorAtPath: and ignore .DS_Store if you see it. From the example in
> NSFileManager's docs:
>
> NSString *file;
> NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager]
> enumeratorAtPath:@"/MyAccount/Documents"];
> while (file = [enumerator nextObject]) {
> if (![file isEqualToString:@".DS_Store"]) {
> // do something
> }
> }
>
> Cheers,
>
> Chris
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.

--
-John Stokes
Computer Psychiatrist (Director of Information Technology)
Church Resource Ministries
email@hidden

Three Pillars: Humility, Communication, Balance
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSFileManager miscount
      • From: Andy Lee <email@hidden>
    • Re: NSFileManager miscount
      • From: Sherm Pendley <email@hidden>
References: 
 >Re: NSFileManager miscount (From: Chris Ridd <email@hidden>)

  • Prev by Date: RE: Accessing IB objects
  • Next by Date: NSWorkspace getFileSystemInfoForPath:...
  • Previous by thread: Re: NSFileManager miscount
  • Next by thread: Re: NSFileManager miscount
  • Index(es):
    • Date
    • Thread