diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-10 22:05:40 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-10 22:05:40 +0000 |
commit | 480e1292b1020e47ab9486d4a0f3b1f0f2ddec81 (patch) | |
tree | 9a6e068ce40e673f23ade5f13f1ff0d79ea3800d /base | |
parent | ce221d9f025d58085395cb8b66e68ce45d941fac (diff) | |
download | chromium_src-480e1292b1020e47ab9486d4a0f3b1f0f2ddec81.zip chromium_src-480e1292b1020e47ab9486d4a0f3b1f0f2ddec81.tar.gz chromium_src-480e1292b1020e47ab9486d4a0f3b1f0f2ddec81.tar.bz2 |
Load the Ahem font from the source tree when not running bundled, for
test_shell_tests.
Review URL: http://codereview.chromium.org/13719
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/mac_util.h | 3 | ||||
-rw-r--r-- | base/mac_util.mm | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/base/mac_util.h b/base/mac_util.h index 47ec6b6..a6c81fa 100644 --- a/base/mac_util.h +++ b/base/mac_util.h @@ -14,6 +14,9 @@ namespace mac_util { std::string PathFromFSRef(const FSRef& ref); bool FSRefFromPath(const std::string& path, FSRef* ref); +// Returns true if the application is running from a bundle +bool AmIBundled(); + } // namespace mac_util #endif // BASE_MAC_UTIL_H_ diff --git a/base/mac_util.mm b/base/mac_util.mm index 1f92e62..462d165 100644 --- a/base/mac_util.mm +++ b/base/mac_util.mm @@ -4,6 +4,7 @@ #include "base/mac_util.h" +#include <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> #include "base/scoped_cftyperef.h" @@ -23,4 +24,21 @@ bool FSRefFromPath(const std::string& path, FSRef* ref) { return status == noErr; } +// Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled +bool AmIBundled() { + ProcessSerialNumber psn = {0, kCurrentProcess}; + + FSRef fsref; + if (GetProcessBundleLocation(&psn, &fsref) != noErr) + return false; + + FSCatalogInfo info; + if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, + NULL, NULL, NULL) != noErr) { + return false; + } + + return info.nodeFlags & kFSNodeIsDirectoryMask; +} + } // namespace mac_util |