• 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: Very simple - UNIX like - filename expansion?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very simple - UNIX like - filename expansion?


  • Subject: Re: Very simple - UNIX like - filename expansion?
  • From: glenn andreas <email@hidden>
  • Date: Mon, 23 May 2005 15:57:42 -0500


On May 23, 2005, at 2:52 PM, Joshua Minor wrote:

Marten van Gelderen wrote:

 I needed a very simple - UNIX like - filename expansion in my App


I suggest wrapping the POSIX glob function like this:

If all you need is really simple (starts with a string, and has an optional extensions - your basic "foo*.[ch]" sort of thing), you can also just use NSString's:


completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:
- (unsigned)completePathIntoString:(NSString **)outputName caseSensitive:(BOOL)flag matchesIntoArray:(NSArray **)outputArray filterTypes:(NSArray *)filterTypes


Attempts to perform filename completion on the receiver, interpreting it as a path in the file system and returning the longest path that matches the receiver by reference in outputName. Considers case if flag is YES. If outputArray is non-NULL, returns all matching filenames in an NSArray given by outputArray. If an array of strings is provided in filterTypes, considers only paths whose extensions (not including the extension separator) match one of those strings.
Returns 0 if no matches are found and 1 if exactly one match is found. In the case of multiple matches, returns the actual number of matching paths if outputArray is provided, or simply a positive value if outputArray is NULL. Hence, you can check for the existence of matches without retrieving by passing NULL as outputArray.



(A routine that strangely enough never noticed until this weekend and really could have used in the past)



Glenn Andreas email@hidden <http://www.gandreas.com/> oh my! quadrium | build, mutate, evolve | images, textures, backgrounds, art

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Very simple - UNIX like - filename expansion? (From: Joshua Minor <email@hidden>)

  • Prev by Date: Re: How to get an NSWindow from an NSDocument?
  • Next by Date: NSImage size?
  • Previous by thread: Re: Very simple - UNIX like - filename expansion?
  • Next by thread: ~/library/application support/myapp directory creation
  • Index(es):
    • Date
    • Thread