mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 12:16:40 +00:00
More NSURL fixup.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14324 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
37a80c5e5a
commit
747659be09
2 changed files with 23 additions and 22 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2002-08-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSURL.m: ([-initFileURLWithPath:]) check to see if path is
|
||||||
|
a directory and append a trailing slash if necessary. Remove hack
|
||||||
|
to refrain from stripping last patch component in file URLs.
|
||||||
|
|
||||||
2002-08-24 Richard Frith-Macdonald <rfm@gnu.org>
|
2002-08-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSURL.m: Hacks for compatibility with MacOS-X in returning
|
* Source/NSURL.m: Hacks for compatibility with MacOS-X in returning
|
||||||
|
|
|
@ -43,6 +43,7 @@ function may be incorrect
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
#include <Foundation/NSFileManager.h>
|
||||||
#include <Foundation/NSConcreteNumber.h>
|
#include <Foundation/NSConcreteNumber.h>
|
||||||
#include <Foundation/NSLock.h>
|
#include <Foundation/NSLock.h>
|
||||||
#include <Foundation/NSMapTable.h>
|
#include <Foundation/NSMapTable.h>
|
||||||
|
@ -211,26 +212,7 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *start = base->path;
|
char *start = base->path;
|
||||||
char *end;
|
char *end = strrchr(start, '/');
|
||||||
|
|
||||||
/*
|
|
||||||
* Evil hack for MacOS-X compatibility.
|
|
||||||
* RFCs state that '/foo/bar' combined with 'xxx'
|
|
||||||
* gives '/foo/xxx', but MacOS-X treats file URLs
|
|
||||||
* differently and returns '/foo/bar/xxx'
|
|
||||||
*/
|
|
||||||
if (rel->isFile == YES)
|
|
||||||
{
|
|
||||||
end = &start[strlen(start)];
|
|
||||||
if (end > start && end[-1] == '/')
|
|
||||||
{
|
|
||||||
end--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
end = strrchr(start, '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end != 0)
|
if (end != 0)
|
||||||
{
|
{
|
||||||
|
@ -575,11 +557,24 @@ static void unescape(const char *from, char * to)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise as a file URL with the specified path.<br />
|
* Initialise as a file URL with the specified path (which must
|
||||||
* Calls -initWithString:relativeToURL:
|
* be a valid path on the local filesystem).<br />
|
||||||
|
* Appends a trailing slash to the path when necessary if it
|
||||||
|
* specifies a directory.<br />
|
||||||
|
* Calls -initWithScheme:host:path:
|
||||||
*/
|
*/
|
||||||
- (id) initFileURLWithPath: (NSString*)aPath
|
- (id) initFileURLWithPath: (NSString*)aPath
|
||||||
{
|
{
|
||||||
|
if ([aPath hasSuffix: @"/"] == NO)
|
||||||
|
{
|
||||||
|
BOOL flag = NO;
|
||||||
|
|
||||||
|
if ([[NSFileManager defaultManager] fileExistsAtPath: aPath
|
||||||
|
isDirectory: &flag] == YES && flag == YES)
|
||||||
|
{
|
||||||
|
aPath = [aPath stringByAppendingString: @"/"];
|
||||||
|
}
|
||||||
|
}
|
||||||
self = [self initWithScheme: NSURLFileScheme
|
self = [self initWithScheme: NSURLFileScheme
|
||||||
host: nil
|
host: nil
|
||||||
path: aPath];
|
path: aPath];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue