Re: Very simple - UNIX like - filename expansion?
Re: Very simple - UNIX like - filename expansion?
- Subject: Re: Very simple - UNIX like - filename expansion?
- From: Daniel Todd Currie <email@hidden>
- Date: Thu, 26 Feb 2004 13:32:44 -0800
I have an open-source class that deals with path auto-completion that
you may find helpful:
http://los.dtcurrie.net/code/
My solution for some of these issues is significantly more complicated
than what you present here, but it is also somewhat more robust. Hope
this helps.
-- Daniel
On 2004 Feb 26, at 07:17, Marten van Gelderen wrote:
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.
_______________________________________________
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.