1 //===-- CFBundle.cpp --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Created by Greg Clayton on 1/16/08.
11 //===----------------------------------------------------------------------===//
16 // CFBundle constructor
17 CFBundle::CFBundle(const char *path)
18 : CFReleaser<CFBundleRef>(), m_bundle_url() {
23 // CFBundle copy constructor
24 CFBundle::CFBundle(const CFBundle &rhs)
25 : CFReleaser<CFBundleRef>(rhs), m_bundle_url(rhs.m_bundle_url) {}
27 // CFBundle copy constructor
28 CFBundle &CFBundle::operator=(const CFBundle &rhs) {
34 CFBundle::~CFBundle() {}
36 // Set the path for a bundle by supplying a
37 bool CFBundle::SetPath(const char *path) {
38 CFAllocatorRef alloc = kCFAllocatorDefault;
39 // Release our old bundle and ULR
40 reset(); // This class is a CFReleaser<CFBundleRef>
42 // Make a CFStringRef from the supplied path
44 cf_path.SetFileSystemRepresentation(path);
46 // Make our Bundle URL
47 m_bundle_url.reset(::CFURLCreateWithFileSystemPath(
48 alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
49 if (m_bundle_url.get()) {
50 reset(::CFBundleCreate(alloc, m_bundle_url.get()));
56 CFStringRef CFBundle::GetIdentifier() const {
57 CFBundleRef bundle = get();
59 return ::CFBundleGetIdentifier(bundle);
63 CFURLRef CFBundle::CopyExecutableURL() const {
64 CFBundleRef bundle = get();
66 return CFBundleCopyExecutableURL(bundle);