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..d349509fde4c3267b6b97f9ec618ff055a8819ec 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,22 @@ bool GetUserDirectory(NSSearchPathDirectory directory, FilePath* result) { |
| return GetSearchPathDirectory(directory, NSUserDomainMask, result); |
| } |
| +std::string GetDisplayNameForPath(const FilePath& path) { |
| + FSRef ref; |
| + if (!FSRefFromPath(path.value(), &ref)) { |
|
benwells
2012/09/04 04:15:01
Nit: No need for braces around the body of these t
thorogood
2012/09/04 05:57:33
Done.
|
| + return path.BaseName().value(); |
| + } |
| + |
| + CFStringRef str; |
| + if (LSCopyDisplayNameForRef(&ref, &str)) { |
| + return path.BaseName().value(); |
| + } |
| + |
| + std::string result(base::SysCFStringRefToUTF8(str)); |
| + NSObjectRelease((void *) str); |
|
benwells
2012/09/04 04:15:01
I have little idea about objective c memory but I
thorogood
2012/09/04 05:57:33
I believe it's optional. I don't believe we do tha
benwells
2012/09/04 06:38:11
OK cool, sounds like you've looked into it.
|
| + return result; |
| +} |
| + |
| FilePath GetUserLibraryPath() { |
| FilePath user_library_path; |
| if (!GetUserDirectory(NSLibraryDirectory, &user_library_path)) { |