ObjFW  Check-in [7f64141183]

Overview
Comment:Add -[OFURL pathComponents]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7f641411835601735ea952239391fd9750fe20515c42c193df0b7fafe125835c
User & Date: js on 2017-10-29 13:37:03
Other Links: manifest | tags
Context
2017-10-29
15:05
Add -[OFURL lastPathComponent] check-in: eba3667137 user: js tags: trunk
13:37
Add -[OFURL pathComponents] check-in: 7f64141183 user: js tags: trunk
11:25
Add +[OFURL fileURLWithPath:isDirectory:] check-in: 773997d072 user: js tags: trunk
Changes

Modified src/OFMutableURL.h from [5b759a7789] to [4ea68f1b3c].

80
81
82
83
84
85
86










87
88
89
90
91
92
93
/*!
 * @brief Initializes an already allocated OFMutableURL.
 *
 * @return An initialized OFMutableURL
 */
- (instancetype)init;











/*!
 * @brief Converts the mutable URL to an immutable URL.
 */
- (void)makeImmutable;
@end

OF_ASSUME_NONNULL_END







>
>
>
>
>
>
>
>
>
>







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*!
 * @brief Initializes an already allocated OFMutableURL.
 *
 * @return An initialized OFMutableURL
 */
- (instancetype)init;

/*!
 * @brief Sets the URL's path from the specified path components.
 *
 * The first component must always be empty to designate the root.
 *
 * @param components The path components to set the URL's path from
 */
- (void)setPathComponents:
    (nullable OFArray OF_GENERIC(OFString *) *)components;

/*!
 * @brief Converts the mutable URL to an immutable URL.
 */
- (void)makeImmutable;
@end

OF_ASSUME_NONNULL_END

Modified src/OFMutableURL.m from [514dff27bb] to [5d3d519f50].

13
14
15
16
17
18
19
20
21
22



23
24
25
26
27
28
29
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFMutableURL.h"
#import "OFURL+Private.h"
#import "OFNumber.h"
#import "OFString.h"




@implementation OFMutableURL
@dynamic scheme, host, port, user, password, path, parameters, query, fragment;

+ (instancetype)URL
{
	return [[[self alloc] init] autorelease];







|


>
>
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFMutableURL.h"
#import "OFArray.h"
#import "OFNumber.h"
#import "OFString.h"
#import "OFURL+Private.h"

#import "OFInvalidFormatException.h"

@implementation OFMutableURL
@dynamic scheme, host, port, user, password, path, parameters, query, fragment;

+ (instancetype)URL
{
	return [[[self alloc] init] autorelease];
92
93
94
95
96
97
98




















99
100
101
102
103
104
105

- (void)setFragment: (OFString *)fragment
{
	OFString *old = _fragment;
	_fragment = [fragment copy];
	[old release];
}





















- (id)copy
{
	OFMutableURL *copy = [self mutableCopy];

	[copy makeImmutable];








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

- (void)setFragment: (OFString *)fragment
{
	OFString *old = _fragment;
	_fragment = [fragment copy];
	[old release];
}

- (void)setPathComponents: (OFArray *)components
{
	void *pool = objc_autoreleasePoolPush();

	if (components == nil) {
		[self setPath: nil];
		return;
	}

	if ([components count] == 0)
		@throw [OFInvalidFormatException exception];

	if ([[components firstObject] length] != 0)
		@throw [OFInvalidFormatException exception];

	[self setPath: [components componentsJoinedByString: @"/"]];

	objc_autoreleasePoolPop(pool);
}

- (id)copy
{
	OFMutableURL *copy = [self mutableCopy];

	[copy makeImmutable];

Modified src/OFURL.h from [76db36b252] to [9597f5d99f].

15
16
17
18
19
20
21

22
23
24
25
26
27
28
 */

#import "OFObject.h"
#import "OFSerialization.h"

OF_ASSUME_NONNULL_BEGIN


@class OFNumber;
@class OFString;

/*!
 * @class OFURL OFURL.h ObjFW/OFURL.h
 *
 * @brief A class for parsing URLs and accessing parts of it.







>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 */

#import "OFObject.h"
#import "OFSerialization.h"

OF_ASSUME_NONNULL_BEGIN

@class OFArray OF_GENERIC(ObjectType);
@class OFNumber;
@class OFString;

/*!
 * @class OFURL OFURL.h ObjFW/OFURL.h
 *
 * @brief A class for parsing URLs and accessing parts of it.
174
175
176
177
178
179
180









181
182
183
184
185
186
187
/*!
 * @brief Returns the URL as a string.
 *
 * @return The URL as a string
 */
- (OFString *)string;










/*!
 * @brief Returns the local file system representation for a file URL.
 *
 * This only exists for URLs with the file scheme and throws an exception
 * otherwise.
 *
 * @return The local file system representation for a file URL







>
>
>
>
>
>
>
>
>







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*!
 * @brief Returns the URL as a string.
 *
 * @return The URL as a string
 */
- (OFString *)string;

/*!
 * @brief Returns the path of the URL split into components.
 *
 * The first component is always empty to designate the root.
 *
 * @return The path of the URL split into components
 */
- (nullable OFArray OF_GENERIC(OFString *) *)pathComponents;

/*!
 * @brief Returns the local file system representation for a file URL.
 *
 * This only exists for URLs with the file scheme and throws an exception
 * otherwise.
 *
 * @return The local file system representation for a file URL

Modified src/OFURL.m from [47b11362db] to [c329b07d23].

518
519
520
521
522
523
524





525
526
527
528
529
530
531

	objc_autoreleasePoolPop(pool);

	[ret makeImmutable];

	return ret;
}






- (OFString *)fileSystemRepresentation
{
	void *pool = objc_autoreleasePoolPush();
	OFString *path;

	if (![_scheme isEqual: @"file"])







>
>
>
>
>







518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536

	objc_autoreleasePoolPop(pool);

	[ret makeImmutable];

	return ret;
}

- (OFArray *)pathComponents
{
	return [_path componentsSeparatedByString: @"/"];
}

- (OFString *)fileSystemRepresentation
{
	void *pool = objc_autoreleasePoolPush();
	OFString *path;

	if (![_scheme isEqual: @"file"])