QDebug DailyRollingFileAppender::debug(QDebug &rDebug) const { QString layout_name; if (layout()) layout_name = layout()->name(); QString codec_name; if (encoding()) codec_name = QLatin1String(encoding()->name()); rDebug.nospace() << "DailyRollingFileAppender(" << "name:" << name() << " " << "activedatepattern:" << mActiveDatePattern << " " << "appendfile:" << appendFile() << " " << "bufferedio:" << bufferedIo() << " " << "datepattern:" << datePattern() << " " << "encoding:" << codec_name << " " << "frequency:" << frequencyToString() << " " << "file:" << fileName() << " " << "filepath:" << filePath() << " " << "suffix:" << suffix() << " " << "fullFileName:" << fullFileName() << " " << "filter:" << firstFilter() << " " << "immediateflush:" << immediateFlush() << " " << "isactive:" << isActive() << " " << "isclosed:" << isClosed() << " " << "layout:" << layout_name << " " << "referencecount:" << referenceCount() << " " << "rollovertime:" << mRollOverTime << "threshold:" << threshold().toString() << "writer:" << writer() << ")"; return rDebug.space(); }
/* static */ void AutoCaptureMechanism::Save(wxBitmap* screenshot, const wxString& fileName) { // make sure default_dir exists if (!wxDirExists(default_dir)) wxMkdir(default_dir); wxFileName fullFileName(default_dir, "appear-" + fileName + "-" + wxPlatformInfo::Get().GetPortIdShortName() + ".png"); // do not overwrite already existing files with this name #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while (fullFileName.FileExists()) fullFileName.SetName(fullFileName.GetName() + "_"); // save the screenshot as a PNG screenshot->SaveFile(fullFileName.GetFullPath(), wxBITMAP_TYPE_PNG); }
GdkPixbuf* UIManager::getLocalPixbuf(const std::string& fileName) { // Try to use a cached pixbuf first PixBufMap::iterator i = _localPixBufs.find(fileName); if (i != _localPixBufs.end()) { return i->second; } // Not cached yet, load afresh // Construct the full filename using the Bitmaps path std::string fullFileName(GlobalRegistry().get(RKEY_BITMAPS_PATH) + fileName); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(fullFileName.c_str(), NULL); if (pixbuf != NULL) { _localPixBufs.insert(PixBufMap::value_type(fileName, pixbuf)); // Avoid destruction of this pixbuf g_object_ref(pixbuf); } else { globalErrorStream() << "Couldn't load pixbuf " << fullFileName << std::endl; } return pixbuf; }
GdkPixbuf* UIManager::getLocalPixbufWithMask(const std::string& fileName) { // Try to find a cached pixbuf before loading from disk PixBufMap::iterator i = _localPixBufsWithMask.find(fileName); if (i != _localPixBufsWithMask.end()) { return i->second; } // Not cached yet, load afresh std::string fullFileName(GlobalRegistry().get(RKEY_BITMAPS_PATH) + fileName); GdkPixbuf* rgb = gdk_pixbuf_new_from_file(fullFileName.c_str(), 0); if (rgb != NULL) { // File load successful, add alpha channel GdkPixbuf* rgba = gdk_pixbuf_add_alpha(rgb, TRUE, 255, 0, 255); gdk_pixbuf_unref(rgb); _localPixBufsWithMask.insert(PixBufMap::value_type(fileName, rgba)); // Avoid destruction of this pixbuf g_object_ref(rgba); return rgba; } else { // File load failed globalErrorStream() << "Couldn't load pixbuf " << fullFileName << std::endl; return NULL; } }
// ----------------------------------------------------------------------------- // CMmMtpDpMetadataAccessWrapper::AddObjectL // Add object (music, video, playlist and abstract media) info to DB // ----------------------------------------------------------------------------- // EXPORT_C void CMmMtpDpMetadataAccessWrapper::AddObjectL( const CMTPObjectMetaData& aObject ) { PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL" ) ); TMPXGeneralCategory category = Category( aObject ); TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) ); if ( category == EMPXVideo ) { PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL Addvideo" ) ); iMmMtpDpMetadataVideoAccess->AddVideoL( fullFileName ); } else if ( category == EMPXPlaylist || category == EMPXAbstractAlbum ) { PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddPlaylist/AbstractAlbum" ) ); iMmMtpDpMetadataMpxAccess->AddAbstractMediaL( fullFileName, category ); } else if ( category == EMPXSong ) { PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::AddObjectL AddSong" ) ); iMmMtpDpMetadataMpxAccess->AddSongL( fullFileName ); } PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::AddObjectL" ) ); }
void PrePostProcessor::DeleteCleanup(NzbInfo* nzbInfo) { if (nzbInfo->GetCleanupDisk() || nzbInfo->GetDeleteStatus() == NzbInfo::dsDupe) { // download was cancelled, deleting already downloaded files from disk for (CompletedFile& completedFile: nzbInfo->GetCompletedFiles()) { BString<1024> fullFileName("%s%c%s", nzbInfo->GetDestDir(), PATH_SEPARATOR, completedFile.GetFilename()); if (FileSystem::FileExists(fullFileName)) { detail("Deleting file %s", completedFile.GetFilename()); FileSystem::DeleteFile(fullFileName); } } // delete .out.tmp-files DirBrowser dir(nzbInfo->GetDestDir()); while (const char* filename = dir.Next()) { int len = strlen(filename); if (len > 8 && !strcmp(filename + len - 8, ".out.tmp")) { BString<1024> fullFilename("%s%c%s", nzbInfo->GetDestDir(), PATH_SEPARATOR, filename); detail("Deleting file %s", filename); FileSystem::DeleteFile(fullFilename); } } // delete old directory (if empty) FileSystem::DeleteDirectory(nzbInfo->GetDestDir()); } }
BitBuffer* FileDBufRequester::readFromFile(const MC2SimpleString& descr) { MC2SimpleString fullFileName(getFileName(descr)); FILE* file = fopen(fullFileName.c_str(), "r"); BitBuffer* retBuf = NULL; if ( file ) { // Seek to the end of file int seekRes = fseek(file, 0, SEEK_END); if ( seekRes < 0 ) { fclose(file); } long fileSize = ftell(file); // Set back the position. seekRes = fseek(file, 0, SEEK_SET); retBuf = new BitBuffer(fileSize); // TODO: Add error handling fread(retBuf->getBufferAddress(), fileSize, 1, file); fclose(file); } else { // No file yet. } return retBuf; }
void FeedValidator::ValidateFeedFormat(const std::string& xslPath, FeedFormat feedFormat, std::string& results) { boost::filesystem::path fullFileName(m_feed.GetFeedConfig().m_config_path); fullFileName /= xslPath; std::ifstream xslFile(fullFileName.string().c_str(), std::ios_base::binary | std::ios_base::in); if (!xslFile) { std::stringstream msg; msg << "FeedValidator: Unable to open XSL file: '" << xslPath << "'"; throw feed_exception(msg.str()); } std::stringstream xslStream; xslFile.get(*xslStream.rdbuf(), '\0'); xslStream.seekg(std::stringstream::beg); TransformFeed(xslStream, results); if (!results.empty() && ValidateFeed(results)) { m_feed.SetFeedFormat(feedFormat); m_feed.SetValidity(true); return; } return; }
void Configurator::LogHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { QByteArray localMsg = msg.toLocal8Bit(); QString stringMsg; QString fullFileName(context.file); QString file; int lastPathSeparatorIndex = fullFileName.lastIndexOf(QDir::separator()); if (lastPathSeparatorIndex) file = fullFileName.right(fullFileName.size() - lastPathSeparatorIndex - 1); else file = fullFileName; QTextStream stream(&stringMsg); switch (type) { case QtDebugMsg: stream << context.category << ".DEBUG: " << localMsg.constData() << " " << " in " << file << " " << context.line << endl; break; case QtWarningMsg: stream << context.category << ".WARNING: " << localMsg.constData() << context.function << " " << file << context.line << endl << endl; break; case QtCriticalMsg: stream << context.category << ".CRITICAL: " << localMsg.constData() << context.function << " " << file << context.line << endl << endl; break; case QtFatalMsg: stream << context.category << ".FATAL: " << localMsg.constData() << context.function << file << context.line << endl << endl; break; default: stream << context.category << ".INFO: " << localMsg.constData() <<endl; } QTextStream(stdout) << stringMsg; Configurator *configurator = Configurator::getInstance(); QDir logDir = configurator->getBaseDir(); QString path = logDir.absoluteFilePath("log.txt"); QFile outFile(path); QIODevice::OpenMode ioFlags = QIODevice::WriteOnly; if (configurator->logFileIsCreated()) { ioFlags |= QIODevice::Append; } else { ioFlags |= QIODevice::Truncate; configurator->setFileCreatedFlag(); } if (outFile.open(ioFlags)) { QTextStream ts(&outFile); ts << stringMsg; } if (type == QtFatalMsg) abort(); }
// ----------------------------------------------------------------------------- // CMmMtpDpMetadataMpxAccess::GetImageObjPropL // get image specific properties specific to videos // ----------------------------------------------------------------------------- // void CMmMtpDpMetadataAccessWrapper::GetImageObjPropL( const CMTPObjectMetaData& aObject, TUint32& aWidth, TUint32& aHeight ) { TMPXGeneralCategory category = Category( aObject ); if ( category == EMPXVideo ) { TPtrC fullFileName( aObject.DesC( CMTPObjectMetaData::ESuid ) ); iMmMtpDpMetadataVideoAccess->SetStorageRootL( fullFileName ); iMmMtpDpMetadataVideoAccess->GetImageObjPropL( fullFileName, aWidth, aHeight ); } }
/** Adds a recognition result to the cache. An object is not added, when an up-to-date version is already in the cache or if it's not possible to check the file's LastModified(). @internalComponent */ void CApsRecognitionCache::AddL(const RFile& aFile, const TDesC& aDirectory, const TDesC& aFileName, const TDataRecognitionResult& aRecognitionResult) { TTime lastModified; if(aFile.Modified(lastModified) != KErrNone) { #if defined(_DEBUG) TFileName fullFileName(aDirectory); fullFileName.Append(aFileName); RDebug::Print(_L("CApsRecognitionCache::AddL(): File '%S' was not added to the cache, cannot get the modified attribute."), &fullFileName); #endif return; } DoAddL(aDirectory, aFileName, lastModified, aRecognitionResult); }
DirectoryResource* DirectoryResourceManager::findFilename(const char* fullName ///< full path to a file ) { OsPath fullFileName(fullName); UtlString dirName = fullFileName.getDirName(); UtlString fileName; fileName.append(fullName, dirName.length(), UtlString::UTLSTRING_TO_END); dirName.strip(UtlString::trailing, OsPath::separator[0]); DirectoryResource* found = NULL; Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG, "DirectoryResourceManager::findFilename: path '%s' file '%s'", dirName.data(), fileName.data()); { OsLock tableMutex(mDirectoryResourceTableLock); UtlSListIterator directories(mDirectoryResourceTable); DirectoryResource* dir; while (!found && (dir = dynamic_cast<DirectoryResource*>(directories.findNext(&dirName)))) { if ( dir->matches(fileName) ) { found = dir; } } } if (found) { UtlString matched; found->appendDescription(matched); Os::Logger::instance().log(FAC_SUPERVISOR, PRI_DEBUG, "DirectoryResourceManager::findFilename: '%s' matches %s", fullName, matched.data()); } else { Os::Logger::instance().log(FAC_SUPERVISOR, PRI_WARNING, "DirectoryResourceManager::findFilename: no match found for '%s'", fullName); } return found; }
bool FileDBufRequester::writeToFile(const MC2SimpleString& descr, BitBuffer* buffer) { MC2SimpleString fullFileName(getFileName(descr)); { FILE* readFile = fopen(fullFileName.c_str(), "r"); if ( readFile != NULL ) { // Already there mc2dbg8 << "[FDBR]: " << descr << " already on disk" << endl; fclose(readFile); return true; } } #if defined (__unix__) || defined (__MACH__) #define USE_TEMP_FILE #endif #ifdef USE_TEMP_FILE // Make temporary file in the same dir. (For e.g. server // to avoid two threads writing to the same file). char tempTemplate[1024]; sprintf(tempTemplate, "%stilecachXXXXXX", m_path.c_str()); int tmpDesc = mkstemp(tempTemplate); MC2SimpleString tempName(tempTemplate); FILE* file = fdopen(tmpDesc, "w"); #else // Write directly to the file FILE* file = fopen(fullFileName.c_str(), "w"); #endif if ( file && (fwrite(buffer->getBufferAddress(), buffer->getBufferSize(), 1, file) == 1 ) ) { mc2dbg8 << "[FDBR]: Wrote " << descr << " to disk" << endl; #ifdef USE_TEMP_FILE // Rename the file to the correct name and hope it works. rename(tempName.c_str(), fullFileName.c_str()); #endif fclose(file); file = NULL; return true; } if ( file ) { fclose(file); } return false; }
void CAgnCalendarConverter::ConstructL(CAgnServFile& aAgnServerFile) /** @internalComponent */ { iOutModelStreamIdSet = CAgnModelStreamIdSet::NewL(); iOutEntryManager = CAgnEntryManager::NewL(); iAgnServerFile = &aAgnServerFile; // Get the original (old version) stream store from the CAgnServFile // iInputStreamStore = iAgnServerFile->StoreL(); __ASSERT_ALWAYS(iInputStreamStore, User::Leave(KErrCorrupt)); // Create the output stream store // TParsePtrC fullFileName(iAgnServerFile->FileName()); HBufC* fileName = HBufC::NewLC(fullFileName.Drive().Length() + fullFileName.NameAndExt().Length() + KUpdatedAgendaFileExtension().Length()); TPtr fileNamePtr(fileName->Des()); fileNamePtr.Append(fullFileName.Drive()); fileNamePtr.Append(fullFileName.NameAndExt()); fileNamePtr.Append(KUpdatedAgendaFileExtension); // Create the output stream store where converted information will be kept // This code copied from CAgnServerSession::CreateAgendaFileL() and CAgnEntryModel::CreateL(CStreamStore& aStore) // iOutputStreamStore = iAgnServerFile->Server().FileMgr()->CreateAgendaFileLC(fileNamePtr); CleanupStack::Pop(iOutputStreamStore); CleanupStack::PopAndDestroy(fileName); iOutputStreamStore->SetTypeL(TUidType(KPermanentFileStoreLayoutUid, KUidAppDllDoc, KUidAgnApp)); iOutEntryManager->SetStore(*iOutputStreamStore); // Create the network of stream Ids needed by the model TStreamId headstreamId = iOutModelStreamIdSet->CreateL(*iOutputStreamStore, CalFileVersionUtils::CurrentFileVersion()); // Create the stream dictionary for iOutputStreamStore and keep headstreamId in it // iDictionary = CStreamDictionary::NewL(); iDictionary->AssignL(KUidAgnModel, headstreamId); // Set stream dictionary in stream store TApaAppIdentifier dummyApp(KUidAgnModel, KNullDesC()); CApaProcess::WriteRootStreamL(*iOutputStreamStore,*iDictionary, dummyApp); iOutputTzRuleIndex = CAgnTzRuleIndex::NewL(*iDictionary, *iOutputStreamStore); }
FILE* ExportAlgorithm::openFile( const String& dirName, const String& fileName ) const { String fullFileName( dirName ); fullFileName << "/" << fileName; FILE* file = acadoFOpen( fullFileName.getName(), "w" ); if ( file == 0 ) return 0; acadoPrintAutoGenerationNotice( file ); if ( commonHeaderName.isEmpty() == BT_FALSE ) acadoFPrintf( file, "#include \"%s\"\n\n\n",commonHeaderName.getName() ); return file; }
Glib::RefPtr<Gdk::Pixbuf> UIManager::getLocalPixbufWithMask(const std::string& fileName) { // Try to find a cached pixbuf before loading from disk PixBufMap::iterator i = _localPixBufsWithMask.find(fileName); if (i != _localPixBufsWithMask.end()) { return i->second; } // Not cached yet, load afresh std::string fullFileName(GlobalRegistry().get(RKEY_BITMAPS_PATH) + fileName); Glib::RefPtr<Gdk::Pixbuf> rgba; try { Glib::RefPtr<Gdk::Pixbuf> rgb = Gdk::Pixbuf::create_from_file(fullFileName); if (rgb) { // File load successful, add alpha channel rgba = rgb->add_alpha(true, 255, 0, 255); } else { rError() << "Couldn't load rgb pixbuf " << fullFileName << std::endl; } } catch (Glib::FileError& err) { rWarning() << "Couldn't load rgb pixbuf " << fullFileName << std::endl; rWarning() << err.what() << std::endl; } _localPixBufsWithMask.insert(PixBufMap::value_type(fileName, rgba)); return rgba; }
void setMetaDataSourceFileLine(const clang::Decl *decl, const Typelib::Type *type) { const clang::SourceManager &sm = decl->getASTContext().getSourceManager(); const clang::SourceLocation &loc = sm.getExpansionLoc(decl->getLocStart()); // uses "readlink(3)" to normalize symlinks from system-header path. for // example // "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/$file" // would be turned into // "/usr/include/c++/4.9/bits/$file" // this was done by the gccxml-importer before. this is needed because the // "preprocess" stage of clang++, run later to retrieve the "orogen_include", // can output smth like // "/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/$file" // which cannot be string-compared... so there, is would have to be flattend as well clang::FileManager &fm = sm.getFileManager(); const clang::FileEntry *fileEntry = sm.getFileEntryForID(sm.getFileID(loc)); std::string dirName = fm.getCanonicalName(fileEntry->getDir()).str(); std::string fullFileName(fileEntry->getName()); std::string fileName = fullFileName.substr(fullFileName.find_last_of("/") + 1); if (fileName.empty()) { std::cerr << "ERROR: invalid filename '" << fileEntry->getDir() << "', no forward slash?\n"; exit(-1); } // some headers can be reached via two ways: actual filepath and symlink // inside the ".orogen" folder -- a hack of really bad taste... anyhow, // guard against this... std::string filePath = do_readlink(dirName+"/"+fileName); // typelib needs the '/path/to/file:column' information std::ostringstream stream; stream << filePath << ":" << sm.getExpansionLineNumber(loc); type->getMetaData().add("source_file_line", stream.str()); }
Glib::RefPtr<Gdk::Pixbuf> UIManager::getLocalPixbuf(const std::string& fileName) { // Try to use a cached pixbuf first PixBufMap::iterator i = _localPixBufs.find(fileName); if (i != _localPixBufs.end()) { return i->second; } // Not cached yet, load afresh // Construct the full filename using the Bitmaps path std::string fullFileName(GlobalRegistry().get(RKEY_BITMAPS_PATH) + fileName); Glib::RefPtr<Gdk::Pixbuf> pixbuf; try { pixbuf = Gdk::Pixbuf::create_from_file(fullFileName); if (!pixbuf) { rError() << "Couldn't load pixbuf " << fullFileName << std::endl; } } catch (Glib::FileError& err) { rWarning() << "Couldn't load pixbuf " << fullFileName << std::endl; rWarning() << err.what() << std::endl; } _localPixBufs.insert(PixBufMap::value_type(fileName, pixbuf)); return pixbuf; }
bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) { // This is for python: if( aFileSet.size() != 1 ) { UTF8 msg = StrPrintf( "Pcbnew:%s() takes only a single filename", __func__ ); DisplayError( this, msg ); return false; } wxString fullFileName( aFileSet[0] ); // We insist on caller sending us an absolute path, if it does not, we say it's a bug. wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) ); std::unique_ptr<wxSingleInstanceChecker> lockFile = ::LockFile( fullFileName ); if( !lockFile ) { wxString msg = wxString::Format( _( "PCB file \"%s\" is already open." ), fullFileName ); DisplayError( this, msg ); return false; } if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() ) { if( !HandleUnsavedChanges( this, _( "The current PCB has been modified. Save changes?" ), [&]()->bool { return SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE ); } ) ) { return false; } } // Release the lock file, until the new file is actually loaded ReleaseFile(); wxFileName pro = fullFileName; pro.SetExt( ProjectFileExtension ); bool is_new = !wxFileName::IsFileReadable( fullFileName ); // If its a non-existent schematic and caller thinks it exists if( is_new && !( aCtl & KICTL_CREATE ) ) { // notify user that fullFileName does not exist, ask if user wants to create it. wxString ask = wxString::Format( _( "PCB \"%s\" does not exist. Do you wish to create it?" ), fullFileName ); if( !IsOK( this, ask ) ) return false; } Clear_Pcb( false ); // pass false since we prompted above for a modified board IO_MGR::PCB_FILE_T pluginType = plugin_type( fullFileName, aCtl ); bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD_SEXP; if( !converted ) { // PROJECT::SetProjectFullName() is an impactful function. It should only be // called under carefully considered circumstances. // The calling code should know not to ask me here to change projects unless // it knows what consequences that will have on other KIFACEs running and using // this same PROJECT. It can be very harmful if that calling code is stupid. Prj().SetProjectFullName( pro.GetFullPath() ); // load project settings before BOARD LoadProjectSettings(); } if( is_new ) { OnModify(); } else { BOARD* loadedBoard = 0; // it will be set to non-NULL if loaded OK PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); // This will rename the file if there is an autosave and the user want to recover CheckForAutoSaveFile( fullFileName ); try { PROPERTIES props; char xbuf[30]; char ybuf[30]; // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet. sprintf( xbuf, "%d", GetPageSizeIU().x ); sprintf( ybuf, "%d", GetPageSizeIU().y ); props["page_width"] = xbuf; props["page_height"] = ybuf; #if USE_INSTRUMENTATION // measure the time to load a BOARD. unsigned startTime = GetRunningMicroSecs(); #endif loadedBoard = pi->Load( fullFileName, NULL, &props ); #if USE_INSTRUMENTATION unsigned stopTime = GetRunningMicroSecs(); printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime ); #endif } catch( const IO_ERROR& ioe ) { if( ioe.Problem() != wxT( "CANCEL" ) ) { wxString msg = wxString::Format( _( "Error loading board file:\n%s" ), fullFileName ); DisplayErrorMessage( this, msg, ioe.What() ); } return false; } // 6.0 TODO: some settings didn't make it into the board file in 5.1 so as not to // change the file format. For 5.1 we must copy them across from the config-initialized // board. BOARD_DESIGN_SETTINGS& bds = loadedBoard->m_designSettings; BOARD_DESIGN_SETTINGS& configBds = GetBoard()->GetDesignSettings(); bds.m_RequireCourtyards = configBds.m_RequireCourtyards; bds.m_ProhibitOverlappingCourtyards = configBds.m_ProhibitOverlappingCourtyards; bds.m_HoleToHoleMin = configBds.m_HoleToHoleMin; bds.m_LineThickness[LAYER_CLASS_OTHERS] = configBds.m_LineThickness[LAYER_CLASS_OTHERS]; bds.m_TextSize[LAYER_CLASS_OTHERS] = configBds.m_TextSize[LAYER_CLASS_OTHERS]; bds.m_TextThickness[LAYER_CLASS_OTHERS] = configBds.m_TextThickness[LAYER_CLASS_OTHERS]; std::copy( configBds.m_TextItalic, configBds.m_TextItalic + 4, bds.m_TextItalic ); std::copy( configBds.m_TextUpright, configBds.m_TextUpright + 4, bds.m_TextUpright ); bds.m_DiffPairDimensionsList = configBds.m_DiffPairDimensionsList; bds.m_CopperEdgeClearance = configBds.m_CopperEdgeClearance; SetBoard( loadedBoard ); // we should not ask PLUGINs to do these items: loadedBoard->BuildListOfNets(); loadedBoard->SynchronizeNetsAndNetClasses(); // If this is a legacy board then we set the copper edge clearance to 1/2 the edge-cut // line width (which was a legacy kludge for implementing edge clearances). if( bds.m_CopperEdgeClearance == Millimeter2iu( LEGACY_COPPEREDGECLEARANCE ) ) bds.SetCopperEdgeClearance( inferLegacyEdgeClearance( loadedBoard ) ); if( loadedBoard->IsModified() ) OnModify(); else GetScreen()->ClrModify(); if( pluginType == IO_MGR::LEGACY && loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION ) { DisplayInfoMessage( this, _( "This file was created by an older version of Pcbnew.\n" "It will be stored in the new file format when you save this file again." ) ); } } { wxFileName fn = fullFileName; if( converted ) fn.SetExt( PcbFileExtension ); wxString fname = fn.GetFullPath(); fname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); GetBoard()->SetFileName( fname ); } // Lock the file newly opened: m_file_checker.reset( lockFile.release() ); if( !converted ) UpdateFileHistory( GetBoard()->GetFileName() ); // Rebuild the new pad list (for drc and ratsnet control ...) GetBoard()->m_Status_Pcb = 0; // Select netclass Default as current netclass (it always exists) SetCurrentNetClass( NETCLASS::Default ); // Rebuild list of nets (full ratsnest rebuild) Compile_Ratsnest( NULL, true ); GetBoard()->BuildConnectivity(); onBoardLoaded(); // Refresh the 3D view, if any EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); if( draw3DFrame ) draw3DFrame->NewDisplay(); #if 0 && defined(DEBUG) // Output the board object tree to stdout, but please run from command prompt: GetBoard()->Show( 0, std::cout ); #endif // from EDA_APPL which was first loaded BOARD only: { /* For an obscure reason the focus is lost after loading a board file * when starting up the process. * (seems due to the recreation of the layer manager after loading the file) * Give focus to main window and Drawpanel * must be done for these 2 windows (for an obscure reason ...) * Linux specific * This is more a workaround than a fix. */ SetFocus(); GetCanvas()->SetFocus(); } return true; }
bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) { // implement the pseudo code from KIWAY_PLAYER.h: SCH_SCREENS screenList; // This is for python: if( aFileSet.size() != 1 ) { UTF8 msg = StrPrintf( "Eeschema:%s() takes only a single filename", __func__ ); DisplayError( this, msg ); return false; } wxString fullFileName( aFileSet[0] ); // We insist on caller sending us an absolute path, if it does not, we say it's a bug. wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "bug in single_top.cpp or project manager." ) ); if( !LockFile( fullFileName ) ) { wxString msg = wxString::Format( _( "Schematic file '%s' is already open." ), GetChars( fullFileName ) ); DisplayError( this, msg ); return false; } // save any currently open and modified project files. for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() ) { if( screen->IsModify() ) { int response = YesNoCancelDialog( this, _( "The current schematic has been modified. Do you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) { return false; } else if( response == wxID_YES ) { wxCommandEvent dummy; OnSaveProject( dummy ); } else { // response == wxID_NO, fall thru } break; } } wxFileName pro = fullFileName; pro.SetExt( ProjectFileExtension ); bool is_new = !wxFileName::IsFileReadable( fullFileName ); // If its a non-existent schematic and caller thinks it exists if( is_new && !( aCtl & KICTL_CREATE ) ) { // notify user that fullFileName does not exist, ask if user wants to create it. wxString ask = wxString::Format( _( "Schematic '%s' does not exist. Do you wish to create it?" ), GetChars( fullFileName ) ); if( !IsOK( this, ask ) ) return false; } // unload current project file before loading new { delete g_RootSheet; g_RootSheet = NULL; CreateScreens(); } GetScreen()->SetFileName( fullFileName ); g_RootSheet->SetFileName( fullFileName ); SetStatusText( wxEmptyString ); ClearMsgPanel(); wxString msg = wxString::Format( _( "Ready\nProject dir: '%s'\n" ), GetChars( wxPathOnly( Prj().GetProjectFullName() ) ) ); SetStatusText( msg ); // PROJECT::SetProjectFullName() is an impactful function. It should only be // called under carefully considered circumstances. // The calling code should know not to ask me here to change projects unless // it knows what consequences that will have on other KIFACEs running and using // this same PROJECT. It can be very harmful if that calling code is stupid. Prj().SetProjectFullName( pro.GetFullPath() ); LoadProjectFile(); // load the libraries here, not in SCH_SCREEN::Draw() which is a context // that will not tolerate DisplayError() dialog since we're already in an // event handler in there. // And when a schematic file is loaded, we need these libs to initialize // some parameters (links to PART LIB, dangling ends ...) Prj().SchLibs(); if( is_new ) { // mark new, unsaved file as modified. GetScreen()->SetModify(); } else { g_RootSheet->SetScreen( NULL ); DBG( printf( "%s: loading schematic %s\n", __func__, TO_UTF8( fullFileName ) );) bool diag = g_RootSheet->Load( this ); (void) diag; SetScreen( m_CurrentSheet->LastScreen() ); GetScreen()->ClrModify(); UpdateFileHistory( fullFileName ); }
void initOsm2OlmInternal(osm2olm* self, const char* outputDirectory, CountryPolygon* polygons, int polygonsCount, CountryInitializer initCountry) { initOsmStreamReader(&(self->reader), self); self->reader.newTag = newTag; self->reader.newNode = newNode; self->reader.newWayNode = newWayNode; self->reader.newWay = newWay; self->reader.newRelationMember = newRelationMember; self->reader.newRelation = newRelation; self->reader.finishNode[OSM_CHANGE_NONE] = writeNode; self->reader.finishWay[OSM_CHANGE_NONE] = writeWay; self->reader.finishRelation[OSM_CHANGE_NONE] = writeRelation; self->tags.values = NULL; self->tags.count = 0; self->tags.capacity = 0; self->wayNodes.values = NULL; self->wayNodes.count = 0; self->wayNodes.capacity = 0; self->relationMembers.values = NULL; self->relationMembers.count = 0; self->relationMembers.capacity = 0; self->relations.values = NULL; self->relations.count = 0; self->relations.capacity = 0; self->currentEntityType = OSM_ENTITY_NONE; self->countries = calloc(sizeof(LCountry), polygonsCount); self->countriesCount = polygonsCount; if(-1 == mkdir(outputDirectory, S_IRWXU) && errno != EEXIST) { printf("Error creating directory %s: %i\n", outputDirectory, errno); } for(int p=0;p <polygonsCount; p++) { self->countries[p].polygon = polygons + p; printf("Country %s\n", self->countries[p].polygon->name); char* countryFileName = fullFileName(polygons[p].name, outputDirectory); initTree16(&(self->countries[p].nodesIndex)); initTree16(&(self->countries[p].waysIndex)); initTree16(&(self->countries[p].relationsIndex)); sqlite3* db = NULL; if(sqlite3_open(strdup(countryFileName), &db) != SQLITE_OK){ fprintf(stderr, "Error open db %s: %s", countryFileName, sqlite3_errmsg(db)); } free(countryFileName); self->countries[p].db = db; initCountry(self->countries + p); printf("Done.\n"); } }
bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) { // This is for python: if( aFileSet.size() != 1 ) { UTF8 msg = StrPrintf( "Pcbnew:%s() takes only a single filename", __func__ ); DisplayError( this, msg ); return false; } wxString fullFileName( aFileSet[0] ); // We insist on caller sending us an absolute path, if it does not, we say it's a bug. wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "bug in single_top.cpp or project manager." ) ); if( !LockFile( fullFileName ) ) { wxString msg = wxString::Format( _( "PCB file '%s' is already open." ), GetChars( fullFileName ) ); DisplayError( this, msg ); return false; } if( GetScreen()->IsModify() ) { int response = YesNoCancelDialog( this, _( "The current board has been modified. Do you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) return false; else if( response == wxID_YES ) SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE ); else { // response == wxID_NO, fall thru } } wxFileName pro = fullFileName; pro.SetExt( ProjectFileExtension ); bool is_new = !wxFileName::IsFileReadable( fullFileName ); // If its a non-existent schematic and caller thinks it exists if( is_new && !( aCtl & KICTL_CREATE ) ) { // notify user that fullFileName does not exist, ask if user wants to create it. wxString ask = wxString::Format( _( "Board '%s' does not exist. Do you wish to create it?" ), GetChars( fullFileName ) ); if( !IsOK( this, ask ) ) return false; } Clear_Pcb( false ); // pass false since we prompted above for a modified board IO_MGR::PCB_FILE_T pluginType = plugin_type( fullFileName, aCtl ); bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD; if( !converted ) { // PROJECT::SetProjectFullName() is an impactful function. It should only be // called under carefully considered circumstances. // The calling code should know not to ask me here to change projects unless // it knows what consequences that will have on other KIFACEs running and using // this same PROJECT. It can be very harmful if that calling code is stupid. Prj().SetProjectFullName( pro.GetFullPath() ); // load project settings before BOARD LoadProjectSettings(); } if( is_new ) { OnModify(); } else { BOARD* loadedBoard = 0; // it will be set to non-NULL if loaded OK PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); try { PROPERTIES props; char xbuf[30]; char ybuf[30]; // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet. sprintf( xbuf, "%d", GetPageSizeIU().x ); sprintf( ybuf, "%d", GetPageSizeIU().y ); props["page_width"] = xbuf; props["page_height"] = ybuf; #if USE_INSTRUMENTATION // measure the time to load a BOARD. unsigned startTime = GetRunningMicroSecs(); #endif loadedBoard = pi->Load( fullFileName, NULL, &props ); #if USE_INSTRUMENTATION unsigned stopTime = GetRunningMicroSecs(); printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime ); #endif } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.errorText ) ); DisplayError( this, msg ); return false; } SetBoard( loadedBoard ); // we should not ask PLUGINs to do these items: loadedBoard->BuildListOfNets(); loadedBoard->SynchronizeNetsAndNetClasses(); SetStatusText( wxEmptyString ); BestZoom(); // update the layer names in the listbox ReCreateLayerBox( false ); GetScreen()->ClrModify(); { wxFileName fn = fullFileName; CheckForAutoSaveFile( fullFileName, fn.GetExt() ); } if( pluginType == IO_MGR::LEGACY && loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION ) { DisplayInfoMessage( this, _( "This file was created by an older version of Pcbnew.\n" "It will be stored in the new file format when you save this file again." ) ); } } { wxFileName fn = fullFileName; if( converted ) fn.SetExt( PcbFileExtension ); wxString fname = fn.GetFullPath(); fname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); GetBoard()->SetFileName( fname ); } UpdateTitle(); if( !converted ) UpdateFileHistory( GetBoard()->GetFileName() ); // Rebuild the new pad list (for drc and ratsnet control ...) GetBoard()->m_Status_Pcb = 0; // Update info shown by the horizontal toolbars SetCurrentNetClass( NETCLASS::Default ); ReFillLayerWidget(); ReCreateLayerBox(); // upate the layer widget to match board visibility states, both layers and render columns. syncLayerVisibilities(); syncLayerWidgetLayer(); syncRenderStates(); // Update the tracks / vias available sizes list: ReCreateAuxiliaryToolbar(); // Update the RATSNEST items, which were not loaded at the time // BOARD::SetVisibleElements() was called from within any PLUGIN. // See case RATSNEST_VISIBLE: in BOARD::SetElementVisibility() GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() ); // Display the loaded board: Zoom_Automatique( false ); // Compile ratsnest and displays net info { wxBusyCursor dummy; // Displays an Hourglass while building connectivity Compile_Ratsnest( NULL, true ); GetBoard()->GetRatsnest()->ProcessBoard(); } SetMsgPanel( GetBoard() ); // Refresh the 3D view, if any if( m_Draw3DFrame ) m_Draw3DFrame->NewDisplay(); #if 0 && defined(DEBUG) // Output the board object tree to stdout, but please run from command prompt: GetBoard()->Show( 0, std::cout ); #endif // from EDA_APPL which was first loaded BOARD only: { /* For an obscure reason the focus is lost after loading a board file * when starting up the process. * (seems due to the recreation of the layer manager after loading the file) * Give focus to main window and Drawpanel * must be done for these 2 windows (for an obscure reason ...) * Linux specific * This is more a workaround than a fix. */ SetFocus(); GetCanvas()->SetFocus(); } return true; }
QString ModelEditor::activeFullFileName () { int idx = _model_editor_tab->currentIndex (); return (fullFileName (idx)); }
bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) { SCH_SCREEN* screen; wxString fullFileName( aFileSet[0] ); wxString msg; SCH_SCREENS screenList; for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() ) { if( screen->IsModify() ) break; } if( screen ) { int response = YesNoCancelDialog( this, _( "The current schematic has been modified. Do you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) { return false; } else if( response == wxID_YES ) { wxCommandEvent dummy; OnSaveProject( dummy ); } } /* if( fullFileName.IsEmpty() && !aIsNew ) { wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(), wxEmptyString, SchematicFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return false; FullFileName = dlg.GetPath(); } */ wxFileName fn = fullFileName; if( fn.IsRelative() ) { fn.MakeAbsolute(); fullFileName = fn.GetFullPath(); } if( !Pgm().LockFile( fullFileName ) ) { DisplayError( this, _( "This file is already open." ) ); return false; } // Clear the screen before open a new file if( g_RootSheet ) { delete g_RootSheet; g_RootSheet = NULL; } CreateScreens(); screen = GetScreen(); wxLogDebug( wxT( "Loading schematic " ) + fullFileName ); // @todo: this is bad: wxSetWorkingDirectory( fn.GetPath() ); screen->SetFileName( fullFileName ); g_RootSheet->SetFileName( fullFileName ); SetStatusText( wxEmptyString ); ClearMsgPanel(); screen->ClrModify(); #if 0 if( aIsNew ) { /* SCH_SCREEN constructor does this now screen->SetPageSettings( PAGE_INFO( wxT( "A4" ) ) ); */ screen->SetZoom( 32 ); m_LastGridSizeId = screen->SetGrid( ID_POPUP_GRID_LEVEL_50 ); TITLE_BLOCK tb; wxString title; title += NAMELESS_PROJECT; title += wxT( ".sch" ); tb.SetTitle( title ); screen->SetTitleBlock( tb ); GetScreen()->SetFileName( title ); LoadProjectFile( wxEmptyString, true ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh(); return true; } #endif // Reloading configuration. msg.Printf( _( "Ready\nWorking dir: '%s'\n" ), GetChars( wxGetCwd() ) ); PrintMsg( msg ); LoadProjectFile( wxEmptyString, false ); // Clear (if needed) the current active library in libedit because it could be // removed from memory LIB_EDIT_FRAME::EnsureActiveLibExists(); // Delete old caches. CMP_LIBRARY::RemoveCacheLibrary(); if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) ) { Zoom_Automatique( false ); if( aCtl == 0 ) { msg.Printf( _( "File '%s' not found." ), GetChars( g_RootSheet->GetScreen()->GetFileName() ) ); DisplayInfoMessage( this, msg ); } return true; // do not close Eeschema if the file if not found: // we may have to create a new schematic file. } // load the project. bool libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() ); g_RootSheet->SetScreen( NULL ); bool diag = g_RootSheet->Load( this ); SetScreen( m_CurrentSheet->LastScreen() ); UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() ); // Redraw base screen (ROOT) if necessary. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh( true ); (void) libCacheExist; (void) diag; // return diag; return true; // do not close Eeschema if the file if not found: // we may have to create a new schematic file. }