ObjFW  Check-in [768b31dede]

Overview
Comment:Add support for hardlinks and symlinks on Windows
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 768b31dede33c0c0ed495e9d4b76ba1ccd74709bfa00f1178fb0bdb898990389
User & Date: js on 2016-07-03 22:40:35
Other Links: manifest | tags
Context
2016-07-04
19:36
Remove check for objc_enumerationMutation check-in: 32d092b9ba user: js tags: trunk
2016-07-03
22:40
Add support for hardlinks and symlinks on Windows check-in: 768b31dede user: js tags: trunk
19:38
-[pathComponents]: Include drive in 1st component check-in: 541aab7a03 user: js tags: trunk
Changes

Modified configure.ac from [8a62215e9e] to [9b304b3c2a].

804
805
806
807
808
809
810



811
812
813
814
815
816
817
	])
	AC_CHECK_FUNC(link, [
		AC_DEFINE(OF_HAVE_LINK, 1, [Whether we have link()])
	])
	AC_CHECK_FUNC(symlink, [
		AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()])
	])



	AC_CHECK_FUNCS([lstat readdir_r])
])

AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep fcntl])

AC_CHECK_FUNC(pipe, [
	AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()])







>
>
>







804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
	])
	AC_CHECK_FUNC(link, [
		AC_DEFINE(OF_HAVE_LINK, 1, [Whether we have link()])
	])
	AC_CHECK_FUNC(symlink, [
		AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()])
	])
	AC_CHECK_FUNC(readlink, [
		AC_DEFINE(OF_HAVE_READLINK, 1, [Whether we have readlink()])
	])
	AC_CHECK_FUNCS([lstat readdir_r])
])

AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep fcntl])

AC_CHECK_FUNC(pipe, [
	AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()])

Modified src/OFFileManager.h from [8d6a926fea] to [0fb12497fc].

223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253



254
255
256
257
258
259
260
261

262

263
264
265
266
267
268
269
270
271
272
273
274
 *
 * If the item at the specified path is a directory, it is removed recursively.
 *
 * @param path The path to the item which should be removed
 */
- (void)removeItemAtPath: (OFString*)path;

#ifdef OF_HAVE_LINK
/*!
 * @brief Creates a hard link for the specified item.
 *
 * The destination path must be a full path, which means it must include the
 * name of the item.
 *
 * This method is not available on some systems, most notably Windows.
 *
 * @param source The path to the item for which a link should be created
 * @param destination The path to the item which should link to the source
 */
- (void)linkItemAtPath: (OFString*)source
		toPath: (OFString*)destination;
#endif

#ifdef OF_HAVE_SYMLINK
/*!
 * @brief Creates a symbolic link for an item.
 *
 * The destination path must be a full path, which means it must include the
 * name of the item.
 *
 * This method is not available on some systems, most notably Windows.



 *
 * @param destination The path to the item which should symbolically link to the
 *		      source
 * @param source The path to the item for which a symbolic link should be
 *		 created
 */
- (void)createSymbolicLinkAtPath: (OFString*)destination
	     withDestinationPath: (OFString*)source;



/*!
 * @brief Returns the destination of the symbolic link at the specified path.
 *
 * @param path The path to the symbolic link
 *
 * @return The destination of the symbolic link at the specified path
 */
- (OFString*)destinationOfSymbolicLinkAtPath: (OFString*)path;
#endif
@end

OF_ASSUME_NONNULL_END







|






|








|






|
>
>
>








>

>












223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
 *
 * If the item at the specified path is a directory, it is removed recursively.
 *
 * @param path The path to the item which should be removed
 */
- (void)removeItemAtPath: (OFString*)path;

#if defined(OF_HAVE_LINK) || defined(OF_WINDOWS)
/*!
 * @brief Creates a hard link for the specified item.
 *
 * The destination path must be a full path, which means it must include the
 * name of the item.
 *
 * This method is not available on some systems.
 *
 * @param source The path to the item for which a link should be created
 * @param destination The path to the item which should link to the source
 */
- (void)linkItemAtPath: (OFString*)source
		toPath: (OFString*)destination;
#endif

#if defined(OF_HAVE_SYMLINK) || defined(OF_WINDOWS)
/*!
 * @brief Creates a symbolic link for an item.
 *
 * The destination path must be a full path, which means it must include the
 * name of the item.
 *
 * This method is not available on some systems.
 *
 * @note On Windows, this requires at least Windows Vista and administrator
 *	 privileges!
 *
 * @param destination The path to the item which should symbolically link to the
 *		      source
 * @param source The path to the item for which a symbolic link should be
 *		 created
 */
- (void)createSymbolicLinkAtPath: (OFString*)destination
	     withDestinationPath: (OFString*)source;
#endif

#if defined(OF_HAVE_READLINK)
/*!
 * @brief Returns the destination of the symbolic link at the specified path.
 *
 * @param path The path to the symbolic link
 *
 * @return The destination of the symbolic link at the specified path
 */
- (OFString*)destinationOfSymbolicLinkAtPath: (OFString*)path;
#endif
@end

OF_ASSUME_NONNULL_END

Modified src/OFFileManager.m from [828aa0d8f5] to [d13c205905].

46
47
48
49
50
51
52

53
54
55
56
57
58
59
#import "OFCreateDirectoryFailedException.h"
#import "OFCreateSymbolicLinkFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFLinkFailedException.h"
#import "OFLockFailedException.h"
#import "OFMoveItemFailedException.h"

#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFReadFailedException.h"
#import "OFRemoveItemFailedException.h"
#import "OFStatItemFailedException.h"
#import "OFUnlockFailedException.h"








>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import "OFCreateDirectoryFailedException.h"
#import "OFCreateSymbolicLinkFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFLinkFailedException.h"
#import "OFLockFailedException.h"
#import "OFMoveItemFailedException.h"
#import "OFNotImplementedException.h"
#import "OFOpenItemFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFReadFailedException.h"
#import "OFRemoveItemFailedException.h"
#import "OFStatItemFailedException.h"
#import "OFUnlockFailedException.h"

82
83
84
85
86
87
88




89
90
91
92
93
94
95

#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
static OFMutex *passwdMutex;
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
static OFMutex *readdirMutex;
#endif





int
of_stat(OFString *path, of_stat_t *buffer)
{
#if defined(OF_WINDOWS)
	return _wstat64([path UTF16String], buffer);
#elif defined(OF_HAVE_OFF64_T)







>
>
>
>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
static OFMutex *passwdMutex;
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
static OFMutex *readdirMutex;
#endif

#ifdef OF_WINDOWS
static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD);
#endif

int
of_stat(OFString *path, of_stat_t *buffer)
{
#if defined(OF_WINDOWS)
	return _wstat64([path UTF16String], buffer);
#elif defined(OF_HAVE_OFF64_T)
124
125
126
127
128
129
130




131
132
133
134
135
136
137
138
139
140
141
142
143
144
145







146
147
148
149
150
151
152
# endif
#endif
}

@implementation OFFileManager
+ (void)initialize
{




	if (self != [OFFileManager class])
		return;

	/*
	 * Make sure OFFile is initialized.
	 * On some systems, this is needed to initialize the file system driver.
	 */
	[OFFile class];

#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
	passwdMutex = [[OFMutex alloc] init];
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
	readdirMutex = [[OFMutex alloc] init];
#endif








	defaultManager = [[OFFileManager alloc] init];
}

+ (OFFileManager*)defaultManager
{
	return defaultManager;







>
>
>
>















>
>
>
>
>
>
>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# endif
#endif
}

@implementation OFFileManager
+ (void)initialize
{
#ifdef OF_WINDOWS
	HMODULE module;
#endif

	if (self != [OFFileManager class])
		return;

	/*
	 * Make sure OFFile is initialized.
	 * On some systems, this is needed to initialize the file system driver.
	 */
	[OFFile class];

#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
	passwdMutex = [[OFMutex alloc] init];
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
	readdirMutex = [[OFMutex alloc] init];
#endif

#ifdef OF_WINDOWS
	if ((module = LoadLibrary("kernel32.dll")) != NULL)
		func_CreateSymbolicLinkW =
		    (WINAPI BOOLEAN (*)(LPCWSTR, LPCWSTR, DWORD))
		    GetProcAddress(module, "CreateSymbolicLinkW");
#endif

	defaultManager = [[OFFileManager alloc] init];
}

+ (OFFileManager*)defaultManager
{
	return defaultManager;
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
			    exceptionWithPath: path
					errNo: errno];
	}

	objc_autoreleasePoolPop(pool);
}

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

	if (source == nil || destination == nil)







|







887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
			    exceptionWithPath: path
					errNo: errno];
	}

	objc_autoreleasePoolPop(pool);
}

#if defined(OF_HAVE_LINK)
- (void)linkItemAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	void *pool;
	of_string_encoding_t encoding;

	if (source == nil || destination == nil)
893
894
895
896
897
898
899



















900
901
902
903
904
905
906
907
908
909
		@throw [OFLinkFailedException
		    exceptionWithSourcePath: source
			    destinationPath: destination
				      errNo: errno];

	objc_autoreleasePoolPop(pool);
}



















#endif

#ifdef OF_HAVE_SYMLINK
- (void)createSymbolicLinkAtPath: (OFString*)destination
	     withDestinationPath: (OFString*)source
{
	void *pool;
	of_string_encoding_t encoding;

	if (source == nil || destination == nil)







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


|







909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
		@throw [OFLinkFailedException
		    exceptionWithSourcePath: source
			    destinationPath: destination
				      errNo: errno];

	objc_autoreleasePoolPop(pool);
}
#else
- (void)linkItemAtPath: (OFString*)source
		toPath: (OFString*)destination
{
	void *pool;

	if (source == nil || destination == nil)
		@throw [OFInvalidArgumentException exception];

	pool = objc_autoreleasePoolPush();

	if (!CreateHardLinkW([destination UTF16String],
	    [source UTF16String], NULL))
		@throw [OFLinkFailedException
		    exceptionWithSourcePath: source
			    destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}
#endif

#if defined(OF_HAVE_SYMLINK)
- (void)createSymbolicLinkAtPath: (OFString*)destination
	     withDestinationPath: (OFString*)source
{
	void *pool;
	of_string_encoding_t encoding;

	if (source == nil || destination == nil)
917
918
919
920
921
922
923



924






















925
926
927
928
929
930
931
		@throw [OFCreateSymbolicLinkFailedException
		    exceptionWithSourcePath: source
			    destinationPath: destination
				      errNo: errno];

	objc_autoreleasePoolPop(pool);
}


























- (OFString*)destinationOfSymbolicLinkAtPath: (OFString*)path
{
	char destination[PATH_MAX];
	ssize_t length;
	of_string_encoding_t encoding;

	if (path == nil)







>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
		@throw [OFCreateSymbolicLinkFailedException
		    exceptionWithSourcePath: source
			    destinationPath: destination
				      errNo: errno];

	objc_autoreleasePoolPop(pool);
}
#elif defined(OF_WINDOWS)
- (void)createSymbolicLinkAtPath: (OFString*)destination
	     withDestinationPath: (OFString*)source
{
	void *pool;

	if (func_CreateSymbolicLinkW == NULL)
		@throw [OFNotImplementedException exceptionWithSelector: _cmd
								 object: self];

	if (source == nil || destination == nil)
		@throw [OFInvalidArgumentException exception];

	pool = objc_autoreleasePoolPush();

	if (!func_CreateSymbolicLinkW([destination UTF16String],
	    [source UTF16String], 0))
		@throw [OFCreateSymbolicLinkFailedException
		    exceptionWithSourcePath: source
			    destinationPath: destination];

	objc_autoreleasePoolPop(pool);
}
#endif

#ifdef OF_HAVE_READLINK
- (OFString*)destinationOfSymbolicLinkAtPath: (OFString*)path
{
	char destination[PATH_MAX];
	ssize_t length;
	of_string_encoding_t encoding;

	if (path == nil)

Modified src/exceptions/OFCreateSymbolicLinkFailedException.h from [15147c1170] to [f563bb643a].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifdef OF_HAVE_SYMLINK
/*!
 * @class OFCreateSymbolicLinkFailedException \
 *	  OFCreateSymbolicLinkFailedException.h \
 *	  ObjFW/OFCreateSymbolicLinkFailedException.h
 *
 * @brief An exception indicating that creating a symbolic link failed.
 */







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#if defined(OF_HAVE_SYMLINK) || defined(OF_WINDOWS)
/*!
 * @class OFCreateSymbolicLinkFailedException \
 *	  OFCreateSymbolicLinkFailedException.h \
 *	  ObjFW/OFCreateSymbolicLinkFailedException.h
 *
 * @brief An exception indicating that creating a symbolic link failed.
 */
46
47
48
49
50
51
52










53
54
55
56
57
58
59











60
61
62
63
64
65
66
@property (readonly) int errNo;

/*!
 * @brief Creates a new, autoreleased create symbolic link failed exception.
 *
 * @param sourcePath The source for the symbolic link
 * @param destinationPath The destination for the symbolic link










 * @param errNo The errno of the error that occurred
 * @return A new, autoreleased create symbolic link failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo;












/*!
 * @brief Initializes an already allocated create symbolic link failed
 *	  exception.
 *
 * @param sourcePath The source for the symbolic link
 * @param destinationPath The destination for the symbolic link
 * @param errNo The errno of the error that occurred







>
>
>
>
>
>
>
>
>
>







>
>
>
>
>
>
>
>
>
>
>







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
84
85
86
87
@property (readonly) int errNo;

/*!
 * @brief Creates a new, autoreleased create symbolic link failed exception.
 *
 * @param sourcePath The source for the symbolic link
 * @param destinationPath The destination for the symbolic link
 * @return A new, autoreleased create symbolic link failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath;

/*!
 * @brief Creates a new, autoreleased create symbolic link failed exception.
 *
 * @param sourcePath The source for the symbolic link
 * @param destinationPath The destination for the symbolic link
 * @param errNo The errno of the error that occurred
 * @return A new, autoreleased create symbolic link failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo;

/*!
 * @brief Initializes an already allocated create symbolic link failed
 *	  exception.
 *
 * @param sourcePath The source for the symbolic link
 * @param destinationPath The destination for the symbolic link
 * @return An initialized create symbolic link failed exception
 */
- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated create symbolic link failed
 *	  exception.
 *
 * @param sourcePath The source for the symbolic link
 * @param destinationPath The destination for the symbolic link
 * @param errNo The errno of the error that occurred

Modified src/exceptions/OFCreateSymbolicLinkFailedException.m from [fc02c53f72] to [3c5d7c863e].

15
16
17
18
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
 */

#include "config.h"

#import "OFCreateSymbolicLinkFailedException.h"
#import "OFString.h"

#ifdef OF_HAVE_SYMLINK
@implementation OFCreateSymbolicLinkFailedException
@synthesize sourcePath = _sourcePath, destinationPath = _destinationPath;
@synthesize errNo = _errNo;








+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo
{
	return [[[self alloc] initWithSourcePath: sourcePath
				 destinationPath: destinationPath
					   errNo: errNo] autorelease];
}

- init
{
	OF_INVALID_INIT_METHOD
}

















- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
	       errNo: (int)errNo
{
	self = [super init];








|



>
>
>
>
>
>
>














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







15
16
17
18
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
68
69
 */

#include "config.h"

#import "OFCreateSymbolicLinkFailedException.h"
#import "OFString.h"

#if defined(OF_HAVE_SYMLINK) || defined(OF_WINDOWS)
@implementation OFCreateSymbolicLinkFailedException
@synthesize sourcePath = _sourcePath, destinationPath = _destinationPath;
@synthesize errNo = _errNo;

+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithSourcePath: sourcePath
				 destinationPath: destinationPath] autorelease];
}

+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo
{
	return [[[self alloc] initWithSourcePath: sourcePath
				 destinationPath: destinationPath
					   errNo: errNo] autorelease];
}

- init
{
	OF_INVALID_INIT_METHOD
}

- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
{
	self = [super init];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
	       errNo: (int)errNo
{
	self = [super init];

62
63
64
65
66
67
68

69
70

71




72
73
74
	[_destinationPath release];

	[super dealloc];
}

- (OFString*)description
{

	return [OFString stringWithFormat:
	    @"Failed to symlink file %@ to %@: %@",

	    _sourcePath, _destinationPath, of_strerror(_errNo)];




}
@end
#endif







>
|
|
>
|
>
>
>
>



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
	[_destinationPath release];

	[super dealloc];
}

- (OFString*)description
{
	if (_errNo != 0)
		return [OFString stringWithFormat:
		    @"Failed to create symbolic link %@ with destination "
		    @"%@: %@", _destinationPath, _sourcePath,
		    of_strerror(_errNo)];
	else
		return [OFString stringWithFormat:
		    @"Failed to create symbolic link %@ with destination %@!",
		    _destinationPath, _sourcePath];
}
@end
#endif

Modified src/exceptions/OFLinkFailedException.h from [d5b885ed6e] to [d7ba6d4dbb].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#ifdef OF_HAVE_LINK
/*!
 * @class OFLinkFailedException \
 *	  OFLinkFailedException.h ObjFW/OFLinkFailedException.h
 *
 * @brief An exception indicating that creating a link failed.
 */
@interface OFLinkFailedException: OFException







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

#if defined(OF_HAVE_LINK) || defined(OF_WINDOWS)
/*!
 * @class OFLinkFailedException \
 *	  OFLinkFailedException.h ObjFW/OFLinkFailedException.h
 *
 * @brief An exception indicating that creating a link failed.
 */
@interface OFLinkFailedException: OFException
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
 * The errno of the error that occurred.
 */
@property (readonly) int errNo;

/*!
 * @brief Creates a new, autoreleased link failed exception.
 *










 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @param errNo The errno of the error that occurred
 * @return A new, autoreleased link failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo;











/*!
 * @brief Initializes an already allocated link failed exception.
 *
 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @param errNo The errno of the error that occurred
 * @return An initialized link failed exception
 */
- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
	       errNo: (int)errNo;
@end
#endif







>
>
>
>
>
>
>
>
>
>









>
>
>
>
>
>
>
>
>
>













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
84
85
86
87
88
89
90
91
 * The errno of the error that occurred.
 */
@property (readonly) int errNo;

/*!
 * @brief Creates a new, autoreleased link failed exception.
 *
 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @return A new, autoreleased link failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath;

/*!
 * @brief Creates a new, autoreleased link failed exception.
 *
 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @param errNo The errno of the error that occurred
 * @return A new, autoreleased link failed exception
 */
+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo;

/*!
 * @brief Initializes an already allocated link failed exception.
 *
 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @return An initialized link failed exception
 */
- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath;

/*!
 * @brief Initializes an already allocated link failed exception.
 *
 * @param sourcePath The source for the link
 * @param destinationPath The destination for the link
 * @param errNo The errno of the error that occurred
 * @return An initialized link failed exception
 */
- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
	       errNo: (int)errNo;
@end
#endif

Modified src/exceptions/OFLinkFailedException.m from [71bc83ac12] to [3fe16945e2].

15
16
17
18
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
 */

#include "config.h"

#import "OFLinkFailedException.h"
#import "OFString.h"

#ifdef OF_HAVE_LINK
@implementation OFLinkFailedException
@synthesize sourcePath = _sourcePath, destinationPath = _destinationPath;
@synthesize errNo = _errNo;








+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo
{
	return [[[self alloc] initWithSourcePath: sourcePath
				 destinationPath: destinationPath
					   errNo: errNo] autorelease];
}

- init
{
	OF_INVALID_INIT_METHOD
}

















- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
	       errNo: (int)errNo
{
	self = [super init];








|



>
>
>
>
>
>
>














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







15
16
17
18
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
68
69
 */

#include "config.h"

#import "OFLinkFailedException.h"
#import "OFString.h"

#if defined(OF_HAVE_LINK) || defined(OF_WINDOWS)
@implementation OFLinkFailedException
@synthesize sourcePath = _sourcePath, destinationPath = _destinationPath;
@synthesize errNo = _errNo;

+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
{
	return [[[self alloc] initWithSourcePath: sourcePath
				 destinationPath: destinationPath] autorelease];
}

+ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath
			destinationPath: (OFString*)destinationPath
				  errNo: (int)errNo
{
	return [[[self alloc] initWithSourcePath: sourcePath
				 destinationPath: destinationPath
					   errNo: errNo] autorelease];
}

- init
{
	OF_INVALID_INIT_METHOD
}

- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
{
	self = [super init];

	@try {
		_sourcePath = [sourcePath copy];
		_destinationPath = [destinationPath copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithSourcePath: (OFString*)sourcePath
     destinationPath: (OFString*)destinationPath
	       errNo: (int)errNo
{
	self = [super init];

62
63
64
65
66
67
68

69
70
71




72
73
74
	[_destinationPath release];

	[super dealloc];
}

- (OFString*)description
{

	return [OFString stringWithFormat:
	    @"Failed to link file %@ to %@: %@",
	    _sourcePath, _destinationPath, of_strerror(_errNo)];




}
@end
#endif







>
|
|
|
>
>
>
>



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
	[_destinationPath release];

	[super dealloc];
}

- (OFString*)description
{
	if (_errNo != 0)
		return [OFString stringWithFormat:
		    @"Failed to link file %@ to %@: %@",
		    _sourcePath, _destinationPath, of_strerror(_errNo)];
	else
		return [OFString stringWithFormat:
		    @"Failed to link file %@ to %@!",
		    _sourcePath, _destinationPath];
}
@end
#endif

Modified src/objfw-defs.h.in from [84b0a50859] to [427af0f6c6].

18
19
20
21
22
23
24

25
26
27
28
29
30
31
32
33
34
35
36
#undef OF_HAVE_OSATOMIC_64
#undef OF_HAVE_PIPE
#undef OF_HAVE_PLUGINS
#undef OF_HAVE_PROCESSES
#undef OF_HAVE_PTHREADS
#undef OF_HAVE_PTHREAD_SPINLOCKS
#undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES

#undef OF_HAVE_SCHED_YIELD
#undef OF_HAVE_SOCKETS
#undef OF_HAVE_STDNORETURN
#undef OF_HAVE_SYMLINK
#undef OF_HAVE_SYS_SOCKET_H
#undef OF_HAVE_THREADS
#undef OF_HAVE___THREAD
#undef OF_HAVE__THREAD_LOCAL
#undef OF_NINTENDO_DS
#undef OF_OBJFW_RUNTIME
#undef OF_UNIVERSAL
#undef SIZE_MAX







>












18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#undef OF_HAVE_OSATOMIC_64
#undef OF_HAVE_PIPE
#undef OF_HAVE_PLUGINS
#undef OF_HAVE_PROCESSES
#undef OF_HAVE_PTHREADS
#undef OF_HAVE_PTHREAD_SPINLOCKS
#undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES
#undef OF_HAVE_READLINK
#undef OF_HAVE_SCHED_YIELD
#undef OF_HAVE_SOCKETS
#undef OF_HAVE_STDNORETURN
#undef OF_HAVE_SYMLINK
#undef OF_HAVE_SYS_SOCKET_H
#undef OF_HAVE_THREADS
#undef OF_HAVE___THREAD
#undef OF_HAVE__THREAD_LOCAL
#undef OF_NINTENDO_DS
#undef OF_OBJFW_RUNTIME
#undef OF_UNIVERSAL
#undef SIZE_MAX