ObjFW  Check-in [925c67cb45]

Overview
Comment:+[OFPlugin pathForName:]: Add fallback to .dylib
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 925c67cb45d19087d6046e6b80664e06606fb415dee9c1859fec8eb2edf724a9
User & Date: js on 2024-05-05 00:49:01
Other Links: manifest | tags
Context
2024-05-05
00:55
Update buildsys check-in: 396d832ab9 user: js tags: trunk
00:49
+[OFPlugin pathForName:]: Add fallback to .dylib check-in: 925c67cb45 user: js tags: trunk
00:17
Update buildsys check-in: 42f939d411 user: js tags: trunk
Changes

Modified src/OFPlugin.h from [3c7ae9a953] to [bf0d5597a2].

42
43
44
45
46
47
48
49



50
51
52
53
54
55
56
57
{
	OFPluginHandle _handle;
}

/**
 * @brief Returns the plugin path for a plugin with the specified name.
 *
 * E.g. on ELF systems, it appends .so, while on macOS and iOS, it creates the



 * appropriate plugin path. This can also be prefixed by a directory.
 *
 * @param name The name to return the plugin path for
 * @return The plugin path
 */
+ (OFString *)pathForName: (OFString *)name;

/**







|
>
>
>
|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
	OFPluginHandle _handle;
}

/**
 * @brief Returns the plugin path for a plugin with the specified name.
 *
 * E.g. on ELF systems, it appends `.so`, while on macOS and iOS, it checks if
 * there is a `.bundle` and if so uses the plugin contained in it, but
 * otherwise falls back to appending `.dylib`.
 *
 * This can also be prefixed by a directory.
 *
 * @param name The name to return the plugin path for
 * @return The plugin path
 */
+ (OFString *)pathForName: (OFString *)name;

/**

Modified src/OFPlugin.m from [cb86f84c31] to [2c713ca183].

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
#include <string.h>

#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif

#import "OFPlugin.h"

#import "OFLocale.h"
#import "OFString.h"
#import "OFSystemInfo.h"

#import "OFInitializationFailedException.h"
#import "OFLoadPluginFailedException.h"

#ifndef RTLD_LAZY
# define RTLD_LAZY 0
#endif

@implementation OFPlugin
+ (instancetype)pluginWithPath: (OFString *)path
{
	return [[[self alloc] initWithPath: path] autorelease];
}

+ (OFString *)pathForName: (OFString *)name
{




#if defined(OF_MACOS)
	return [name stringByAppendingFormat: @".bundle/Contents/MacOS/%@",
					      name.lastPathComponent];
#elif defined(OF_IOS)
	return [name stringByAppendingFormat: @".bundle/%@",
					      name.lastPathComponent];

#else

	return [name stringByAppendingString: @PLUGIN_SUFFIX];
#endif
}

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

	@try {







>



















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

<







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
#include <string.h>

#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif

#import "OFPlugin.h"
#import "OFFileManager.h"
#import "OFLocale.h"
#import "OFString.h"
#import "OFSystemInfo.h"

#import "OFInitializationFailedException.h"
#import "OFLoadPluginFailedException.h"

#ifndef RTLD_LAZY
# define RTLD_LAZY 0
#endif

@implementation OFPlugin
+ (instancetype)pluginWithPath: (OFString *)path
{
	return [[[self alloc] initWithPath: path] autorelease];
}

+ (OFString *)pathForName: (OFString *)name
{
#if (defined(OF_MACOS) || defined(OF_IOS)) && defined(OF_HAVE_FILES)
	OFString *path = [name stringByAppendingPathExtension: @"bundle"];

	if ([[OFFileManager defaultManager] directoryExistsAtPath: path])
# if defined(OF_MACOS)
		return [path stringByAppendingFormat: @"/Contents/MacOS/%@",
						      name.lastPathComponent];
# elif defined(OF_IOS)
		return [name stringByAppendingFormat: @"/%@",
						      name.lastPathComponent];
# endif
#endif

	return [name stringByAppendingString: @PLUGIN_SUFFIX];

}

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

	@try {