Thanks for all the input.  I am doing x-platform development and we like to 
keep mainline code identical so I implemented functions _findfirst and 
_findnext using NSFileManager ... it work s pretty cool as follows:



intptr_t _findfirst(CString search, _finddata_t *data)
{
        intptr_t rtx = 0;
        _breakdown(search);
        if([results count])
        {
                const char* name = [[results objectAtIndex:0] 
cStringUsingEncoding:NSUTF8StringEncoding];
                strcpy(data->name,name);
                rtx = 1;
        }
        return rtx;
}

int _findnext(intptr_t& next, _finddata_t *data)
{
        int rtx = 0;
        if(next < [results count])
        {
                const char* name = [[results objectAtIndex:next] 
cStringUsingEncoding:NSUTF8StringEncoding];
                strcpy(data->name,name);
                next++;
        }
        else rtx = 1;
        return rtx;
}

void _breakdown(CString search)
{       
        nssearch = [NSString stringWithCString:(const char*)search 
encoding:NSUTF8StringEncoding];
        path = [nssearch stringByDeletingLastPathComponent];
        fileManager = [NSFileManager defaultManager];
        directoryContents = [fileManager contentsOfDirectoryAtPath:path 
error:&error];
        lastPathComponent = [nssearch lastPathComponent];
        predicate = [NSPredicate predicateWithFormat:@"SELF like [c] %@", 
lastPathComponent];
        results = [directoryContents filteredArrayUsingPredicate:predicate];
}
On Oct 5, 2011, at 3:13 PM, Lee Ann Rucker wrote:

> [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:aPath error:NULL]  
> pathsMatchingExtensions:anArrayOfExtensions]
> 
> On Oct 5, 2011, at 2:07 PM, Kyle Sluder wrote:
> 
>> On Wed, Oct 5, 2011 at 1:31 PM, koko <k...@highrolls.net> wrote:
>>> Is there a best way to get thins done with NSFileManager?
>> 
>> NSFileManager has no concept of file extension patterns like Windows
>> does. If you really need to find all files that have the extension
>> ".exe", then you can do a simple loop and comparison. If what you
>> really want to do is find all files of a certain type, you should use
>> UTIs instead.
>> 
>> --Kyle Sluder
>> _______________________________________________
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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/lrucker%40vmware.com
>> 
>> This email sent to lruc...@vmware.com
> 
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to