Chromium Code Reviews| Index: base/mac/foundation_util.mm |
| diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm |
| index d9cbbfbc487fe1c602f1d4c2de3c7f4fa88ded2e..f5305b3e4102265a9b5e6a071b474ec6c3bc18a9 100644 |
| --- a/base/mac/foundation_util.mm |
| +++ b/base/mac/foundation_util.mm |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include "base/mac/foundation_util.h" |
| +#include "base/mac/mac_util.h" |
| #include <stdlib.h> |
| #include <string.h> |
| @@ -128,6 +129,20 @@ bool GetUserDirectory(NSSearchPathDirectory directory, FilePath* result) { |
| return GetSearchPathDirectory(directory, NSUserDomainMask, result); |
| } |
| +std::string GetDisplayBaseName(const FilePath& path) { |
| + FSRef ref; |
| + if (!FSRefFromPath(path.value(), &ref)) |
|
Nico
2012/09/04 14:09:37
Can you use a CFURL instead of a FSRef?
thorogood
2012/09/06 00:16:53
It seems like I could, e.g.: [NSURL fileURLWithPat
Nico
2012/09/06 00:22:28
FSRef is a very old type, and NSURL is what Apple
thorogood
2012/09/06 04:42:37
Turns out it's now reasonably more verbose, both t
|
| + return path.BaseName().value(); |
| + |
| + CFStringRef str; |
| + if (LSCopyDisplayNameForRef(&ref, &str) != noErr) |
| + return path.BaseName().value(); |
| + |
| + std::string result(base::SysCFStringRefToUTF8(str)); |
| + NSObjectRelease((void *) str); |
|
Nico
2012/09/04 14:09:37
CFRelease
thorogood
2012/09/06 00:16:53
Done.
|
| + return result; |
| +} |
| + |
| FilePath GetUserLibraryPath() { |
| FilePath user_library_path; |
| if (!GetUserDirectory(NSLibraryDirectory, &user_library_path)) { |