本文整理匯總了C++中CFBundleCopyBundleURL函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFBundleCopyBundleURL函數的具體用法?C++ CFBundleCopyBundleURL怎麽用?C++ CFBundleCopyBundleURL使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFBundleCopyBundleURL函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: binaryPath
QString config::prefix() {
#ifdef Q_OS_WIN32
QDir binaryPath(QCoreApplication::applicationDirPath());
return QDir::toNativeSeparators(binaryPath.canonicalPath());
#endif
#ifdef Q_OS_LINUX
QString basePath(qgetenv("PLEXYDESK_DIR"));
if (basePath.isEmpty() || basePath.isNull()) {
return PLEXYPREFIX;
}
return basePath;
#endif
#ifdef Q_OS_MAC
CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef macPath =
CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
const char *pathPtr =
CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());
CFRelease(appUrlRef);
CFRelease(macPath);
return QLatin1String(pathPtr) + QString("/Contents/");
#endif
return QString();
}
示例2: GetStartOnSystemStartup
bool GetStartOnSystemStartup()
{
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
return !!foundItem; // return boolified object
}
示例3: macSetBundlePath
// dynamic data path detection onmac
bool macSetBundlePath(char* buffer)
{
// the following code will enable mupen to find its data when placed in an app bundle on mac OS X.
// returns true if path is set, returns false if path was not set
char path[1024] = { 0 };
CFBundleRef main_bundle = CFBundleGetMainBundle(); assert(main_bundle);
CFURLRef main_bundle_URL = CFBundleCopyBundleURL(main_bundle); assert(main_bundle_URL);
CFStringRef cf_string_ref = CFURLCopyFileSystemPath( main_bundle_URL, kCFURLPOSIXPathStyle); assert(cf_string_ref);
CFStringGetCString(cf_string_ref, path, 1024, kCFStringEncodingASCII);
CFRelease(main_bundle_URL);
CFRelease(cf_string_ref);
if (strstr( path, ".app" ) != 0)
{
DebugMessage(M64MSG_VERBOSE, "checking whether we are using an app bundle: yes");
// executable is inside an app bundle, use app bundle-relative paths
sprintf(buffer, "%s/Contents/Resources/", path);
return true;
}
else
{
DebugMessage(M64MSG_VERBOSE, "checking whether we are using an app bundle: no");
return false;
}
}
示例4: main
int main(int argc, char *argv[])
{
#ifdef WIN32
qInstallMsgHandler(myMessageOutput);
#endif
#if defined(Q_OS_MACX)
// On Mac, switch working directory to resources folder
CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
QString path( CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding()) );
path += "/Contents/Resources";
QDir::setCurrent( path );
CFRelease(pluginRef);
CFRelease(macPath);
#elif defined(PO_DATA_REPO)
QDir::setCurrent(PO_DATA_REPO);
#endif
srand(time(NULL));
try
{
//HotKeyClass HotKeyEvent;
QApplication a(argc, argv);
//a.installEventFilter(&HotKeyEvent);
/* Names to use later for QSettings */
QCoreApplication::setApplicationName("Pokeymon-Online");
QCoreApplication::setOrganizationName("Dreambelievers");
QSettings settings;
if (settings.value("language").isNull()) {
settings.setValue("language", QLocale::system().name().section('_', 0, 0));
}
QString locale = settings.value("language").toString();
QTranslator translator;
translator.load(QString("trans/translation_") + locale);
a.installTranslator(&translator);
/* icon ;) */
#if not defined(Q_OS_MACX)
a.setWindowIcon(QIcon("db/icon.png"));
#endif
MainEngine w;
return a.exec();
} /*catch (const std::exception &e) {
qDebug() << "Caught runtime " << e.what();
} catch (const QString &s) {
qDebug() << "Caught string " << s;
} */catch (const char* s) {
qDebug() << "Caught const char* " << s;
} /*catch (...) {
qDebug() << "Caught Exception.";
}*/
return 0;
}
示例5: mBundle
Bundle::Bundle(CFBundleRef bundle, const char *root /* = NULL */)
: mBundle(bundle)
{
assert(bundle);
CFRetain(bundle);
mPath = root ? root : cfStringRelease(CFBundleCopyBundleURL(mBundle));
secdebug("bundle", "%p Bundle from bundle %p(%s)", this, bundle, mPath.c_str());
}
示例6: open_libgl
static void open_libgl(void)
{
bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengles")); // we are always linked to OpenGLES.framework statically, so it is already loaded and could be found by id
assert(bundle != NULL);
CFRetain(bundle);
bundleURL = CFBundleCopyBundleURL(bundle);
}
示例7: InitDirs
void InitDirs(const std::string& argv0) {
if (g_initialized)
return;
// store working dir
fs::initial_path();
fs::path bundle_path;
fs::path app_path;
CFBundleRef bundle = CFBundleGetMainBundle();
char bundle_dir[MAXPATHLEN];
if (bundle) {
CFURLRef bundleurl = CFBundleCopyBundleURL(bundle);
CFURLGetFileSystemRepresentation(bundleurl, true, reinterpret_cast<UInt8*>(bundle_dir), MAXPATHLEN);
} else {
// executable is not the main binary in application bundle (i.e. Server or AI)
uint32_t size = sizeof(bundle_dir);
if (_NSGetExecutablePath(bundle_dir, &size) != 0) {
std::cerr << "_NSGetExecutablePath() failed: buffer too small; need size " << size << std::endl;
exit(-1);
}
}
bundle_path = fs::path(bundle_dir);
// search bundle_path for a directory named "FreeOrion.app", exiting if not found, else constructing a path to application bundle contents
fs::path::iterator appiter = std::find(bundle_path.begin(), bundle_path.end(), "FreeOrion.app");
if (appiter == bundle_path.end()) {
std::cerr << "Error: Application bundle must be named 'FreeOrion.app' and executables must not be called from outside of it." << std::endl;
exit(-1);
} else {
for (fs::path::iterator piter = bundle_path.begin(); piter != appiter; ++piter) {
app_path /= *piter;
}
app_path /= "FreeOrion.app/Contents";
}
s_root_data_dir = app_path / "Resources";
s_user_dir = fs::path(getenv("HOME")) / "Library" / "Application Support" / "FreeOrion";
s_bin_dir = app_path / "Executables";
s_config_path = s_user_dir / "config.xml";
s_python_home = app_path / "Frameworks" / "Python.framework" / "Versions" / "Current";
fs::path p = s_user_dir;
if (!exists(p))
fs::create_directories(p);
p /= "save";
if (!exists(p))
fs::create_directories(p);
// Intentionally do not create the server save dir.
// The server save dir is publically accessible and should not be
// automatically created for the user.
g_initialized = true;
}
示例8: FSGetApplPath
bool FSGetApplPath(UniString &applPath, bool withPS/* = true*/)
{
#if defined(WIN32) || defined(_WIN32_WCE)
wchar_t Temp[_MAX_PATH+1] = L"";
#if defined(_WIN32_WCE)
::GetModuleFileName(NULL, Temp, _MAX_PATH);
#else
::GetModuleFileNameW(NULL, Temp, _MAX_PATH);
#endif
applPath = Temp;
STRIndex_t pos = applPath.FindRAt(PATH_SEPARATOR_CHAR);
if ( STRING_FOUND(pos) )
applPath.Truncate( withPS ? pos + 1 : pos);
return true;
#else
CFBundleRef bundleRef = CFBundleGetMainBundle();
if ( bundleRef == NULL ) return false;
CFURLRef urlRef = CFBundleCopyBundleURL(bundleRef);
CFRelease(bundleRef);
if ( urlRef )
{
CFStringRef stringRef = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
CFRelease(urlRef);
if ( stringRef )
{
applPath = stringRef;
CFRelease(stringRef);
STRIndex_t pos = applPath.FindRAt(PATH_SEPARATOR_CHAR);
if ( STRING_FOUND(pos) )
{
if (!withPS)
applPath.Truncate(pos);
}
else
{
if (withPS)
applPath += PATH_SEPARATOR_CHAR;
}
return true;
}
}
return false;
#endif
}
示例9: bundles
/* -----------------------------------------------------------------------------
plugin entry point, called by vpnd
ref is the vpn bundle reference
pppref is the ppp bundle reference
bundles can be layout in two different ways
- As simple vpn bundles (bundle.vpn). the bundle contains the vpn bundle binary.
- As full ppp bundles (bundle.ppp). The bundle contains the ppp bundle binary,
and also the vpn kext and the vpn bundle binary in its Plugins directory.
if a simple vpn bundle was used, pppref will be NULL.
if a ppp bundle was used, the vpn plugin will be able to get access to the
Plugins directory and load the vpn kext.
----------------------------------------------------------------------------- */
int start(struct vpn_channel* the_vpn_channel, CFBundleRef ref, CFBundleRef pppref, int debug_mode)
{
char name[MAXPATHLEN];
CFURLRef url;
debug = debug_mode;
/* first load the kext if we are loaded as part of a ppp bundle */
if (pppref) {
while ((listen_sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_L2TP)) < 0)
if (errno != EINTR)
break;
if (listen_sockfd < 0) {
vpnlog(LOG_DEBUG, "first call to socket failed - attempting to load kext\n");
if (url = CFBundleCopyBundleURL(pppref)) {
name[0] = 0;
CFURLGetFileSystemRepresentation(url, 0, name, MAXPATHLEN - 1);
CFRelease(url);
strcat(name, "/");
if (url = CFBundleCopyBuiltInPlugInsURL(pppref)) {
CFURLGetFileSystemRepresentation(url, 0, name + strlen(name),
MAXPATHLEN - strlen(name) - strlen(L2TP_NKE) - 1);
CFRelease(url);
strcat(name, "/");
strcat(name, L2TP_NKE);
if (!load_kext(name))
while ((listen_sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_L2TP)) < 0)
if (errno != EINTR)
break;
}
}
if (listen_sockfd < 0) {
vpnlog(LOG_ERR, "VPND L2TP plugin: Unable to load L2TP kernel extension\n");
return -1;
}
}
}
/* retain reference */
bundle = ref;
CFRetain(bundle);
pppbundle = pppref;
CFRetain(pppbundle);
// hookup our socket handlers
bzero(the_vpn_channel, sizeof(struct vpn_channel));
the_vpn_channel->get_pppd_args = l2tpvpn_get_pppd_args;
the_vpn_channel->listen = l2tpvpn_listen;
the_vpn_channel->accept = l2tpvpn_accept;
the_vpn_channel->refuse = l2tpvpn_refuse;
the_vpn_channel->close = l2tpvpn_close;
return 0;
}
示例10: start
/* -----------------------------------------------------------------------------
plugin entry point, called by pppd
----------------------------------------------------------------------------- */
int start(CFBundleRef ref)
{
CFStringRef strref;
CFURLRef urlref;
bundle = ref;
CFRetain(bundle);
url = CFBundleCopyBundleURL(bundle);
// hookup our handlers
old_check_options = the_channel->check_options;
the_channel->check_options = serial_check_options;
old_connect = the_channel->connect;
the_channel->connect = serial_connect;
old_process_extra_options = the_channel->process_extra_options;
the_channel->process_extra_options = serial_process_extra_options;
add_notifier(&connect_fail_notify, serial_connect_notifier, 0);
add_notifier(&lcp_lowerdown_notify, serial_lcpdown_notifier, 0);
cancelstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Cancel"), CFSTR("Cancel"), NULL);
if (cancelstrref == 0) return 1;
CFStringGetCString(cancelstrref, (char*)cancelstr, sizeof(cancelstr), kCFStringEncodingUTF8);
icstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Network Connection"), CFSTR("Network Connection"), NULL);
if (icstrref == 0) return 1;
CFStringGetCString(icstrref, (char*)icstr, sizeof(icstr), kCFStringEncodingUTF8);
urlref = CFBundleCopyResourceURL(bundle, CFSTR("NetworkConnect.icns"), NULL, NULL);
if (urlref == 0 || ((strref = CFURLGetString(urlref)) == 0)) {
if (urlref)
CFRelease(urlref);
return 1;
}
CFStringGetCString(strref, (char*)iconstr, sizeof(iconstr), kCFStringEncodingUTF8);
iconstrref = CFStringCreateCopy(NULL, strref);
CFRelease(urlref);
urlref = CFBundleCopyBuiltInPlugInsURL(bundle);
if (urlref == 0 || ((CFURLGetFileSystemRepresentation(urlref, TRUE, pathccl, sizeof(pathccl))) == FALSE)) {
if (urlref)
CFRelease(urlref);
return 1;
}
strlcat((char*)pathccl, SUFFIX_CCLENGINE, sizeof(pathccl));
CFRelease(urlref);
// add the socket specific options
add_options(serial_options);
return 0;
}
示例11: fill_pathname_application_path
void fill_pathname_application_path(char *buf, size_t size)
{
size_t i;
(void)i;
if (!size)
return;
#ifdef _WIN32
DWORD ret = GetModuleFileName(GetModuleHandle(NULL), buf, size - 1);
buf[ret] = '\0';
#elif defined(__APPLE__)
CFBundleRef bundle = CFBundleGetMainBundle();
if (bundle)
{
CFURLRef bundle_url = CFBundleCopyBundleURL(bundle);
CFStringRef bundle_path = CFURLCopyPath(bundle_url);
CFStringGetCString(bundle_path, buf, size, kCFStringEncodingUTF8);
CFRelease(bundle_path);
CFRelease(bundle_url);
rarch_assert(strlcat(buf, "nobin", size) < size);
return;
}
#elif defined(__HAIKU__)
image_info info;
int32 cookie = 0;
while (get_next_image_info(0, &cookie, &info) == B_OK)
{
if (info.type == B_APP_IMAGE)
{
strlcpy(buf, info.name, size);
return;
}
}
#else
*buf = '\0';
pid_t pid = getpid();
char link_path[PATH_MAX];
/* Linux, BSD and Solaris paths. Not standardized. */
static const char *exts[] = { "exe", "file", "path/a.out" };
for (i = 0; i < ARRAY_SIZE(exts); i++)
{
snprintf(link_path, sizeof(link_path), "/proc/%u/%s",
(unsigned)pid, exts[i]);
ssize_t ret = readlink(link_path, buf, size - 1);
if (ret >= 0)
{
buf[ret] = '\0';
return;
}
}
RARCH_ERR("Cannot resolve application path! This should not happen.\n");
#endif
}
示例12: getExecutablePath
std::string getExecutablePath()
{
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
FixedStrT<512> buf;
CFURLGetFileSystemRepresentation(url, true,
(UInt8*) buf.str(), buf.capacity());
return buf.str();
}
示例13: CFBundleCopyBundleURL
QDir
lastfm::dir::bundle()
{
// Trolltech provided example
CFURLRef appUrlRef = CFBundleCopyBundleURL( CFBundleGetMainBundle() );
CFStringRef macPath = CFURLCopyFileSystemPath( appUrlRef, kCFURLPOSIXPathStyle );
QString path = CFStringToQString( macPath );
CFRelease(appUrlRef);
CFRelease(macPath);
return QDir( path );
}
示例14: CFBundleCopyBundleURL
void WindowMenu::onBringAllToFront()
{
#ifdef Q_WS_MAC
CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
if (appUrlRef)
{
LSOpenCFURLRef(appUrlRef, NULL);
CFRelease(appUrlRef);
}
#endif
}
示例15: initialize
void initialize()
{
static bool initialized = false;
if (initialized) {
return;
}
// Determine path for resources
#ifdef TARGET_OSX
CFBundleRef mainBundle = CFBundleGetMainBundle();
if (mainBundle) {
boost::filesystem::path bundlePath = convertCFUrlToPath(CFBundleCopyBundleURL(mainBundle));
boost::filesystem::path resourcesPath = convertCFUrlToPath(CFBundleCopyResourcesDirectoryURL(mainBundle));
resources = bundlePath / resourcesPath;
}
#elif TARGET_LINUX
resources = boost::filesystem::read_symlink(boost::filesystem::path("/proc/self/exe")).parent_path() / boost::filesystem::path("resources");
#endif
if (!valid(resources)) {
throw std::runtime_error("Unable to determine resource directory!");
}
// Determine data path
char const* dataPathEnv = getenv(DATA_DIRECTORY_ENV_NAME.c_str());
if (dataPathEnv) {
data = boost::filesystem::path(dataPathEnv);
} else {
boost::filesystem::path userHome;
char const* home = util::coalesce(getenv("HOME"), getenv("USERPROFILE"));
if (home) {
userHome = boost::filesystem::path(home);
} else {
char const* homedrive = getenv("HOMEDRIVE");
char const* homepath = getenv("HOMEPATH");
if (homedrive && homepath) {
userHome = boost::filesystem::path(std::string(homedrive) + homepath);
}
}
if (!valid(userHome)) {
throw std::runtime_error("Unable to determine user home directory!");
}
data = userHome / DATA_DIRECTORY_DEFAULT_NAME;
ensureDirectoryExists(data);
}
initialized = true;
}