int main(int argc, char** argv) { QSafeApplication safeApp(argc, argv); safeApp.setApplicationName("CoreApp"); safeApp.setOrganizationName("DKFZ"); // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); Poco::Path provFile(basePath); provFile.setFileName("CoreApp.provisioning"); Poco::Util::MapConfiguration* coreConfig(new Poco::Util::MapConfiguration()); coreConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); coreConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.application"); // Preload the org.mitk.gui.qt.common plug-in (and hence also Qmitk) to speed // up a clean-cache start. This also works around bugs in older gcc and glibc implementations, // which have difficulties with multiple dynamic opening and closing of shared libraries with // many global static initializers. It also helps if dependent libraries have weird static // initialization methods and/or missing de-initialization code. coreConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY, "liborg_mitk_gui_qt_common"); return berry::Starter::Run(argc, argv, coreConfig); }
//============================================================================ // FUNCTION : SPELLutils::fileCopy //============================================================================ void SPELLutils::copyFile( const std::string& sourcePath, const std::string& targetPath ) { if (!pathExists(sourcePath)) { THROW_EXCEPTION("Cannot copy file", "File not found: " + sourcePath, SPELL_ERROR_FILESYSTEM); } if (!pathExists( basePath( targetPath ))) { THROW_EXCEPTION("Cannot copy file", "Target directory not found: " + basePath(targetPath), SPELL_ERROR_FILESYSTEM); } std::ifstream infile( sourcePath.c_str() , std::ios_base::binary); std::ofstream outfile( targetPath.c_str(), std::ios_base::binary); outfile << infile.rdbuf(); outfile.flush(); outfile.close(); }
void Forest::createNewFile() { // Release the current file if we have one. mData = NULL; // We need to construct a default file name String missionName( Con::getVariable( "$Client::MissionFile" ) ); String levelDirectory( Con::getVariable( "$pref::Directories::Level" ) ); if ( levelDirectory.isEmpty() ) { levelDirectory = "levels"; } missionName.replace( "tools/levels", levelDirectory ); missionName = Platform::makeRelativePathName(missionName, Platform::getMainDotCsDir()); Torque::Path basePath( missionName ); String fileName = Torque::FS::MakeUniquePath( basePath.getPath(), basePath.getFileName(), "forest" ); mDataFileName = StringTable->insert( fileName ); ForestData *file = new ForestData; file->write( mDataFileName ); delete file; mData = ResourceManager::get().load( mDataFileName ); mZoningDirty = true; }
int main(int argc, char** argv) { // Create a QApplication instance first QtSafeApplication qSafeApp(argc, argv); qSafeApp.setApplicationName("ExtApp"); qSafeApp.setOrganizationName("DKFZ"); // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); Poco::Path provFile(basePath); provFile.setFileName("ExtApp.provisioning"); Poco::Path extPath(basePath); extPath.pushDirectory("ExtBundles"); std::string pluginDirs = extPath.toString(); Poco::Util::MapConfiguration* extConfig(new Poco::Util::MapConfiguration()); extConfig->setString(berry::Platform::ARG_PLUGIN_DIRS, pluginDirs); extConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); extConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.extapplication"); return berry::Starter::Run(argc, argv, extConfig); }
QString WebService::installPrefix() const { #ifndef Q_OS_WIN32DOWS QDir binaryPath(QCoreApplication::applicationDirPath()); if (binaryPath.cdUp()) { 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(); }
/** * @brief Installs the tranlators. * * Installs both the translator for the application and the translator for Qt strings. */ void Qpamat::installTranslations() { // translation static QTranslator translator(0), ttranslator(0); QString loc = QTextCodec::locale(); QString localDirs[] = { qApp->applicationDirPath(), // not installed basePath() + "/share/qpamat/translations/" // installed }; for (unsigned int i = 0; i < ARRAY_SIZE(localDirs); i++) { if (translator.load(loc, localDirs[i])) { break; } } QString dirs[] = { QString("/usr/share/qt4/translations"), QString("/usr/share/qt/translations"), QString(getenv("QTDIR")) + "/translations/", qApp->applicationDirPath() + "/../share/qpamat/translations/" }; for (unsigned int i = 0; i < ARRAY_SIZE(dirs); i++) { QDir test(dirs[i]); if (test.exists()) { ttranslator.load(QString("qt_") + loc, dirs[i]); break; } } qApp->installTranslator(&translator); qApp->installTranslator(&ttranslator); }
void TerrainFile::create( String *inOutFilename, U32 newSize, const Vector<String> &materials ) { // Determine the path and basename - first try using the input filename (mission name) Torque::Path basePath( *inOutFilename ); if ( !basePath.getExtension().equal("mis") ) { // Use the default path and filename String terrainDirectory( Con::getVariable( "$pref::Directories::Terrain" ) ); if ( terrainDirectory.isEmpty() ) { terrainDirectory = "art/terrains"; } basePath.setPath( terrainDirectory ); basePath.setFileName( "terrain" ); } // Construct a default file name (*inOutFilename) = Torque::FS::MakeUniquePath( basePath.getRootAndPath(), basePath.getFileName(), "ter" ); // Create the file TerrainFile *file = new TerrainFile; for ( U32 i=0; i < materials.size(); i++ ) file->mMaterials.push_back( TerrainMaterial::findOrCreate( materials[i] ) ); file->setSize( newSize, true ); file->save( *inOutFilename ); delete file; }
void DirectoryScanner::endElement() { switch (--depth) { case 1: { QString basePath( type == "registry" ? regBaseFinder.GetBasePath() : fsBaseFinder.GetBasePath()); if(!basePath.isEmpty()) { dirs.push_back(QVariantList() << basePath << include.join('|') << exclude.join('|')); } include.clear(); exclude.clear(); break; } case 0: if (dirs.length() > 0) { QVariantList entry; entry << name << title; entry.push_back(dirs); result.push_back(entry); dirs.clear(); } break; default: break; } }
bool Model::Import3DFromFile( const std::string& pFile) { static bool first = true; if(first) { first = false; setupShaders(); } std::ifstream fin(pFile.c_str()); if(!fin.fail()) { fin.close(); } else{ printf("Couldn't open file: %s\n", pFile.c_str()); printf("%s\n", importer.GetErrorString()); return false; } scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality); if( !scene) { printf("%s\n", importer.GetErrorString()); return false; } // Now we can access the file's contents. printf("Import of scene %s succeeded.\n",pFile.c_str()); #ifdef __APPLE__ boost::filesystem::path p(pFile); std::string basePath = p.parent_path().string()+"/"; #else char path[2000]; wchar_t wpath[2000]; strcpy(path, pFile.c_str()); mbstowcs(wpath, path, strlen(path)+1);//Plus null LPWSTR ptr = wpath; PathRemoveFileSpec(ptr); std::wstring backToString(ptr); std::string basePath(std::string(backToString.begin(),backToString.end())+"\\"); #endif printf("Import textures of scene %s...\n",pFile.c_str()); LoadGLTextures(scene, basePath); printf("Import textures of scene %s done.\n",pFile.c_str()); printf("Import generating VAOs for scene %s...\n",pFile.c_str()); genVAOsAndUniformBuffer(scene); printf("Import generating VAOs for scene %s done.\n",pFile.c_str()); if(!checkForErrors()) { std::cerr << "Problem loading model..." << std::endl; exit(1); } return true; }
int main(int argc, char** argv) { // Create a QApplication instance first QtSafeApplication qSafeApp(argc, argv); qSafeApp.setApplicationName("MITK Workbench"); qSafeApp.setOrganizationName("DKFZ"); // This function checks if an instance is already running // and either sends a message to it (containing the command // line arguments) or checks if a new instance was forced by // providing the BlueBerry.newInstance command line argument. // In the latter case, a path to a temporary directory for // the new application's storage directory is returned. QString storageDir = handleNewAppInstance(&qSafeApp, argc, argv, "BlueBerry.newInstance"); // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); Poco::Path provFile(basePath); provFile.setFileName("mitkWorkbench.provisioning"); Poco::Path extPath(basePath); extPath.pushDirectory("ExtBundles"); std::string pluginDirs = extPath.toString(); Poco::Util::MapConfiguration* extConfig(new Poco::Util::MapConfiguration()); if (!storageDir.isEmpty()) { extConfig->setString(berry::Platform::ARG_STORAGE_DIR, storageDir.toStdString()); } extConfig->setString(berry::Platform::ARG_PLUGIN_DIRS, pluginDirs); extConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); extConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.extapplication"); #ifdef Q_OS_WIN #define CTK_LIB_PREFIX #else #define CTK_LIB_PREFIX "lib" #endif // Preload the org.mitk.gui.qt.ext plug-in (and hence also QmitkExt) to speed // up a clean-cache start. This also works around bugs in older gcc and glibc implementations, // which have difficulties with multiple dynamic opening and closing of shared libraries with // many global static initializers. It also helps if dependent libraries have weird static // initialization methods and/or missing de-initialization code. extConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY, "liborg_mitk_gui_qt_ext," CTK_LIB_PREFIX "CTKDICOMCore:0.1"); // Seed the random number generator, once at startup. QTime time = QTime::currentTime(); qsrand((uint)time.msec()); // Run the workbench. return berry::Starter::Run(argc, argv, extConfig); }
wxString CompileTargetBase::GetBasePath() const { if (m_Filename.IsEmpty()) return _T("."); wxFileName basePath(m_Filename); wxString base = basePath.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR); return !base.IsEmpty() ? base : _T("."); }
wxFileName FileViewer::GetFilename(wxString ref) const { if ( ref.length() >= 3 && ref[1] == _T(':') && (ref[2] == _T('\\') || ref[2] == _T('/')) ) { // This is an absolute Windows path (c:\foo... or c:/foo...); fix // the latter case. ref.Replace("/", "\\"); } wxPathFormat pathfmt = ref.Contains(_T('\\')) ? wxPATH_WIN : wxPATH_UNIX; wxFileName filename(ref.BeforeLast(_T(':')), pathfmt); if ( filename.IsRelative() ) { wxFileName relative(filename); wxString basePath(m_basePath); // Sometimes, the path in source reference is not relative to the PO // file's location, but is relative to e.g. the root directory. See // https://code.djangoproject.com/ticket/13936 for exhaustive // discussion with plenty of examples. // // Deal with this by trying parent directories of m_basePath too. So if // a file named project/locales/cs/foo.po has a reference to src/main.c, // try not only project/locales/cs/src/main.c, but also // project/locales/src/main.c and project/src/main.c etc. while ( !basePath.empty() ) { filename = relative; filename.MakeAbsolute(basePath); if ( filename.FileExists() ) { break; // good, found the file } else { // remove the last path component size_t last = basePath.find_last_of("\\/"); if ( last == wxString::npos ) break; else basePath.erase(last); } } } return filename; }
void Win32EnumPorts( std::list<Int32>& portlist ) { portlist.clear(); // use querydosdevice on NT/2000/xp (no need to open ports...) if ( VER_PLATFORM_WIN32_NT == Win32GetOSVersion() ) { const int bufferSize = 65535; CORE::CDynamicBuffer deviceNameBuffer( bufferSize, true ); // Read the list of devices into the buffer Int32 len = ::QueryDosDevice( 0, deviceNameBuffer.AsTypePtr< char >(), bufferSize ); for ( Int32 n=0; n<len; ++n ) { // if found "COM", then add number to list if ( 0 == _stricmp( deviceNameBuffer.AsConstTypePtr< char >( n ), "COM" ) ) { portlist.push_back( atoi( deviceNameBuffer.AsConstTypePtr< char >( n+3 ) ) ); } // find next null pointer while ( deviceNameBuffer.AsConstType< char >( n ) != '\0' ) { ++n; } } } // else, open port 1-255 else { CORE::CString basePath( "\\\\.\\COM" ); for ( Int32 i=1; i<255; ++i ) { CORE::CString portPath = basePath + CORE::Int32ToString( i ); // try to open port bool result = false; ::HANDLE handle = ::CreateFile( portPath.C_String(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0 ); if ( INVALID_HANDLE_VALUE == handle ) continue; ::CloseHandle( handle ); portlist.push_back( i ); } } }
int main(int argc, char** argv) { std::string basePath(Poco::Environment::get("OMMTEST")); Poco::DirectoryIterator end; std::vector<std::string> videoFiles; std::string videoPath = basePath + "/video"; Poco::DirectoryIterator videoDir(videoPath); while(videoDir != end) { videoFiles.push_back(videoPath + "/" + videoDir.name()); ++videoDir; } std::vector<std::string> audioFiles; std::string audioPath = basePath + "/audio"; Poco::DirectoryIterator audioDir(audioPath); while(audioDir != end) { audioFiles.push_back(audioPath + "/" + audioDir.name()); ++audioDir; } std::vector<std::string> liveTv; for (int i = 0; i < 10; ++i) { liveTv.push_back(liveStreamAddress + Poco::NumberFormatter::format(i) + "$0"); } std::vector<std::string> allStreams; for (std::vector<std::string>::iterator it = audioFiles.begin(); it != audioFiles.end(); ++it) { allStreams.push_back(*it); } for (std::vector<std::string>::iterator it = videoFiles.begin(); it != videoFiles.end(); ++it) { allStreams.push_back(*it); } AvStreamEngine engine; engine.createPlayer(); // seqPlay(engine, audioFiles); // randPlay(engine, audioFiles); // seqPlay(engine, videoFiles); // randPlay(engine, videoFiles); // seqPlay(engine, liveTv); randPlay(engine, liveTv, 20); // seqPlay(engine, allStreams); // randPlay(engine, allStreams); engine.destructPlayer(); }
bool Router::do_proc(HttpTask* task) { std::string basePath("D:"); domainRouter* router = defaultRouter; std::string hostName = task->request.getHost(); int cPos; if ((cPos = hostName.rfind(':')) != std::string::npos) { task->serverPort = stoi(hostName.substr(cPos + 1)); hostName = hostName.substr(0, cPos); } else{ task->serverPort = 80; } task->hostName = hostName; auto p = vServers.find(hostName); if (p != vServers.end()) router = p->second; if (router == NULL) { writeError(task, HTTPErrorCode::InternalServerError, NULL, 0); return false; } if (!router->getLocalPath(task->request.getRequestURI(), task)) { writeError(task, HTTPErrorCode::Forbidden, NULL, 0); return false; } int pos = task->LocalPath.rfind('.'); if (pos != std::string::npos) task->extName = task->LocalPath.substr(pos); task->doCgi = task->doCgi && cgiExt.find(task->extName) != cgiExt.end(); for (auto i = task->LocalPath.begin(); i != task->LocalPath.end(); i++) if ((*i) == '/') (*i) = '\\'; return true; }
bool PosixFileSystem::DeleteDirectory_r(const char *nativePath) { RAD_ASSERT(nativePath); String basePath(CStr(nativePath)); if (basePath.empty) return false; FileSearch::Ref s = OpenSearch( (basePath + "/*.*").c_str, kSearchOption_Recursive, kFileOption_NativePath, 0 ); if (s) { if (*(basePath.end.get()-1) != '/') basePath += '/'; String name; FileAttributes fa; while (s->NextFile(name, &fa, 0)) { String path = basePath + name; if (fa & kFileAttribute_Directory) { if (!DeleteDirectory_r(path.c_str)) return false; } else { if (unlink(path.c_str) != 0) { std::cerr << "ERROR: unable to remove file: " << path.c_str.get() << std::endl; } } } s.reset(); } if (unlink(nativePath)) { std::cerr << "ERROR: unable to remove directory: " << nativePath << std::endl; } return true; }
/*------------------------------------------------------------Solver::resolve-+ | | +----------------------------------------------------------------------------*/ istream * Solver::resolve( UnicodeString path, UnicodeString const & basePath ) { if (path.good()) { UCS_2 const * p0 = basePath; for (UCS_2 const * p = p0 + basePath.length(); p > p0; --p) { if ((*p == (UCS_2)'/') || (*p == (UCS_2)'\\')) { path = basePath(0, p-basePath+1) + path; // insert the directory break; } } return new ifstream( MultibyteString(path, encLocale).inqString(), ios::in | ios::binary | ios::nocreate ); } return 0; }
QString Config::plexydeskBasePath() { #ifndef Q_WS_X11 QDir binaryPath (QCoreApplication::applicationDirPath()); if (binaryPath.cdUp()) { qDebug() << Q_FUNC_INFO << QDir::toNativeSeparators(binaryPath.canonicalPath()); return QDir::toNativeSeparators(binaryPath.canonicalPath()); } #endif #ifdef Q_WS_X11 QString basePath(qgetenv("PLEXYDESK_DIR")); if (basePath.isEmpty() || basePath.isNull()) { return PLEXYPREFIX; } return basePath; #endif }
int main(int argc, char** argv) { QSafeApplication safeApp(argc, argv); safeApp.setApplicationName("CoreApp"); safeApp.setOrganizationName("DKFZ"); // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); Poco::Path provFile(basePath); provFile.setFileName("CoreApp.provisioning"); Poco::Util::MapConfiguration* coreConfig(new Poco::Util::MapConfiguration()); coreConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); coreConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.application"); return berry::Starter::Run(argc, argv, coreConfig); }
int main(int argc, char** argv) { // Create a QApplication instance first QApplication myApp(argc, argv); myApp.setApplicationName("$(project-app-name)"); myApp.setOrganizationName("$(vendor)"); // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); Poco::Path provFile(basePath); provFile.setFileName("$(project-app-name).provisioning"); Poco::Util::MapConfiguration* sbConfig(new Poco::Util::MapConfiguration()); sbConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); sbConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.extapplication"); return berry::Starter::Run(argc, argv, sbConfig); }
void EbookController::OnClickedLink(int pageNo, DrawInstr *link) { ScopedMem<WCHAR> url(str::conv::FromHtmlUtf8(link->str.s, link->str.len)); if (url::IsAbsolute(url)) { EbookTocDest dest(nullptr, url); cb->GotoLink(&dest); return; } if (Doc_Epub == doc.Type() && pages && (size_t)pageNo <= pages->Count()) { // normalize the URL by combining it with the chapter's base path for (int j = pageNo; j > 0; j--) { HtmlPage *p = pages->At(j - 1); // <pagebreak src="..." page_marker /> is usually the second instruction on a page for (size_t k = 0; k < std::min((size_t)2, p->instructions.Count()); k++) { DrawInstr& di = p->instructions.At(k); if (InstrAnchor == di.type && str::StartsWith(di.str.s + di.str.len, "\" page_marker />")) { ScopedMem<char> basePath(str::DupN(di.str.s, di.str.len)); ScopedMem<char> relPath(ResolveHtmlEntities(link->str.s, link->str.len)); ScopedMem<char> absPath(NormalizeURL(relPath, basePath)); url.Set(str::conv::FromUtf8(absPath)); j = 0; // done break; } } } } int idx = ResolvePageAnchor(url); if (-1 == idx && str::FindChar(url, '%')) { url::DecodeInPlace(url); idx = ResolvePageAnchor(url); } if (idx != -1) { EbookTocDest dest(nullptr, idx); cb->GotoLink(&dest); } }
void go( int portNumber, const char* directory ) { printf("Creating objects ...\n"); SystemThreadApi threadApi; RawSocketApi socketApi; HttpSocketReader socketReader( socketApi ); HttpResponseSocketWriter socketWriter( socketApi ); SystemDirectoryApi directoryApi; SystemFileFactory fileFactory; SystemFileApi fileApi( fileFactory ); std::string basePath( directory ); HttpRequestParserImpl requestParser; HttpRequestHandlerFactoryImpl requestHandlerFactory( basePath, fileApi, directoryApi ); StlWorkItemQueue workItemQueue; unsigned numberOfThreads = 50; SystemSlaveThreadFactory slaveThreadFactory( threadApi ); ThreadPool threadPool( threadApi, slaveThreadFactory, workItemQueue, numberOfThreads ); ThreadedRequestHandler connectionhandler ( socketReader, requestParser, requestHandlerFactory, socketWriter, threadPool ); SocketConnectionReceiver receiver( socketApi, portNumber ); printf("Creating server...\n"); Server server( receiver, connectionhandler ); printf("Starting server (you won't see a Server Started message :) )...\n"); server.start(); }
EXPORT_C CUrl* CUrl::ResolveL(CUrl& aBaseUrl, CUrl& aRelativeUrl) // // Based on the relative parsing algorithm in RFC2396 { // Return copy of aRelativeUrl if aBaseUrl is empty if (aBaseUrl.UrlDes().Compare(KNullDesC)==0) return aRelativeUrl.AllocL(); TPtrC relativeUrl(aRelativeUrl.UrlDes()); TPtrC relPath(aRelativeUrl.Component(EUrlPath)); TPtrC relAuth(aRelativeUrl.Component(EUrlAuthority)); TPtrC relScheme(aRelativeUrl.Component(EUrlScheme)); TPtrC relQuery(aRelativeUrl.Component(EUrlQuery)); TPtrC relFragment(aRelativeUrl.Component(EUrlFragment)); if (relScheme.Length() > 0) { // LOOPHOLE in RFC 1630 if schemes match then remove the scheme from the relative url if (aBaseUrl.UrlDes().FindF(relScheme) == 0) relativeUrl.Set(relativeUrl.Mid(relScheme.Length() + 1)); // remove the ':' as well else // the relative url is absolute return NewL(relativeUrl); } TBool useBaseAuth = ETrue; TBool useRelQuery = ETrue; TPtrC basePath(aBaseUrl.Component(EUrlPath)); HBufC* resolvedPath = NULL; if (relPath.Compare(KNullDesC)==0 && relAuth.Compare(KNullDesC)==0 && relScheme.Compare(KNullDesC)==0 && relQuery.Compare(KNullDesC)==0) // relative URL could just be a fragment { // Use current document url (assume that it is aBaseUrl), including query, then add relative URL fragment useRelQuery = EFalse; resolvedPath = basePath.AllocLC(); } else if (relativeUrl.Find(KUrlLoc) == 0) // relative url is a network path { // Set resolved path to be the relative path useBaseAuth = EFalse; resolvedPath = relPath.AllocLC(); } else if (relPath.Locate('/') == 0) // relative url is an absolute path { resolvedPath = relPath.AllocLC(); } else { // Do path resolution, merge the base path and relative path if (relPath.Length() != 0) // if the relative path is a query or fragment then shouldn't strip the document from the basePath { TInt endBasePath = basePath.LocateReverse('/'); if (endBasePath != KErrNotFound) basePath.Set(basePath.Left(endBasePath + 1)); // keep the '/' else basePath.Set(_L("/")); // Create path of just '/' } // Resolve relative path against base path resolvedPath = HBufC::NewLC(relPath.Length() + basePath.Length()); TRelativePaths relativePaths(basePath, relPath, resolvedPath->Des()); relativePaths.ResolveRelativePaths(); } // put the url together TPtrC baseScheme(aBaseUrl.Component(EUrlScheme)); TPtrC baseAuth(aBaseUrl.Component(EUrlAuthority)); TPtrC baseQuery(aBaseUrl.Component(EUrlQuery)); HBufC* resolvedUrl = HBufC::NewLC(aBaseUrl.UrlDes().Length() + relativeUrl.Length() + KUrlColon().Length() + KUrlLoc().Length() + KUrlQMark().Length() + KUrlHash().Length() + 1); // this will be long enough - extra 1 just in case basePath was empty TPtr resolvedBuf = resolvedUrl->Des(); if (baseScheme.Length() > 0) { resolvedBuf.Append(baseScheme); resolvedBuf.Append(KUrlColon); } resolvedBuf.Append(KUrlLoc); if (useBaseAuth && baseAuth.Length() >0) { resolvedBuf.Append(baseAuth); } else if (relAuth.Length() > 0) { resolvedBuf.Append(relAuth); } resolvedBuf.Append(*resolvedPath); if (useRelQuery && relQuery.Length() >0) { resolvedBuf.Append(KUrlQMark); resolvedBuf.Append(relQuery); } else if (!useRelQuery && baseQuery.Length() >0) { resolvedBuf.Append(KUrlQMark); resolvedBuf.Append(baseQuery); } if (relFragment.Length() >0) { resolvedBuf.Append(KUrlHash); resolvedBuf.Append(relFragment); } CUrl * url = CUrl::NewL(*resolvedUrl); CleanupStack::PopAndDestroy(2); // resolvedUrl, resolvedPath return url; }
ManagerFrame::ManagerFrame( wxWindow* parent ): BaseManagerFrame(parent), m_replayProvider(NULL) { SetTitle(wxTheApp->GetAppDisplayName()); SetStatusBar(m_statusBar); #ifdef __WXMSW__ SetIcon(wxIcon("APPICON")); #endif // Initalize default size / position SetMinClientSize(wxDLG_UNIT(this, wxSize(200, 100))); SetClientSize(wxDLG_UNIT(this, wxSize(480, 280))); m_treeSplitter->SetSashPosition(wxDLG_UNIT(this, wxSize(120, -1)).GetWidth()); int sashHeight = GetClientSize().GetHeight() - m_toolBar->GetSize().GetHeight() - wxDLG_UNIT(this, wxSize(-1, 80)).GetHeight(); m_splitter->SetSashPosition(sashHeight); Center(); // Disconnect wxFormBuilder idle events m_treeSplitter->Disconnect(wxEVT_IDLE, wxIdleEventHandler(BaseManagerFrame::m_treeSplitterOnIdle), NULL, this); m_splitter->Disconnect(wxEVT_IDLE, wxIdleEventHandler(BaseManagerFrame::m_splitterOnIdle), NULL, this); wxPersistentRegisterAndRestore(this); wxPersistentRegisterAndRestore(m_treeSplitter); wxPersistentRegisterAndRestore(m_splitter); m_providerDV->AppendIconTextColumn(_("Category"), PCIDescription, wxDATAVIEW_CELL_INERT, wxDLG_UNIT(this, wxSize(80, -1)).GetWidth()); wxSizeEvent sizeEvt; OnProviderSizeChanged(sizeEvt); m_replayDV->AppendTextColumn(_("Arena"), RCIArena, wxDATAVIEW_CELL_INERT, wxDLG_UNIT(this, wxSize(80, -1)).GetWidth())->SetFlags(wxCOL_DEFAULT_FLAGS | wxCOL_SORTABLE); m_replayDV->AppendTextColumn(_("Team Size"), RCITeamSize, wxDATAVIEW_CELL_INERT, wxDLG_UNIT(this, wxSize(20, -1)).GetWidth(), wxALIGN_RIGHT)->SetFlags(wxCOL_DEFAULT_FLAGS | wxCOL_SORTABLE); m_replayDV->AppendTextColumn(_("Score"), RCIScore, wxDATAVIEW_CELL_INERT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth(), wxALIGN_CENTER)->SetFlags(wxCOL_DEFAULT_FLAGS | wxCOL_SORTABLE); m_replayDV->AppendTextColumn(_("Length"), RCILength, wxDATAVIEW_CELL_INERT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth())->SetFlags(wxCOL_DEFAULT_FLAGS | wxCOL_SORTABLE); wxDataViewColumn* dateColumn = m_replayDV->AppendTextColumn(_("Date"), RCIDate, wxDATAVIEW_CELL_INERT, wxDLG_UNIT(this, wxSize(60, -1)).GetWidth()); dateColumn->SetFlags(wxCOL_DEFAULT_FLAGS | wxCOL_SORTABLE); dateColumn->SetSortOrder(false); m_replayDV->AppendTextColumn(_("Description"), RCIDescription); m_goalListCtrl->AppendColumn(_("Player"), wxLIST_FORMAT_CENTER, wxDLG_UNIT(this, wxSize(80, -1)).GetWidth()); m_goalListCtrl->AppendColumn(_("Score"), wxLIST_FORMAT_CENTER, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth()); m_goalListCtrl->AppendColumn(_("Team"), wxLIST_FORMAT_RIGHT, wxDLG_UNIT(this, wxSize(20, -1)).GetWidth()); m_goalListCtrl->AppendColumn(_("Time"), wxLIST_FORMAT_LEFT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth()); m_statsListCtrl->AppendColumn(_("Player"), wxLIST_FORMAT_LEFT, wxDLG_UNIT(this, wxSize(80, -1)).GetWidth()); m_statsListCtrl->AppendColumn(_("Score"), wxLIST_FORMAT_RIGHT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth()); m_statsListCtrl->AppendColumn(_("Goals"), wxLIST_FORMAT_RIGHT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth()); m_statsListCtrl->AppendColumn(_("Saves"), wxLIST_FORMAT_RIGHT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth()); m_statsListCtrl->AppendColumn(_("Assists"), wxLIST_FORMAT_RIGHT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth()); m_statsListCtrl->AppendColumn(_("Shots on Goal"), wxLIST_FORMAT_RIGHT, wxDLG_UNIT(this, wxSize(28, -1)).GetWidth()); m_statsListCtrl->AppendColumn(_("Team"), wxLIST_FORMAT_RIGHT, wxDLG_UNIT(this, wxSize(20, -1)).GetWidth()); wxFileName basePath(wxStandardPaths::Get().GetDocumentsDir(), ""); basePath.AppendDir("My Games"); basePath.AppendDir("Rocket League"); basePath.AppendDir("TAGame"); basePath.AppendDir("Demos"); // Prepare various UI elements m_menubar->Check(ID_AUTO_UPLOAD, wxConfig::Get()->ReadBool("AutoUpload", false)); m_toolBar->EnableTool(ID_EXPORT, false); m_toolBar->EnableTool(ID_UPLOAD, false); m_toolBar->EnableTool(wxID_DELETE, false); ReplayProvider::Ptr activeReplays(new ReplayProvider(&m_replayProvider, basePath.GetFullPath(), "Active Game Replays")); m_replayProvider.provider.push_back(activeReplays); if (activeReplays->replay.empty()) wxLogError(_("No replays could be found")); ReplayProvider::Ptr archiveRoot(new ReplayProvider(&m_replayProvider, "", "Replay Archive")); m_replayProvider.provider.push_back(archiveRoot); wxObjectDataPtr<ProviderDataModel> provModel(new ProviderDataModel(&m_replayProvider)); m_providerDV->AssociateModel(provModel.get()); m_providerDV->Select(wxDataViewItem(activeReplays.get())); wxDataViewEvent dvEvt; dvEvt.SetItem(wxDataViewItem(activeReplays.get())); OnProviderSelectionChanged(dvEvt); m_replayDV->SetFocus(); m_menubar->Enable(ID_NEW_CATEGORY, false); m_toolBar->EnableTool(ID_NEW_CATEGORY, false); m_replayProvider.Bind(wxEVT_REPLAY_ADDED, &ManagerFrame::OnReplayAdded, this); m_replayProvider.Bind(wxEVT_REPLAY_REMOVED, &ManagerFrame::OnReplayRemoved, this); TransferManager::Get().Bind(wxEVT_TRANSFER_UPDATE, &ManagerFrame::OnTransferUpdate, this); m_replayDV->SetDropTarget(new ReplayDropTarget(m_replayDV)); }
/// Creates difference images, returns the number that have a 0 metric. /// If outputDir.isEmpty(), don't write out diff files. static void create_diff_images (DiffMetricProc dmp, const int colorThreshold, RecordArray* differences, const SkString& baseDir, const SkString& comparisonDir, const SkString& outputDir, const StringArray& matchSubstrings, const StringArray& nomatchSubstrings, bool recurseIntoSubdirs, bool getBounds, bool verbose, DiffSummary* summary) { SkASSERT(!baseDir.isEmpty()); SkASSERT(!comparisonDir.isEmpty()); FileArray baseFiles; FileArray comparisonFiles; get_file_list(baseDir, matchSubstrings, nomatchSubstrings, recurseIntoSubdirs, &baseFiles); get_file_list(comparisonDir, matchSubstrings, nomatchSubstrings, recurseIntoSubdirs, &comparisonFiles); if (!baseFiles.isEmpty()) { qsort(baseFiles.begin(), baseFiles.count(), sizeof(SkString*), SkCastForQSort(compare_file_name_metrics)); } if (!comparisonFiles.isEmpty()) { qsort(comparisonFiles.begin(), comparisonFiles.count(), sizeof(SkString*), SkCastForQSort(compare_file_name_metrics)); } int i = 0; int j = 0; while (i < baseFiles.count() && j < comparisonFiles.count()) { SkString basePath(baseDir); SkString comparisonPath(comparisonDir); DiffRecord *drp = new DiffRecord; int v = strcmp(baseFiles[i]->c_str(), comparisonFiles[j]->c_str()); if (v < 0) { // in baseDir, but not in comparisonDir drp->fResult = DiffRecord::kCouldNotCompare_Result; basePath.append(*baseFiles[i]); comparisonPath.append(*baseFiles[i]); drp->fBase.fFilename = *baseFiles[i]; drp->fBase.fFullPath = basePath; drp->fBase.fStatus = DiffResource::kExists_Status; drp->fComparison.fFilename = *baseFiles[i]; drp->fComparison.fFullPath = comparisonPath; drp->fComparison.fStatus = DiffResource::kDoesNotExist_Status; VERBOSE_STATUS("MISSING", ANSI_COLOR_YELLOW, baseFiles[i]); ++i; } else if (v > 0) { // in comparisonDir, but not in baseDir drp->fResult = DiffRecord::kCouldNotCompare_Result; basePath.append(*comparisonFiles[j]); comparisonPath.append(*comparisonFiles[j]); drp->fBase.fFilename = *comparisonFiles[j]; drp->fBase.fFullPath = basePath; drp->fBase.fStatus = DiffResource::kDoesNotExist_Status; drp->fComparison.fFilename = *comparisonFiles[j]; drp->fComparison.fFullPath = comparisonPath; drp->fComparison.fStatus = DiffResource::kExists_Status; VERBOSE_STATUS("MISSING", ANSI_COLOR_YELLOW, comparisonFiles[j]); ++j; } else { // Found the same filename in both baseDir and comparisonDir. SkASSERT(DiffRecord::kUnknown_Result == drp->fResult); basePath.append(*baseFiles[i]); comparisonPath.append(*comparisonFiles[j]); drp->fBase.fFilename = *baseFiles[i]; drp->fBase.fFullPath = basePath; drp->fBase.fStatus = DiffResource::kExists_Status; drp->fComparison.fFilename = *comparisonFiles[j]; drp->fComparison.fFullPath = comparisonPath; drp->fComparison.fStatus = DiffResource::kExists_Status; SkAutoDataUnref baseFileBits(read_file(drp->fBase.fFullPath.c_str())); if (baseFileBits) { drp->fBase.fStatus = DiffResource::kRead_Status; } SkAutoDataUnref comparisonFileBits(read_file(drp->fComparison.fFullPath.c_str())); if (comparisonFileBits) { drp->fComparison.fStatus = DiffResource::kRead_Status; } if (NULL == baseFileBits || NULL == comparisonFileBits) { if (NULL == baseFileBits) { drp->fBase.fStatus = DiffResource::kCouldNotRead_Status; VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, baseFiles[i]); } if (NULL == comparisonFileBits) { drp->fComparison.fStatus = DiffResource::kCouldNotRead_Status; VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[j]); } drp->fResult = DiffRecord::kCouldNotCompare_Result; } else if (are_buffers_equal(baseFileBits, comparisonFileBits)) { drp->fResult = DiffRecord::kEqualBits_Result; VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]); } else { AutoReleasePixels arp(drp); get_bitmap(baseFileBits, drp->fBase, SkImageDecoder::kDecodePixels_Mode); get_bitmap(comparisonFileBits, drp->fComparison, SkImageDecoder::kDecodePixels_Mode); VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]); if (DiffResource::kDecoded_Status == drp->fBase.fStatus && DiffResource::kDecoded_Status == drp->fComparison.fStatus) { create_and_write_diff_image(drp, dmp, colorThreshold, outputDir, drp->fBase.fFilename); } else { drp->fResult = DiffRecord::kCouldNotCompare_Result; } } ++i; ++j; } if (getBounds) { get_bounds(*drp); } SkASSERT(DiffRecord::kUnknown_Result != drp->fResult); differences->push(drp); summary->add(drp); } for (; i < baseFiles.count(); ++i) { // files only in baseDir DiffRecord *drp = new DiffRecord(); drp->fBase.fFilename = *baseFiles[i]; drp->fBase.fFullPath = baseDir; drp->fBase.fFullPath.append(drp->fBase.fFilename); drp->fBase.fStatus = DiffResource::kExists_Status; drp->fComparison.fFilename = *baseFiles[i]; drp->fComparison.fFullPath = comparisonDir; drp->fComparison.fFullPath.append(drp->fComparison.fFilename); drp->fComparison.fStatus = DiffResource::kDoesNotExist_Status; drp->fResult = DiffRecord::kCouldNotCompare_Result; if (getBounds) { get_bounds(*drp); } differences->push(drp); summary->add(drp); } for (; j < comparisonFiles.count(); ++j) { // files only in comparisonDir DiffRecord *drp = new DiffRecord(); drp->fBase.fFilename = *comparisonFiles[j]; drp->fBase.fFullPath = baseDir; drp->fBase.fFullPath.append(drp->fBase.fFilename); drp->fBase.fStatus = DiffResource::kDoesNotExist_Status; drp->fComparison.fFilename = *comparisonFiles[j]; drp->fComparison.fFullPath = comparisonDir; drp->fComparison.fFullPath.append(drp->fComparison.fFilename); drp->fComparison.fStatus = DiffResource::kExists_Status; drp->fResult = DiffRecord::kCouldNotCompare_Result; if (getBounds) { get_bounds(*drp); } differences->push(drp); summary->add(drp); } release_file_list(&baseFiles); release_file_list(&comparisonFiles); }
QString Plugin::absolutePath() const { return basePath() + "/" + relativePath(); }
bool SVNDiff::DiffFileAgainstBase( const CTSVNPath& filePath, svn_revnum_t & baseRev, bool ignoreprops, svn_wc_status_kind status /*= svn_wc_status_none*/, svn_wc_status_kind text_status /*= svn_wc_status_none*/, svn_wc_status_kind prop_status /*= svn_wc_status_none*/ ) { bool retvalue = false; bool fileexternal = false; if ((text_status == svn_wc_status_none)||(prop_status == svn_wc_status_none)) { SVNStatus stat; stat.GetStatus(filePath); if (stat.status == NULL) return false; text_status = stat.status->text_status; prop_status = stat.status->prop_status; fileexternal = stat.status->file_external != 0; } if (!ignoreprops && (prop_status > svn_wc_status_normal)) { DiffProps(filePath, SVNRev::REV_WC, SVNRev::REV_BASE, baseRev); } if (filePath.IsDirectory()) return true; if ((status >= svn_wc_status_normal) || (text_status >= svn_wc_status_normal)) { CTSVNPath basePath(SVN::GetPristinePath(filePath)); if (baseRev == 0) { SVNInfo info; const SVNInfoData * infodata = info.GetFirstFileInfo(filePath, SVNRev(), SVNRev()); if (infodata) { if (infodata->copyfromurl && infodata->copyfromurl[0]) baseRev = infodata->copyfromrev; else baseRev = infodata->lastchangedrev; } } // If necessary, convert the line-endings on the file before diffing // note: file externals can not be exported if (((DWORD)CRegDWORD(L"Software\\TortoiseSVN\\ConvertBase", TRUE)) && (!fileexternal)) { CTSVNPath temporaryFile = CTempFiles::Instance().GetTempFilePath(m_bRemoveTempFiles, filePath, SVNRev::REV_BASE); if (!m_pSVN->Export(filePath, temporaryFile, SVNRev(SVNRev::REV_BASE), SVNRev(SVNRev::REV_BASE))) { temporaryFile.Reset(); } else { basePath = temporaryFile; SetFileAttributes(basePath.GetWinPath(), FILE_ATTRIBUTE_READONLY); } } // for added/deleted files, we don't have a BASE file. // create an empty temp file to be used. if (!basePath.Exists()) { basePath = CTempFiles::Instance().GetTempFilePath(m_bRemoveTempFiles, filePath, SVNRev::REV_BASE); SetFileAttributes(basePath.GetWinPath(), FILE_ATTRIBUTE_READONLY); } CString name = filePath.GetFilename(); CTSVNPath wcFilePath = filePath; if (!wcFilePath.Exists()) { wcFilePath = CTempFiles::Instance().GetTempFilePath(m_bRemoveTempFiles, filePath, SVNRev::REV_BASE); SetFileAttributes(wcFilePath.GetWinPath(), FILE_ATTRIBUTE_READONLY); } CString n1, n2; n1.Format(IDS_DIFF_WCNAME, (LPCTSTR)name); if (baseRev) n2.FormatMessage(IDS_DIFF_BASENAMEREV, (LPCTSTR)name, baseRev); else n2.Format(IDS_DIFF_BASENAME, (LPCTSTR)name); retvalue = CAppUtils::StartExtDiff( basePath, wcFilePath, n2, n1, filePath, filePath, SVNRev::REV_BASE, SVNRev::REV_WC, SVNRev::REV_BASE, CAppUtils::DiffFlags().Wait().AlternativeTool(m_bAlternativeTool), m_JumpLine, name, L""); } return retvalue; }