diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/file_version_info.cc | 10 | ||||
-rw-r--r-- | base/file_version_info.h | 5 | ||||
-rw-r--r-- | base/file_version_info_mac.mm | 20 |
3 files changed, 24 insertions, 11 deletions
diff --git a/base/file_version_info.cc b/base/file_version_info.cc index 22d3d24..19aa011 100644 --- a/base/file_version_info.cc +++ b/base/file_version_info.cc @@ -40,9 +40,9 @@ FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { // static FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( - const std::wstring& file_path) { + const FilePath& file_path) { DWORD dummy; - const wchar_t* path = file_path.c_str(); + const wchar_t* path = file_path.value().c_str(); DWORD length = ::GetFileVersionInfoSize(path, &dummy); if (length == 0) return NULL; @@ -71,6 +71,12 @@ FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( } } +FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( + const std::wstring& file_path) { + FilePath file_path_fp = FilePath::FromWStringHack(file_path); + return CreateFileVersionInfo(file_path_fp); +} + std::wstring FileVersionInfo::company_name() { return GetStringValue(L"CompanyName"); } diff --git a/base/file_version_info.h b/base/file_version_info.h index d2d6630..653aaf3 100644 --- a/base/file_version_info.h +++ b/base/file_version_info.h @@ -8,6 +8,7 @@ #include <string> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/scoped_ptr.h" #ifdef OS_MACOSX @@ -27,6 +28,9 @@ class FileVersionInfo { // Creates a FileVersionInfo for the specified path. Returns NULL if something // goes wrong (typically the file does not exit or cannot be opened). The // returned object should be deleted when you are done with it. + static FileVersionInfo* CreateFileVersionInfo(const FilePath& file_path); + // This version, taking a wstring, is deprecated and only kept around + // until we can fix all callers. static FileVersionInfo* CreateFileVersionInfo(const std::wstring& file_path); // Creates a FileVersionInfo for the current module. Returns NULL in case @@ -77,7 +81,6 @@ class FileVersionInfo { VS_FIXEDFILEINFO* fixed_file_info_; #elif defined(OS_MACOSX) explicit FileVersionInfo(NSBundle *bundle); - explicit FileVersionInfo(const std::wstring& file_path); NSBundle *bundle_; #endif diff --git a/base/file_version_info_mac.mm b/base/file_version_info_mac.mm index 62fe7e0..3813cc6 100644 --- a/base/file_version_info_mac.mm +++ b/base/file_version_info_mac.mm @@ -9,14 +9,8 @@ #include "base/logging.h" #include "base/string_util.h" -FileVersionInfo::FileVersionInfo(const std::wstring& file_path) { - NSString* path = [[NSString alloc] - initWithCString:reinterpret_cast<const char*>(file_path.c_str()) - encoding:NSUTF32StringEncoding]; - bundle_ = [NSBundle bundleWithPath: path]; -} - FileVersionInfo::FileVersionInfo(NSBundle *bundle) : bundle_(bundle) { + [bundle_ retain]; } FileVersionInfo::~FileVersionInfo() { @@ -34,7 +28,17 @@ FileVersionInfo* FileVersionInfo::CreateFileVersionInfoForCurrentModule() { // static FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( const std::wstring& file_path) { - return new FileVersionInfo(file_path); + NSString* path = [NSString stringWithCString: + reinterpret_cast<const char*>(file_path.c_str()) + encoding:NSUTF32StringEncoding]; + return new FileVersionInfo([NSBundle bundleWithPath:path]); +} + +// static +FileVersionInfo* FileVersionInfo::CreateFileVersionInfo( + const FilePath& file_path) { + NSString* path = [NSString stringWithUTF8String:file_path.value().c_str()]; + return new FileVersionInfo([NSBundle bundleWithPath:path]); } std::wstring FileVersionInfo::company_name() { |