ObjFW  Check-in [0abd116830]

Overview
Comment:Rename -[initWith*Path:] to -[initWithPath:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0abd11683034d90f15a479655bb384804a23a3a49f3da1cddd44dd420fa57d65
User & Date: js on 2013-08-14 19:28:59
Other Links: manifest | tags
Context
2013-08-14
19:30
Rename +[archiveWithFile:] to +[archiveWithPath:]. check-in: 81f3ac43a6 user: js tags: trunk
19:28
Rename -[initWith*Path:] to -[initWithPath:]. check-in: 0abd116830 user: js tags: trunk
19:17
+[stringWithPath:] -> +[pathWithComponents:]. check-in: 7c4179ab9b user: js tags: trunk
Changes

Modified src/OFFile.m from [e0f0d0594a] to [6d3006c532].

249
250
251
252
253
254
255
256

257
258
259
260
261
262
263
249
250
251
252
253
254
255

256
257
258
259
260
261
262
263







-
+







#ifndef _WIN32
	if (mkdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    DIR_MODE))
#else
	if (_wmkdir([path UTF16String]))
#endif
		@throw [OFCreateDirectoryFailedException
		    exceptionWithDirectoryPath: path];
		    exceptionWithPath: path];
}

+ (void)createDirectoryAtPath: (OFString*)path
		createParents: (bool)createParents
{
	void *pool;
	OFArray *pathComponents;
381
382
383
384
385
386
387
388

389
390
391
392
393
394
395
381
382
383
384
385
386
387

388
389
390
391
392
393
394
395







-
+








#ifndef _WIN32
	if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wchdir([path UTF16String]))
#endif
		@throw [OFChangeCurrentDirectoryPathFailedException
		    exceptionWithDirectoryPath: path];
		    exceptionWithPath: path];
}

+ (off_t)sizeOfFileAtPath: (OFString*)path
{
	if (path == nil)
		@throw [OFInvalidArgumentException exception];

607
608
609
610
611
612
613
614

615
616
617
618
619
620
621
622
607
608
609
610
611
612
613

614

615
616
617
618
619
620
621







-
+
-







		@throw [OFInvalidArgumentException exception];

#ifndef _WIN32
	if (remove([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE]))
#else
	if (_wremove([path UTF16String]))
#endif
		@throw [OFRemoveItemFailedException
		@throw [OFRemoveItemFailedException exceptionWithPath: path];
		    exceptionWithItemPath: path];
}

#ifdef OF_HAVE_LINK
+ (void)linkItemAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	void *pool;

Modified src/exceptions/OFChangeCurrentDirectoryPathFailedException.h from [bcc7cfa1aa] to [5677a9d1f1].

20
21
22
23
24
25
26
27

28
29
30
31
32

33
34
35
36
37
38
39
40
41


42
43
44

45
46
47
48
49
50


51
52
53

54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70
20
21
22
23
24
25
26

27
28
29
30
31

32
33
34
35
36
37
38
39


40
41
42
43

44
45
46
47
48


49
50
51
52

53
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
70







-
+




-
+







-
-
+
+


-
+




-
-
+
+


-
+








-
+









/*!
 * @brief An exception indicating that changing the current directory path
 *	  failed.
 */
@interface OFChangeCurrentDirectoryPathFailedException: OFException
{
	OFString *_directoryPath;
	OFString *_path;
	int _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *directoryPath;
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased change current directory path failed
 *	  exception.
 *
 * @param directoryPath The path of the directory to which the current path
 *			could not be changed
 * @param path The path of the directory to which the current path could not be
 *	       changed
 * @return A new, autoreleased change current directory path failed exception
 */
+ (instancetype)exceptionWithDirectoryPath: (OFString*)directoryPath;
+ (instancetype)exceptionWithPath: (OFString*)path;

/*!
 * @brief Initializes an already allocated change directory failed exception.
 *
 * @param directoryPath The path of the directory to which the current path
 *			could not be changed
 * @param path The path of the directory to which the current path could not be
 *	       changed
 * @return An initialized change current directory path failed exception
 */
- initWithDirectoryPath: (OFString*)directoryPath;
- initWithPath: (OFString*)path;

/*!
 * @brief Returns the path of the directory to which the current path could not
 *	  be changed.
 *
 * @return The path of the directory to which the current path could not be
 *	   changed
 */
- (OFString*)directoryPath;
- (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFChangeCurrentDirectoryPathFailedException.m from [52bb583ba5] to [a962360020].

20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50

51
52
53
54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70
71

72
73
74

75
76

77
78
79
80
81
82
83
20
21
22
23
24
25
26

27
28

29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68
69

70
71
72

73
74

75
76
77
78
79
80
81
82







-
+

-
+
-














-
+




-
+











-
+








-
+


-
+

-
+








#import "OFChangeCurrentDirectoryPathFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFChangeCurrentDirectoryPathFailedException
+ (instancetype)exceptionWithDirectoryPath: (OFString*)directoryPath
+ (instancetype)exceptionWithPath: (OFString*)path
{
	return [[[self alloc]
	return [[[self alloc] initWithPath: path] autorelease];
	    initWithDirectoryPath: directoryPath] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithDirectoryPath: (OFString*)directoryPath
- initWithPath: (OFString*)path
{
	self = [super init];

	@try {
		_directoryPath = [directoryPath copy];
		_path = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_directoryPath release];
	[_path release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to change the current directory path to %@! " ERRFMT,
	    _directoryPath, ERRPARAM];
	    _path, ERRPARAM];
}

- (OFString*)directoryPath
- (OFString*)path
{
	OF_GETTER(_directoryPath, false)
	OF_GETTER(_path, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFCreateDirectoryFailedException.h from [b8aa2a86f9] to [5df77d0e78].

19
20
21
22
23
24
25
26

27
28
29
30
31

32
33
34
35
36
37
38
39


40
41
42

43
44
45
46
47
48


49
50
51

52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67
19
20
21
22
23
24
25

26
27
28
29
30

31
32
33
34
35
36
37


38
39
40
41

42
43
44
45
46


47
48
49
50

51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66
67







-
+




-
+






-
-
+
+


-
+




-
-
+
+


-
+







-
+








#import "OFException.h"

/*!
 * @brief An exception indicating a directory couldn't be created.
 */
@interface OFCreateDirectoryFailedException: OFException
{
	OFString *_directoryPath;
	OFString *_path;
	int _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *directoryPath;
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased create directory failed exception.
 *
 * @param directoryPath A string with the path of the directory which couldn't
 *			be created
 * @param path A string with the path of the directory which could not be
 *	       created
 * @return A new, autoreleased create directory failed exception
 */
+ (instancetype)exceptionWithDirectoryPath: (OFString*)directoryPath;
+ (instancetype)exceptionWithPath: (OFString*)path;

/*!
 * @brief Initializes an already allocated create directory failed exception.
 *
 * @param directoryPath A string with the path of the directory which couldn't
 *			be created
 * @param path A string with the path of the directory which could not be
 *	       created
 * @return An initialized create directory failed exception
 */
- initWithDirectoryPath: (OFString*)directoryPath;
- initWithPath: (OFString*)path;

/*!
 * @brief Returns a string with the path of the directory which couldn't be
 *	  created.
 *
 * @return A string with the path of the directory which couldn't be created
 */
- (OFString*)directoryPath;
- (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFCreateDirectoryFailedException.m from [31e546c773] to [afa7c99661].

20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50

51
52
53
54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70

71
72
73
74

75
76

77
78
79
80
81
82
83
20
21
22
23
24
25
26

27
28

29

30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68

69

70
71

72
73

74
75
76
77
78
79
80
81







-
+

-
+
-














-
+




-
+











-
+







-
+
-


-
+

-
+








#import "OFCreateDirectoryFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFCreateDirectoryFailedException
+ (instancetype)exceptionWithDirectoryPath: (OFString*)directoryPath
+ (instancetype)exceptionWithPath: (OFString*)path
{
	return [[[self alloc]
	return [[[self alloc] initWithPath: path] autorelease];
	    initWithDirectoryPath: directoryPath] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithDirectoryPath: (OFString*)directoryPath
- initWithPath: (OFString*)path
{
	self = [super init];

	@try {
		_directoryPath = [directoryPath copy];
		_path = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_directoryPath release];
	[_path release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to create directory %@! " ERRFMT,
	    @"Failed to create directory %@! " ERRFMT, _path, ERRPARAM];
	    _directoryPath, ERRPARAM];
}

- (OFString*)directoryPath
- (OFString*)path
{
	OF_GETTER(_directoryPath, false)
	OF_GETTER(_path, false)
}

- (int)errNo
{
	return _errNo;
}
@end

Modified src/exceptions/OFRemoveItemFailedException.h from [01ad7dd278] to [8b02487093].

19
20
21
22
23
24
25
26

27
28
29
30
31

32
33
34
35
36
37
38

39
40
41

42
43
44
45
46

47
48
49

50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
19
20
21
22
23
24
25

26
27
28
29
30

31
32
33
34
35
36
37

38
39
40

41
42
43
44
45

46
47
48

49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64







-
+




-
+






-
+


-
+




-
+


-
+






-
+








#import "OFException.h"

/*!
 * @brief An exception indicating that removing an item failed.
 */
@interface OFRemoveItemFailedException: OFException
{
	OFString *_itemPath;
	OFString *_path;
	int _errNo;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy, nonatomic) OFString *itemPath;
@property (readonly, copy, nonatomic) OFString *path;
@property (readonly) int errNo;
#endif

/*!
 * @brief Creates a new, autoreleased remove failed exception.
 *
 * @param itemPath The path of the item which could not be removed
 * @param path The path of the item which could not be removed
 * @return A new, autoreleased remove item failed exception
 */
+ (instancetype)exceptionWithItemPath: (OFString*)itemPath;
+ (instancetype)exceptionWithPath: (OFString*)path;

/*!
 * @brief Initializes an already allocated remove failed exception.
 *
 * @param itemPath The path of the item which could not be removed
 * @param path The path of the item which could not be removed
 * @return An initialized remove item failed exception
 */
- initWithItemPath: (OFString*)itemPath;
- initWithPath: (OFString*)path;

/*!
 * @brief Returns the path of the item which could not be removed.
 *
 * @return The path of the item which could not be removed
 */
- (OFString*)itemPath;
- (OFString*)path;

/*!
 * @brief Returns the errno from when the exception was created.
 *
 * @return The errno from when the exception was created
 */
- (int)errNo;
@end

Modified src/exceptions/OFRemoveItemFailedException.m from [8c04e72357] to [e961218ed3].

20
21
22
23
24
25
26
27

28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49

50
51
52
53
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
69

70
71
72

73
74

75
76
77
78
79
80
81
20
21
22
23
24
25
26

27
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48

49
50
51
52
53
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68

69
70
71

72
73

74
75
76
77
78
79
80
81







-
+

-
+














-
+




-
+











-
+







-
+


-
+

-
+








#import "OFRemoveItemFailedException.h"
#import "OFString.h"

#import "common.h"

@implementation OFRemoveItemFailedException
+ (instancetype)exceptionWithItemPath: (OFString*)itemPath
+ (instancetype)exceptionWithPath: (OFString*)path
{
	return [[[self alloc] initWithItemPath: itemPath] autorelease];
	return [[[self alloc] initWithPath: path] autorelease];
}

- init
{
	@try {
		[self doesNotRecognizeSelector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	abort();
}

- initWithItemPath: (OFString*)itemPath
- initWithPath: (OFString*)path
{
	self = [super init];

	@try {
		_itemPath = [itemPath copy];
		_path = [path copy];
		_errNo = GET_ERRNO;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_itemPath release];
	[_path release];

	[super dealloc];
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"Failed to remove item at path %@! " ERRFMT, _itemPath, ERRPARAM];
	    @"Failed to remove item at path %@! " ERRFMT, _path, ERRPARAM];
}

- (OFString*)itemPath
- (OFString*)path
{
	OF_GETTER(_itemPath, false)
	OF_GETTER(_path, false)
}

- (int)errNo
{
	return _errNo;
}
@end