Chromium Code Reviews| Index: base/mac/foundation_util.mm |
| diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm |
| index 8ab02abce8e027f28678c8cd475a0be9dfbf5015..6d8563fa9f12ea096a1f4be2fa2c2a6a8a5f3858 100644 |
| --- a/base/mac/foundation_util.mm |
| +++ b/base/mac/foundation_util.mm |
| @@ -73,9 +73,7 @@ FilePath PathForFrameworkBundleResource(CFStringRef resourceName) { |
| NSBundle* bundle = base::mac::FrameworkBundle(); |
| NSString* resourcePath = [bundle pathForResource:(NSString*)resourceName |
| ofType:nil]; |
| - if (!resourcePath) |
| - return FilePath(); |
| - return FilePath([resourcePath fileSystemRepresentation]); |
| + return NSStringToFilePath(resourcePath); |
| } |
| OSType CreatorCodeForCFBundleRef(CFBundleRef bundle) { |
| @@ -101,8 +99,7 @@ bool GetSearchPathDirectory(NSSearchPathDirectory directory, |
| if ([dirs count] < 1) { |
| return false; |
| } |
| - NSString* path = [dirs objectAtIndex:0]; |
| - *result = FilePath([path fileSystemRepresentation]); |
| + *result = NSStringToFilePath([dirs objectAtIndex:0]); |
| return true; |
| } |
| @@ -330,6 +327,20 @@ std::string GetValueFromDictionaryErrorMessage( |
| " instead"; |
| } |
| +NSString* FilePathToNSString(const FilePath& path) { |
| + if (path.empty()) |
| + return nil; |
| + return [[NSFileManager defaultManager] |
| + stringWithFileSystemRepresentation:path.value().c_str() |
|
Mark Mentovai
2012/02/08 04:29:04
This is overkill. +[NSString stringWithUTF8String:
sail
2012/02/08 05:21:38
Done.
|
| + length:path.value().size()]; |
| +} |
| + |
| +FilePath NSStringToFilePath(NSString* str) { |
| + if (!str || ![str length]) |
|
Mark Mentovai
2012/02/08 04:29:04
You can simplify this to (![str length]).
sail
2012/02/08 05:21:38
Done.
|
| + return FilePath(); |
| + return FilePath([str fileSystemRepresentation]); |
| +} |
| + |
| } // namespace mac |
| } // namespace base |