1 //===-- CFBundle.cpp --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Created by Greg Clayton on 1/16/08.
12 //===----------------------------------------------------------------------===//
17 //----------------------------------------------------------------------
18 // CFBundle constructor
19 //----------------------------------------------------------------------
20 CFBundle::CFBundle(const char *path)
21 : CFReleaser<CFBundleRef>(), m_bundle_url() {
26 //----------------------------------------------------------------------
27 // CFBundle copy constructor
28 //----------------------------------------------------------------------
29 CFBundle::CFBundle(const CFBundle &rhs)
30 : CFReleaser<CFBundleRef>(rhs), m_bundle_url(rhs.m_bundle_url) {}
32 //----------------------------------------------------------------------
33 // CFBundle copy constructor
34 //----------------------------------------------------------------------
35 CFBundle &CFBundle::operator=(const CFBundle &rhs) {
40 //----------------------------------------------------------------------
42 //----------------------------------------------------------------------
43 CFBundle::~CFBundle() {}
45 //----------------------------------------------------------------------
46 // Set the path for a bundle by supplying a
47 //----------------------------------------------------------------------
48 bool CFBundle::SetPath(const char *path) {
49 CFAllocatorRef alloc = kCFAllocatorDefault;
50 // Release our old bundle and ULR
51 reset(); // This class is a CFReleaser<CFBundleRef>
53 // Make a CFStringRef from the supplied path
55 cf_path.SetFileSystemRepresentation(path);
57 // Make our Bundle URL
58 m_bundle_url.reset(::CFURLCreateWithFileSystemPath(
59 alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
60 if (m_bundle_url.get()) {
61 reset(::CFBundleCreate(alloc, m_bundle_url.get()));
67 CFStringRef CFBundle::GetIdentifier() const {
68 CFBundleRef bundle = get();
70 return ::CFBundleGetIdentifier(bundle);
74 CFURLRef CFBundle::CopyExecutableURL() const {
75 CFBundleRef bundle = get();
77 return CFBundleCopyExecutableURL(bundle);