Implement completePathIntoString

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3073 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1998-10-15 18:46:27 +00:00
parent 8c8a2b47ac
commit d52a07b1b3
3 changed files with 51 additions and 7 deletions

View file

@ -1,3 +1,9 @@
Thu Oct 15 08:13:12 1998 Masatake Yamato <masata-y@is.aist-nara.ac.jp>
* src/NSString.m ([NSString
-completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:]):
Implement.
Thu Oct 15 06:15:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/BinaryCStream.m: Update system version number

View file

@ -10,8 +10,8 @@
@itemize @bullet
@item Fix NSZoneFromPointer (when given a pointer to malloced memory), and
NSRecycleZone (to tramsfer 'live' objects to the default zone). [4] (980805).
@item @emph{Fix NSZoneFromPointer (when given a pointer to malloced memory), and
NSRecycleZone (to tramsfer 'live' objects to the default zone).} [4] (980805).
@item Implement Formatter classes (NSDateFormatter, etc) [5] (980722).
@ -28,8 +28,6 @@ NSRecycleZone (to tramsfer 'live' objects to the default zone). [4] (980805).
@item Improve initWithFormat releated methods for NSString and find out how to implemente the locale stuff [4 OPENSTEP/Rhapsody] (980712)
@item Finish implementing the filesystem related NSString methods [3] (980712)
@item Make gstep-base 64bit clean [5, 64bit machine] (980629)
@item Make gstep-base smaller. Perhaps we can get rid of classes that

View file

@ -49,6 +49,8 @@
#include <Foundation/NSValue.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSFileManager.h>
#include <gnustep/base/IndexedCollection.h>
#include <Foundation/NSData.h>
#include <Foundation/NSBundle.h>
@ -2141,14 +2143,52 @@ else
// Manipulating File System Paths
- (unsigned int) completePathIntoString: (NSString**)outputName
caseSensitive: (BOOL)flag
matchesIntoArray: (NSArray**)outputArray
filterTypes: (NSArray*)filterTypes
{
[self notImplemented:_cmd];
return 0;
NSString * base_path = [self stringByDeletingLastPathComponent];
NSString * last_compo = [self lastPathComponent];
NSString * tmp_path;
NSDirectoryEnumerator * e;
int match_count = 0;
if (outputName != NULL) *outputName = nil;
if ([base_path length] == 0) base_path = @".";
e = [[NSFileManager defaultManager] enumeratorAtPath: base_path];
while (tmp_path = [e nextObject], tmp_path)
{
/* Prefix matching */
if (YES == flag)
{ /* Case sensitive */
if (NO == [tmp_path hasPrefix: last_compo])
continue ;
}
else
{
if (NO == [[tmp_path uppercaseString]
hasPrefix: [last_compo uppercaseString]])
continue;
}
/* Extensions filtering */
if (filterTypes &&
(NO == [filterTypes containsObject: [tmp_path pathExtension]]))
continue ;
/* Found a completion */
match_count++;
if (outputArray != NULL)
[*outputArray addObject: tmp_path];
if ((outputName != NULL) &&
((*outputName == nil) || (([*outputName length] < [tmp_path length]))))
*outputName = tmp_path;
}
return match_count;
}
/* Return a string for passing to OS calls to handle file system objects. */