Re: NSFileManager miscount
Re: NSFileManager miscount
- Subject: Re: NSFileManager miscount
- From: John Stokes <email@hidden>
- Date: Tue, 11 Mar 2003 16:33:25 -0800
OK, I feel like a complete ninny.
Yes, the .DS_Store issue was the problem. Somehow I got it in my head that
ls -l displayed hidden files in addition to permissions.
I warned you that I might ask dumb questions! 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.