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
) {
35 CFBundle::~CFBundle() {}
37 // Set the path for a bundle by supplying a
38 bool CFBundle::SetPath(const char *path
) {
39 CFAllocatorRef alloc
= kCFAllocatorDefault
;
40 // Release our old bundle and ULR
41 reset(); // This class is a CFReleaser<CFBundleRef>
43 // Make a CFStringRef from the supplied path
45 cf_path
.SetFileSystemRepresentation(path
);
47 // Make our Bundle URL
48 m_bundle_url
.reset(::CFURLCreateWithFileSystemPath(
49 alloc
, cf_path
.get(), kCFURLPOSIXPathStyle
, true));
50 if (m_bundle_url
.get()) {
51 reset(::CFBundleCreate(alloc
, m_bundle_url
.get()));
57 CFStringRef
CFBundle::GetIdentifier() const {
58 CFBundleRef bundle
= get();
60 return ::CFBundleGetIdentifier(bundle
);
64 CFURLRef
CFBundle::CopyExecutableURL() const {
65 CFBundleRef bundle
= get();
67 return CFBundleCopyExecutableURL(bundle
);