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

Very simple - UNIX like - filename expansion?


  • Subject: Very simple - UNIX like - filename expansion?
  • From: Marten van Gelderen <email@hidden>
  • Date: Thu, 26 Feb 2004 16:17:45 +0100

Dear All,

I needed a very simple - UNIX like - filename expansion in my App. It just had to accept a star as last character in an absolute path. So I implemented:

@implementation NSString (MvG_PathExtensions)

- (NSString *)stringByDeletingSuffix:(NSString *)suffix
{
return [self hasSuffix: suffix] ? [self substringToIndex: [self length] - [suffix length]] : self;
}

- (NSString *)stringByExpandingStarInPath
{
NSString *string;
return ([[self stringByDeletingSuffix: @"*"]
completePathIntoString: &string caseSensitive: YES matchesIntoArray: NULL filterTypes: NULL] > 0) ? string : self;
}

@end

This almost works, except for the case where the matching directory contains only one subdirectory. It then goes "one level" too far. I do understand that this is the consequence of the "completePath..." message which returns the "longest match" etc. etc.

My question is: am I on the right track and should I make "-stringByExpandingStarInPath" a little smarter or is there an alternative way/package/category that I am not aware of?

Thanks in advance...
--
Groeten, Marten
_______________________________________________
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: Very simple - UNIX like - filename expansion?
      • From: Daniel Todd Currie <email@hidden>
  • Prev by Date: Re: Line numbers in IDE
  • Next by Date: Re: Problems with Distributed Objects
  • Previous by thread: Re: Setting windows attrubutes to use applicationShouldTerminateAfterLastWindowClosed:
  • Next by thread: Re: Very simple - UNIX like - filename expansion?
  • Index(es):
    • Date
    • Thread