From 1cc68a258e2031447426129355b535852c3e47f3 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Mon, 15 Apr 2013 20:21:05 +0400 Subject: [PATCH] [r: andrey.zaytzev] IDEA-105363 --- native/MacLauncher/Launcher.m | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/native/MacLauncher/Launcher.m b/native/MacLauncher/Launcher.m index 08b62e3d8b70..514fd9651a5b 100644 --- a/native/MacLauncher/Launcher.m +++ b/native/MacLauncher/Launcher.m @@ -64,18 +64,22 @@ typedef jint (JNICALL *fun_ptr_t_CreateJavaVM)(JavaVM **pvm, void **env, void *a } +void appendBundle(NSString *path, NSMutableArray *sink) { + if ([path hasSuffix:@".jdk"] || [path hasSuffix:@".jre"]) { + NSBundle *bundle = [NSBundle bundleWithPath:path]; + if (bundle != nil) { + [sink addObject:bundle]; + } + } +} + void appendJvmBundlesAt(NSString *path, NSMutableArray *sink) { NSError *error = nil; NSArray *names = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error]; if (names != nil) { for (NSString *name in names) { - if ([name hasSuffix:@".jdk"] || [name hasSuffix:@".jre"]) { - NSBundle *bundle = [NSBundle bundleWithPath:[path stringByAppendingPathComponent:name]]; - if (bundle != nil) { - [sink addObject:bundle]; - } - } + appendBundle([path stringByAppendingPathComponent:name], sink); } } } @@ -86,7 +90,7 @@ NSArray *allVms() { NSString *explicit = [[[NSProcessInfo processInfo] environment] objectForKey:@"IDEA_JDK"]; if (explicit != nil) { - appendJvmBundlesAt(explicit, jvmBundlePaths); + appendBundle(explicit, jvmBundlePaths); } else { NSBundle *bundle = [NSBundle mainBundle];