diff options
author | Elliott Hughes <enh@google.com> | 2015-04-16 13:24:58 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-04-16 13:24:58 -0700 |
commit | 1a4d85a5e81bb98503966312a509c5a1e23f14d4 (patch) | |
tree | 26372cd9bb6eb367b53529b5954371804f2619ec /adb/get_my_path_darwin.cpp | |
parent | c01445d2e8faafdb40e4fb426bc537f4f1220bad (diff) | |
download | system_core-1a4d85a5e81bb98503966312a509c5a1e23f14d4.tar.gz system_core-1a4d85a5e81bb98503966312a509c5a1e23f14d4.tar.bz2 system_core-1a4d85a5e81bb98503966312a509c5a1e23f14d4.zip |
Move get_my_path_darwin to C++.
As long as we have C in here, we can't use C++ in our headers.
Change-Id: Ibccaa77a5af506dc504aa9c39c8dca5dcdbeccab
Diffstat (limited to 'adb/get_my_path_darwin.cpp')
-rw-r--r-- | adb/get_my_path_darwin.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/adb/get_my_path_darwin.cpp b/adb/get_my_path_darwin.cpp new file mode 100644 index 000000000..b0c962e08 --- /dev/null +++ b/adb/get_my_path_darwin.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import <Carbon/Carbon.h> +#include <unistd.h> + +#include "adb.h" + +void get_my_path(char *s, size_t maxLen) +{ + CFBundleRef mainBundle = CFBundleGetMainBundle(); + CFURLRef executableURL = CFBundleCopyExecutableURL(mainBundle); + CFStringRef executablePathString = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle); + CFRelease(executableURL); + + CFStringGetFileSystemRepresentation(executablePathString, s, maxLen); + CFRelease(executablePathString); +} + |