String patches

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3072 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1998-10-15 13:46:35 +00:00
parent b56f5ae12e
commit 8c8a2b47ac
2 changed files with 68 additions and 3 deletions

View file

@ -29,6 +29,17 @@ Thu Oct 15 06:15:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
make simpler and more efficient.
* src/include/fast.x: Added fastZone()
Wed Oct 14 11:29:11 1998 Masatake Yamato <masata-y@is.aist-nara.ac.jp>
* src/NSString.m ([NSString -stringByResolvingSymlinksInPath]):
Implement.
Wed Oct 14 10:27:47 1998 Masatake Yamato <masata-y@is.aist-nara.ac.jp>
* src/NSString.m ([NSString +pathWithComponents:]):
Use the first object of components as the base path string
instead of null string([NSString string]).
Tue Oct 13 09:24:17 1998 Adam Fedor <fedor@doc.com>
* src/include/NSNotification.h: Addd placeholder in

View file

@ -2390,8 +2390,62 @@ else
- (NSString*) stringByResolvingSymlinksInPath
{
[self notImplemented:_cmd];
#if defined(__WIN32__) || defined(_WIN32)
return self;
#else
NSString *first_half = self, * second_half = @"";
const char * tmp_cpath;
const int MAX_PATH_LEN = 1024;
char tmp_buf[MAX_PATH_LEN];
int syscall_result;
struct stat tmp_stat;
while(1)
{
tmp_cpath = [first_half cString];
syscall_result = lstat(tmp_cpath, &tmp_stat);
if (0 != syscall_result) return self ;
if ((tmp_stat.st_mode & S_IFLNK) &&
((syscall_result = readlink(tmp_cpath, tmp_buf, MAX_PATH_LEN)) != -1))
{
/*
* first half is a path to a symbolic link.
*/
tmp_buf[syscall_result] = '\0'; // Make a C string
second_half = [[NSString stringWithCString: tmp_buf]
stringByAppendingPathComponent: second_half];
first_half = [first_half stringByDeletingLastPathComponent];
}
else
{
/*
* second_half is an absolute path
*/
if ([second_half hasPrefix: @"/"])
return [second_half stringByResolvingSymlinksInPath];
/*
* first half is NOT a path to a symbolic link
*/
second_half = [[first_half lastPathComponent]
stringByAppendingPathComponent: second_half];
first_half = [first_half stringByDeletingLastPathComponent];
}
/* BREAK CONDITION */
if ([first_half length] == 0) break;
else if ([first_half isEqual: @"/"])
{
second_half = [@"/" stringByAppendingPathComponent: second_half];
break;
}
}
return second_half;
#endif /* (__WIN32__) || (_WIN32) */
}
- (NSString*) stringByStandardizingPath
@ -2477,10 +2531,10 @@ else
// #ifndef STRICT_OPENSTEP
+ (NSString*) pathWithComponents: (NSArray*)components
{
NSString *s = [self string];
NSString *s = [components objectAtIndex: 0];
int i;
for (i = 0; i < [components count]; i++) {
for (i = 1; i < [components count]; i++) {
s = [s stringByAppendingPathComponent: [components objectAtIndex: i]];
}
return s;