ObjFW  Check-in [9713afbd6d]

Overview
Comment:OFFileManager: Add -[currentDirectoryURL]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9713afbd6da38966dc51ccf34082ba24853480b2666759808b85911ee60d752c
User & Date: js on 2017-10-28 21:26:30
Other Links: manifest | tags
Context
2017-10-28
23:52
OFURL: Return a proper URL for +[fileURLWithPath:] check-in: 8aa7f964bc user: js tags: trunk
21:26
OFFileManager: Add -[currentDirectoryURL] check-in: 9713afbd6d user: js tags: trunk
21:08
Make OFURL more generic check-in: 0f995db06d user: js tags: trunk
Changes

Modified src/OFFileManager.h from [b4c0bf6d7e] to [6fbc0773f9].

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
#endif
#if (defined(OF_HAVE_SYMLINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_SYMLINKS
#endif

@class OFArray OF_GENERIC(ObjectType);
@class OFDate;


/*!
 * @class OFFileManager OFFileManager.h ObjFW/OFFileManager.h
 *
 * @brief A class which provides management for files, e.g. reading contents of
 *	  directories, deleting files, renaming files, etc.
 */
@interface OFFileManager: OFObject
/*!
 * @brief Returns the default file manager.
 */
+ (OFFileManager *)defaultManager;

/*!
 * @brief Returns the path for the current working directory.
 *
 * @return The path of the current working directory
 */
- (OFString *)currentDirectoryPath;








/*!
 * @brief Checks whether a file exists at the specified path.
 *
 * @param path The path to check
 * @return A boolean whether there is a file at the specified path
 */
- (bool)fileExistsAtPath: (OFString *)path;







>




















>
>
>
>
>
>
>







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
#endif
#if (defined(OF_HAVE_SYMLINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_SYMLINKS
#endif

@class OFArray OF_GENERIC(ObjectType);
@class OFDate;
@class OFURL;

/*!
 * @class OFFileManager OFFileManager.h ObjFW/OFFileManager.h
 *
 * @brief A class which provides management for files, e.g. reading contents of
 *	  directories, deleting files, renaming files, etc.
 */
@interface OFFileManager: OFObject
/*!
 * @brief Returns the default file manager.
 */
+ (OFFileManager *)defaultManager;

/*!
 * @brief Returns the path for the current working directory.
 *
 * @return The path of the current working directory
 */
- (OFString *)currentDirectoryPath;

/*!
 * @brief Returns the URL for the current working directory.
 *
 * @return The URL of the current working directory
 */
- (OFURL *)currentDirectoryURL;

/*!
 * @brief Checks whether a file exists at the specified path.
 *
 * @param path The path to check
 * @return A boolean whether there is a file at the specified path
 */
- (bool)fileExistsAtPath: (OFString *)path;

Modified src/OFFileManager.m from [6c0ff405f2] to [63200da91b].

31
32
33
34
35
36
37
38
39
40

41
42
43
44
45
46
47
48
49
50
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#endif

#import "OFFileManager.h"
#import "OFFile.h"
#import "OFString.h"
#import "OFArray.h"

#import "OFDate.h"
#import "OFSystemInfo.h"
#import "OFLocalization.h"

#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif

#import "OFChangeCurrentDirectoryPathFailedException.h"
#import "OFChangeOwnerFailedException.h"







|
|
|
>
|

|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#endif

#import "OFFileManager.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFFile.h"
#import "OFLocalization.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFURL.h"

#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif

#import "OFChangeCurrentDirectoryPathFailedException.h"
#import "OFChangeOwnerFailedException.h"
281
282
283
284
285
286
287















288
289
290
291
292
293
294
	} @finally {
		free(buffer);
	}

	return ret;
#endif
}
















- (bool)fileExistsAtPath: (OFString *)path
{
	of_stat_t s;

	if (path == nil)
		@throw [OFInvalidArgumentException exception];







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







282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
	} @finally {
		free(buffer);
	}

	return ret;
#endif
}

- (OFURL *)currentDirectoryURL
{
	OFMutableURL *URL = [OFMutableURL URL];
	void *pool = objc_autoreleasePoolPush();

	[URL setScheme: @"file"];
	[URL setPath: [[[self currentDirectoryPath] pathComponents]
	    componentsJoinedByString: @"/"]];
	[URL makeImmutable];

	objc_autoreleasePoolPop(pool);

	return URL;
}

- (bool)fileExistsAtPath: (OFString *)path
{
	of_stat_t s;

	if (path == nil)
		@throw [OFInvalidArgumentException exception];