std::string resourcePath() { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE return bundlePath() + "/Contents/Resources/" ; #else return bundlePath() ; #endif }
std::string resourcePath() { #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE return bundlePath() + "/Contents/Resources/" ; #endif #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX return std::string("/usr/share/qtOgitor/"); #else return bundlePath() ; #endif }
void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { #ifdef DATA_PATH // Add the global DATA_PATH to the directory search list // FIXME: We use depth = 4 for now, to match the old code. May want to change that Common::FSNode dataNode(DATA_PATH); if (dataNode.exists() && dataNode.isDirectory()) { s.add(DATA_PATH, new Common::FSDirectory(dataNode, 4), priority); } #endif #ifdef MACOSX // Get URL of the Resource directory of the .app bundle CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); if (fileUrl) { // Try to convert the URL to an absolute path UInt8 buf[MAXPATHLEN]; if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) { // Success: Add it to the search path Common::String bundlePath((const char *)buf); s.add("__OSX_BUNDLE__", new Common::FSDirectory(bundlePath), priority); } CFRelease(fileUrl); } #endif }
void IosRunner::start() { if (m_toolHandler) { m_toolHandler->stop(); emit finished(m_cleanExit); } m_cleanExit = false; IosToolHandler::DeviceType devType = IosToolHandler::IosDeviceType; if (m_device->type() != Ios::Constants::IOS_DEVICE_TYPE) { IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>(); if (sim.isNull()) { emit finished(m_cleanExit); return; } devType = IosToolHandler::IosSimulatedIphoneRetina4InchType; // store type in sim? } m_toolHandler = new IosToolHandler(devType, this); connect(m_toolHandler, SIGNAL(appOutput(Ios::IosToolHandler*,QString)), SLOT(handleAppOutput(Ios::IosToolHandler*,QString))); connect(m_toolHandler, SIGNAL(didStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)), SLOT(handleDidStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus))); connect(m_toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)), SLOT(handleErrorMsg(Ios::IosToolHandler*,QString))); connect(m_toolHandler, SIGNAL(gotGdbserverPort(Ios::IosToolHandler*,QString,QString,int)), SLOT(handleGotGdbserverPort(Ios::IosToolHandler*,QString,QString,int))); connect(m_toolHandler, SIGNAL(gotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID)), SLOT(handleGotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID))); connect(m_toolHandler, SIGNAL(toolExited(Ios::IosToolHandler*,int)), SLOT(handleToolExited(Ios::IosToolHandler*,int))); connect(m_toolHandler, SIGNAL(finished(Ios::IosToolHandler*)), SLOT(handleFinished(Ios::IosToolHandler*))); m_toolHandler->requestRunApp(bundlePath(), extraArgs(), runType(), deviceId()); }
Bundle Bundle::fromPath(const QString &path) { Bundle bundle; QFileInfo bundlePath(path); if (!bundlePath.isReadable()) { qCWarning(l) << "bundle" << bundlePath.absolutePath() << "is not readable"; return Bundle(); } bundle.b->path = path; QScopedPointer<QIODevice> manifestJSON(bundle.openFile(Bundle::MANIFEST, QIODevice::Text)); if (!manifestJSON) { qCWarning(l) << "cannot find" << path << "manifest json"; return Bundle(); } QJsonParseError parseError; QJsonDocument doc = QJsonDocument::fromJson(manifestJSON->readAll(), &parseError); if (parseError.error != QJsonParseError::NoError) { qCWarning(l) << "cannot parse" << path << "manifest json" << parseError.errorString(); return Bundle(); } manifestJSON->close(); bundle.b->manifest = doc.object(); bundle.b->isValid = true; return bundle; }
void IosRunner::start() { if (m_toolHandler) { m_toolHandler->stop(); emit finished(m_cleanExit); } m_cleanExit = false; m_qmlPort = 0; if (!QFileInfo(m_bundleDir).exists()) { TaskHub::addTask(Task::Warning, tr("Could not find %1.").arg(m_bundleDir), ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); emit finished(m_cleanExit); return; } if (m_device->type() == Ios::Constants::IOS_DEVICE_TYPE) { IosDevice::ConstPtr iosDevice = m_device.dynamicCast<const IosDevice>(); if (m_device.isNull()) { emit finished(m_cleanExit); return; } if (m_qmlDebug) m_qmlPort = iosDevice->nextPort(); } else { IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>(); if (sim.isNull()) { emit finished(m_cleanExit); return; } if (m_qmlDebug) m_qmlPort = sim->nextPort(); } m_toolHandler = new IosToolHandler(m_deviceType, this); connect(m_toolHandler, SIGNAL(appOutput(Ios::IosToolHandler*,QString)), SLOT(handleAppOutput(Ios::IosToolHandler*,QString))); connect(m_toolHandler, SIGNAL(didStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus)), SLOT(handleDidStartApp(Ios::IosToolHandler*,QString,QString,Ios::IosToolHandler::OpStatus))); connect(m_toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)), SLOT(handleErrorMsg(Ios::IosToolHandler*,QString))); connect(m_toolHandler, SIGNAL(gotServerPorts(Ios::IosToolHandler*,QString,QString,int,int)), SLOT(handleGotServerPorts(Ios::IosToolHandler*,QString,QString,int,int))); connect(m_toolHandler, SIGNAL(gotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID)), SLOT(handleGotInferiorPid(Ios::IosToolHandler*,QString,QString,Q_PID))); connect(m_toolHandler, SIGNAL(toolExited(Ios::IosToolHandler*,int)), SLOT(handleToolExited(Ios::IosToolHandler*,int))); connect(m_toolHandler, SIGNAL(finished(Ios::IosToolHandler*)), SLOT(handleFinished(Ios::IosToolHandler*))); m_toolHandler->requestRunApp(bundlePath(), extraArgs(), runType(), deviceId()); }
void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { // Get URL of the Resource directory of the .app bundle CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); if (fileUrl) { // Try to convert the URL to an absolute path UInt8 buf[MAXPATHLEN]; if (CFURLGetFileSystemRepresentation(fileUrl, true, buf, sizeof(buf))) { // Success: Add it to the search path Common::String bundlePath((const char *)buf); s.add("__OSX_BUNDLE__", new Common::FSDirectory(bundlePath), priority); } CFRelease(fileUrl); } }
void Download::didDecideDestination(const String& destination, bool allowOverwrite) { ASSERT(!destination.isEmpty()); if (destination.isEmpty()) return; m_allowOverwrite = allowOverwrite; m_destination = destination; m_bundlePath = destination + DownloadBundle::fileExtension(); RetainPtr<CFStringRef> bundlePath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(m_bundlePath.characters()), m_bundlePath.length(), kCFAllocatorNull)); RetainPtr<CFURLRef> bundlePathURL(AdoptCF, CFURLCreateWithFileSystemPath(0, bundlePath.get(), kCFURLWindowsPathStyle, false)); CFURLDownloadSetDestination(m_download.get(), bundlePathURL.get(), allowOverwrite); }
void IosRunner::start() { if (m_toolHandler) { m_toolHandler->stop(); emit finished(m_cleanExit); } m_cleanExit = false; m_qmlPort = 0; if (!QFileInfo::exists(m_bundleDir)) { TaskHub::addTask(Task::Warning, tr("Could not find %1.").arg(m_bundleDir), ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); emit finished(m_cleanExit); return; } if (m_device->type() == Ios::Constants::IOS_DEVICE_TYPE) { IosDevice::ConstPtr iosDevice = m_device.dynamicCast<const IosDevice>(); if (m_device.isNull()) { emit finished(m_cleanExit); return; } if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) m_qmlPort = iosDevice->nextPort(); } else { IosSimulator::ConstPtr sim = m_device.dynamicCast<const IosSimulator>(); if (sim.isNull()) { emit finished(m_cleanExit); return; } if (m_qmlDebugServices != QmlDebug::NoQmlDebugServices) m_qmlPort = sim->nextPort(); } m_toolHandler = new IosToolHandler(m_deviceType, this); connect(m_toolHandler, &IosToolHandler::appOutput, this, &IosRunner::handleAppOutput); connect(m_toolHandler, &IosToolHandler::didStartApp, this, &IosRunner::handleDidStartApp); connect(m_toolHandler, &IosToolHandler::errorMsg, this, &IosRunner::handleErrorMsg); connect(m_toolHandler, &IosToolHandler::gotServerPorts, this, &IosRunner::handleGotServerPorts); connect(m_toolHandler, &IosToolHandler::gotInferiorPid, this, &IosRunner::handleGotInferiorPid); connect(m_toolHandler, &IosToolHandler::toolExited, this, &IosRunner::handleToolExited); connect(m_toolHandler, &IosToolHandler::finished, this, &IosRunner::handleFinished); m_toolHandler->requestRunApp(bundlePath(), extraArgs(), runType(), deviceId()); }
void LoginState::createGUIWindow() { assert(pGui); // Load the previous login settings from login.cfg, if one exists std::string ipAddress(""), playerName("nameless newbie"); float colorSelection = 0.0f; Ogre::ConfigFile loginConfig; try { loginConfig.load(bundlePath() + "login.cfg"); ipAddress = loginConfig.getSetting("IPaddress"); playerName = loginConfig.getSetting("PlayerName"); if (!from_string<float>(colorSelection, loginConfig.getSetting("PlayerColor"), std::dec)) colorSelection = 0.0f; } catch (Ogre::FileNotFoundException e) {} pGui->setupLoginWindow(ipAddress, playerName, colorSelection); pGui->setLoginReceiver(this); mViewport = new MenuStateViewport(pSceneManager); }
void LoginState::attemptLogin(const std::string &ipAddress, const std::string &playerName) { int ret; net::NetData *netdata = NULL; // First, save our login settings, overwriting the previous file std::ofstream lastLoginSettings((bundlePath() + "login.cfg").c_str(), std::ios::trunc); lastLoginSettings << "IPaddress="<<ipAddress<<std::endl; lastLoginSettings << "PlayerName="<<playerName<<std::endl; lastLoginSettings << "PlayerColor="<<pGui->getColorSliderValue()<<std::endl; lastLoginSettings.close(); // attempt to actually connect to the server netdata = new net::NetData(net::NetData::CLIENT); pGui->addConsoleItem("Connecting to server " + ipAddress); ret = netdata->connect(ipAddress, 50740); switch(ret) { case 1: // success pGui->addConsoleItem("Connection to server succeeded"); break; default: std::stringstream out; out << ret; pGui->addConsoleItem("Connection to server failed: " + out.str()); return; } netdata->me.nick = playerName; netdata->me.color = getColorFromPseudoHue(pGui->getColorSliderValue()); netdata->me.changed = true; // Mark this info for transmission netdata->sendChanges(); // Send changes without waiting! // Then, login. getStateManager()->loginToGame(netdata); }
QIODevice *Bundle::openFile(enum Bundle::File file, QIODevice::OpenMode mode) const { QString fileName; switch (file) { case Bundle::MANIFEST: fileName = "manifest.json"; break; case Bundle::INFO: fileName = "appinfo.json"; break; case Bundle::APPJS: fileName = "pebble-js-app.js"; break; case Bundle::BINARY: fileName = b->manifest.value(type()).toObject().value("name").toString(); break; case Bundle::RESOURCES: fileName = b->manifest.value("resources").toObject().value("name").toString(); break; } QIODevice *dev = 0; QFileInfo bundlePath(path()); if (bundlePath.isDir()) { QDir bundleDir(path()); if (bundleDir.exists(fileName)) { dev = new QFile(bundleDir.absoluteFilePath(fileName)); } } else if (bundlePath.isFile()) { dev = new QuaZipFile(path(), fileName); } if (dev && !dev->open(QIODevice::ReadOnly | mode)) { delete dev; return 0; } return dev; }
void packScanDir( const char* path, list_t* dirList ) { struct dirent *pent; struct stat st; char* buf=malloc(sizeof(char)*2048); DIR *pdir= opendir( path ); if(pdir) { while( (pent=readdir(pdir)) ) { //We're not going to read hidden files or . / .. if(pent->d_name[0] != '.') { sprintf(buf, "%s/%s",path,pent->d_name); if(stat(buf, &st)==0) { if( (st.st_mode&S_IFDIR)==S_IFDIR ) { //Ignore the "wizznic" directory since it's allready added. if(strcmp( buf, "packs/000_wizznic" ) != 0) { char* pdstr = malloc( sizeof(char)*strlen(buf)+1 ); strcpy( pdstr, buf ); listAppendData( dirList, (void*)pdstr ); } } else if( (st.st_mode&S_IFREG) ) { //It's a file, let's try and see if it's a bundle. int l = strlen(buf); if( l > 4 && strcasecmp( &buf[l-4] ,".wiz" )==0 ) { l = debundle( buf, getUsrPackDir() ); if( l == BUNDLE_SUCCESS ) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Installed bundle '%s'.\n", buf); char* pdstr = malloc( sizeof(char)*strlen(buf)+1 ); strcpy( pdstr, bundlePath() ); listAppendData( dirList, (void*)pdstr ); unlink( buf ); } else if( l == BUNDLE_FAIL_CORRUPT ) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "The bundle file '%s' is corrupt, deleting it.\n", buf); unlink( buf ); } else if( l == BUNDLE_FAIL_UNSUPPORTED_VERSION ) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "The bundle file '%s' is not supported by this version of Wizznic, please try and update Wizznic.\n", buf); } else if( l == BUNDLE_FAIL_DIR_EXISTS ) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "The bundle file '%s' has already been installed.\n", buf); } bundlePathReset(); } } } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "packScanDir(); Error: stat('%s') failed!\n", buf); } } } closedir(pdir); } free(buf); }
std::string resourcePath() { return bundlePath(); }