1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/base/mac_util.mm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,34 @@ 1.4 +// Copyright (c) 2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#include "base/mac_util.h" 1.9 + 1.10 +#include <Carbon/Carbon.h> 1.11 +#import <Cocoa/Cocoa.h> 1.12 + 1.13 +#include "base/file_path.h" 1.14 +#include "base/logging.h" 1.15 +#include "base/scoped_cftyperef.h" 1.16 +#include "base/sys_string_conversions.h" 1.17 + 1.18 +namespace mac_util { 1.19 + 1.20 +// Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled 1.21 +bool AmIBundled() { 1.22 + ProcessSerialNumber psn = {0, kCurrentProcess}; 1.23 + 1.24 + FSRef fsref; 1.25 + if (GetProcessBundleLocation(&psn, &fsref) != noErr) 1.26 + return false; 1.27 + 1.28 + FSCatalogInfo info; 1.29 + if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, 1.30 + NULL, NULL, NULL) != noErr) { 1.31 + return false; 1.32 + } 1.33 + 1.34 + return info.nodeFlags & kFSNodeIsDirectoryMask; 1.35 +} 1.36 + 1.37 +} // namespace mac_util