Merge pull request #154 from triplef/nsurl-additions

Add various NSURL methods.
This commit is contained in:
rfm 2020-11-06 09:38:16 +00:00 committed by GitHub
commit 95a71ea552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 1 deletions

View file

@ -1,3 +1,12 @@
2020-10-06-03 Frederik Seiffert <frederik@algoriddim.com>
* Headers/Foundation/NSURL.h,
* Source/NSURL.h: Add NSURL methods:
- URLByAppendingPathComponent:isDirectory:
- isFileReferenceURL (always returns NO)
- fileReferenceURL
- filePathURL
2020-08-30 Fred Kiefer <fredkiefer@gmx.de>
* Source/NSDateComponentsFormatter.m: Fix use of wrong operator.

View file

@ -411,7 +411,23 @@ enum
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
/** Returns a URL formed by adding a path component to the path of the
* receiver, along with a trailing slash if the component is designated a
* directory.<br />
* See [NSString-stringByAppendingPathComponent:].
*/
- (NSURL *) URLByAppendingPathComponent:(NSString *)pathComponent
isDirectory:(BOOL)isDirectory;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
- (BOOL) isFileReferenceURL;
- (NSURL *) fileReferenceURL;
- (NSURL *) filePathURL;
- (BOOL) getResourceValue: (id*)value
forKey: (NSString *)key
error: (NSError**)error;

View file

@ -774,7 +774,6 @@ NSURL:
- stopAccessingSecurityScopedResource
- stringByAddingPercentEscapesUsingEncoding:
- stringByReplacingPercentEscapesUsingEncoding:
- URLByAppendingPathComponent:isDirectory:
-------------------------------------------------------------
NSURLAuthenticationChallenge:
- performDefaultHandlingForAuthenticationChallenge:

View file

@ -1539,6 +1539,29 @@ static NSUInteger urlAlign;
return [[self path] lastPathComponent];
}
- (BOOL) isFileReferenceURL
{
return NO;
}
- (NSURL *) fileReferenceURL
{
if ([self isFileURL])
{
return self;
}
return nil;
}
- (NSURL *) filePathURL
{
if ([self isFileURL])
{
return self;
}
return nil;
}
- (BOOL) getResourceValue: (id*)value
forKey: (NSString *)key
error: (NSError**)error
@ -1951,6 +1974,17 @@ static NSUInteger urlAlign;
return self;
}
- (NSURL *) URLByAppendingPathComponent:(NSString *)pathComponent
isDirectory:(BOOL)isDirectory
{
NSString *path = [[self path] stringByAppendingPathComponent: pathComponent];
if (isDirectory)
{
path = [path stringByAppendingString: @"/"];
}
return [self _URLBySettingPath: path];
}
- (void) URLHandle: (NSURLHandle*)sender
resourceDataDidBecomeAvailable: (NSData*)newData
{