From 880d2ef43c2c9a064c5f427910d23e023a4f48ff Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Thu, 2 Oct 2008 19:12:59 +0000 Subject: [PATCH] Fix to get application name correctly. Was dropping argument from launchservices and not removing extension from path in fallback code. ticket: 6055 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20814 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kim/lib/mac/kim_os_library.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/kim/lib/mac/kim_os_library.c b/src/kim/lib/mac/kim_os_library.c index ecac38ca3..b0781bbf2 100644 --- a/src/kim/lib/mac/kim_os_library.c +++ b/src/kim/lib/mac/kim_os_library.c @@ -237,14 +237,16 @@ kim_error kim_os_library_get_caller_name (kim_string *out_application_name) if (bundle_url) { err = LSCopyDisplayNameForURL (bundle_url, &cfname); + check_error (err); } if (bundle_url) { CFRelease (bundle_url); } } - if (!err && !name) { + if (!err && !cfname) { kim_string path = NULL; CFURLRef cfpath = NULL; + CFURLRef cfpathnoext = NULL; err = kim_os_library_get_application_path (&path); @@ -253,12 +255,21 @@ kim_error kim_os_library_get_caller_name (kim_string *out_application_name) (const UInt8 *) path, strlen (path), 0); + if (cfpath) { + cfpathnoext = CFURLCreateCopyDeletingPathExtension (kCFAllocatorDefault, + cfpath); + } + + if (cfpathnoext) { + cfname = CFURLCopyLastPathComponent (cfpathnoext); + } else { cfname = CFURLCopyLastPathComponent (cfpath); } } - if (cfpath) { CFRelease (cfpath); } + if (cfpathnoext) { CFRelease (cfpathnoext); } + if (cfpath ) { CFRelease (cfpath); } } if (!err && cfname) { -- 2.26.2