bool CSVNStatusCache::BlockPath(const CTSVNPath& path, bool specific, ULONGLONG timeout /* = 0 */) { if (timeout == 0) timeout = BLOCK_PATH_DEFAULT_TIMEOUT; if (timeout > BLOCK_PATH_MAX_TIMEOUT) timeout = BLOCK_PATH_MAX_TIMEOUT; timeout = GetTickCount64() + (timeout * 1000); // timeout is in seconds, but we need the milliseconds if (!specific) { CTSVNPath p(path); do { CTSVNPath dbPath(p); dbPath.AppendPathString(g_SVNAdminDir.GetAdminDirName() + L"\\wc.db"); if (!dbPath.Exists()) p = p.GetContainingDirectory(); else { CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": block path %s\n", p.GetWinPath()); AutoLocker lock(m_NoWatchPathCritSec); m_NoWatchPaths[p] = timeout; return true; } } while (!p.IsEmpty()); } CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": block path %s\n", path.GetWinPath()); AutoLocker lock(m_NoWatchPathCritSec); m_NoWatchPaths[path.GetDirectory()] = timeout; return true; }
void MobileKVEngine::_initDBPath(const std::string& path) { boost::system::error_code err; boost::filesystem::path dbPath(path); if (!boost::filesystem::exists(dbPath, err)) { if (err) { uasserted(4085, err.message()); } std::string errMsg("DB path not found: "); errMsg += dbPath.generic_string(); uasserted(4086, errMsg); } else if (!boost::filesystem::is_directory(dbPath, err)) { if (err) { uasserted(4087, err.message()); } std::string errMsg("DB path is not a valid directory: "); errMsg += dbPath.generic_string(); uasserted(4088, errMsg); } dbPath /= "mobile.sqlite"; if (boost::filesystem::exists(dbPath, err)) { if (err) { uasserted(4089, err.message()); } else if (!boost::filesystem::is_regular_file(dbPath)) { std::string errMsg("Failed to open " + dbPath.generic_string() + ": not a regular file"); uasserted(4090, errMsg); } } _path = dbPath.generic_string(); }
beast::File Config::getModuleDatabasePath () const { boost::filesystem::path dbPath (legacy ("database_path")); beast::String const s (dbPath.native ().c_str ()); if (s.isNotEmpty ()) return beast::File (s); return beast::File::nonexistent (); }
/* WARNING: This function is not portable! Linux ONLY! */ std::string getExeDirectory() { char path[PATH_MAX]; size_t len = readlink("/proc/self/exe", path, PATH_MAX); path[len] = '\0'; std::string dbPath(path); std::size_t dir = dbPath.find_last_of('/'); if (dir != std::string::npos) return dbPath.substr(0, dir); else return std::string(); }
void FKRealmComponent::startComponent(){ if(!component()){ FKRealm* realm=static_cast<FKRealm*>(componentFactory()->newInstance()); connect(realm,SIGNAL(messageRequested(QString)),this,SIGNAL(messageRequested(QString))); QString dbPath(FKPathResolver::realmDatabasePath()); QDir(dbPath).mkpath("."); FKDataBase* db=new FKFSDB(realm); db->setPath(dbPath); realm->setDataBase(db); FKThreadedComponent::startComponent(realm); emit messageRequested(QString(tr("Started"))); emit started(); } }
void FKServerComponent::startComponent(){ if(!component()){ FKServerInfrastructure* server=static_cast<FKServerInfrastructure*>(componentFactory()->newInstance()); connect(server,SIGNAL(waitingForAnswerChanged(FKInfrastructureType)),SIGNAL(waitingForRealmAnswerChanged())); connect(server,SIGNAL(connectedToRealm()),SIGNAL(connectedToRealm())); connect(server,SIGNAL(disconnectedFromRealm()),SIGNAL(disconnectedFromRealm())); connect(server,SIGNAL(loggedIn()),SIGNAL(loggedIn())); connect(server,SIGNAL(messageRequested(QString)),SIGNAL(messageRequested(QString))); connect(server,SIGNAL(roomInstruction(FKInstructionObject)),SIGNAL(roomInstruction(FKInstructionObject))); QString dbPath(FKPathResolver::serverDatabasePath()); QDir(dbPath).mkpath("."); FKDataBase* db=new FKFSDB(server); db->setPath(dbPath); server->setDataBase(db); FKThreadedComponent::startComponent(server); emit messageRequested(QString(tr("Started"))); emit started(); } }
std::map<CTSVNPath, WCRootsTimes>::iterator CWCRoots::AddPathInternal( const CTSVNPath& path ) { AutoLocker lock(m_critSec); CTSVNPath p(path); do { CTSVNPath dbPath(p); dbPath.AppendPathString(g_SVNAdminDir.GetAdminDirName() + _T("\\wc.db")); if (!dbPath.Exists()) p = p.GetContainingDirectory(); else { WCRootsTimes dbTimes; dbTimes.LastTicks = GetTickCount(); dbTimes.FileTime = dbPath.GetLastWriteTime(); return m_WCDBs.insert(std::pair<CTSVNPath, WCRootsTimes>(p, dbTimes)).first; } } while (!p.IsEmpty()); return m_WCDBs.end(); }
bool CSVNStatusCache::UnBlockPath(const CTSVNPath& path) { bool ret = false; CTSVNPath p(path); do { CTSVNPath dbPath(p); dbPath.AppendPathString(g_SVNAdminDir.GetAdminDirName() + L"\\wc.db"); if (!dbPath.Exists()) p = p.GetContainingDirectory(); else { AutoLocker lock(m_NoWatchPathCritSec); std::map<CTSVNPath, ULONGLONG>::iterator it = m_NoWatchPaths.find(p); if (it != m_NoWatchPaths.end()) { CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": path removed from no good: %s\n", it->first.GetWinPath()); m_NoWatchPaths.erase(it); ret = true; } break; } } while (!p.IsEmpty()); AutoLocker lock(m_NoWatchPathCritSec); std::map<CTSVNPath, ULONGLONG>::iterator it = m_NoWatchPaths.find(path.GetDirectory()); if (it != m_NoWatchPaths.end()) { CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": path removed from no good: %s\n", it->first.GetWinPath()); m_NoWatchPaths.erase(it); ret = true; } AddFolderForCrawling(path.GetDirectory()); return ret; }
void BeAccessibleWindow::MessageReceived(BMessage* msg) { switch(msg->what) { case COMPACT_DATABASE_MSG: { GlobalSQLMgr->Compact(); break; } case OPEN_DATABASE_MSG: { BString path; if (msg->FindString("path", &path) == B_OK) { OpenDatabase(BPath(path.String())); } break; } case MENU_FILE_NEW_MSG: { fNewFile->Show(); break; } case MENU_FILE_OPEN_MSG: { fOpenFile->Show(); break; } case MENU_FILE_CLOSE_MSG: { CloseDatabase(); break; } case OPEN_BUTTON: { BString name; msg->FindString("TabName", &name); if (name == "Table" || name == "TableList") OpenTable(DATA_VIEW); //else if (name == "Query") break; } case DESIGN_BUTTON: { BString name; msg->FindString("TabName", &name); if (name == "Table") OpenTable(DESIGN_VIEW); //else if (name == "Query") break; } case NEW_BUTTON: { BString name; msg->FindString("TabName", &name); if (name == "Table") NewTable(DESIGN_VIEW); //else if (name == "Query") } case ENABLE_OPEN_BUTTON: { BString listName; msg->FindString("ListName", &listName); if (listName == "TableList") { fTableTab->fOpenButton->SetEnabled(true); fTableTab->fDesignButton->SetEnabled(true); } //else if (listName == "QueryList") break; } case DISABLE_OPEN_BUTTON: { BString listName; msg->FindString("ListName", &listName); if (listName == "TableList") { fTableTab->fOpenButton->SetEnabled(false); fTableTab->fDesignButton->SetEnabled(false); } //else if (listName == "QueryList") break; } case B_QUIT_REQUESTED: { BMessenger(be_app).SendMessage(B_QUIT_REQUESTED); break; } case IMPORT_FILE_REQUESTED_MSG: { fImportFile->SetTarget(BMessenger(this)); fImportFile->Show(); break; } case IMPORT_FILE_MSG: { entry_ref ref; msg->FindRef("refs", &ref); const BEntry entry(&ref, true); BPath dbPath(&entry); BRect frame(200,200,600,700); ImportFileWindow* importWindow = new ImportFileWindow(frame, dbPath.Path()); importWindow->Show(); break; } default: { BWindow::MessageReceived(msg); break; } } }
TogglApi::TogglApi( QObject *parent, QString logPathOverride, QString dbPathOverride) : QObject(parent) , shutdown(false) , ctx(0) { QString version = QApplication::applicationVersion(); ctx = toggl_context_init("linux_native_app", version.toStdString().c_str()); QString appDirPath = QStandardPaths::writableLocation( QStandardPaths::DataLocation); QDir appDir = QDir(appDirPath); if (!appDir.exists()) { appDir.mkpath("."); } QString logPath(""); if (logPathOverride.isEmpty()) { logPath = appDir.filePath("toggldesktop.log"); } else { logPath = logPathOverride; } toggl_set_log_path(logPath.toUtf8().constData()); qDebug() << "Log path " << logPath; toggl_set_log_level("debug"); QString dbPath(""); if (dbPathOverride.isEmpty()) { dbPath = appDir.filePath("toggldesktop.db"); } else { dbPath = dbPathOverride; } toggl_set_db_path(ctx, dbPath.toUtf8().constData()); qDebug() << "DB path " << dbPath; QString executablePath = QCoreApplication::applicationDirPath(); QDir executableDir = QDir(executablePath); QString cacertPath = executableDir.filePath("cacert.pem"); toggl_set_cacert_path(ctx, cacertPath.toUtf8().constData()); toggl_on_show_app(ctx, on_display_app); toggl_on_update(ctx, on_display_update); toggl_on_error(ctx, on_display_error); toggl_on_online_state(ctx, on_display_online_state); toggl_on_url(ctx, on_display_url); toggl_on_login(ctx, on_display_login); toggl_on_reminder(ctx, on_display_reminder); toggl_on_time_entry_list(ctx, on_display_time_entry_list); toggl_on_time_entry_autocomplete(ctx, on_display_time_entry_autocomplete); toggl_on_mini_timer_autocomplete(ctx, on_display_mini_timer_autocomplete); toggl_on_project_autocomplete(ctx, on_display_project_autocomplete); toggl_on_workspace_select(ctx, on_display_workspace_select); toggl_on_client_select(ctx, on_display_client_select); toggl_on_tags(ctx, on_display_tags); toggl_on_time_entry_editor(ctx, on_display_time_entry_editor); toggl_on_settings(ctx, on_display_settings); toggl_on_timer_state(ctx, on_display_timer_state); toggl_on_idle_notification(ctx, on_display_idle_notification); char *env = toggl_environment(ctx); if (env) { Bugsnag::releaseStage = QString(env); free(env); } instance = this; }
int main( int argc, char **argv ) { std::cout << "Skype History Exporter v1.3.0 Stable\n" << " WEBSITE: [ https://github.com/Temptin/SkypeExport ]\n"; // helps people find updated versions // prepare command line parameters po::options_description desc( "Available options" ); desc.add_options() ( "help,h", "show this help message" ) ( "db,i", po::value<std::string>()->default_value("./main.db"), "path to your Skype profile's main.db" ) ( "outpath,o", po::value<std::string>()->default_value("./ExportedHistory"), "path where all html files will be written; will be created if missing" ) ( "contacts,c", po::value<std::string>(), "space-separated list of the SkypeIDs to output; defaults to blank which outputs all contacts" ) ( "timefmt,t", po::value<std::string>()->default_value("12h"), "format of timestamps in history output; set to \"12h\" for 12-hour clock (default), \"24h\" for a 24-hour clock, \"utc12h\" for UTC-based 12-hour clock, or \"utc24h\" for UTC-based 24-hour clock" ) ; // parse and verify command line parameters po::variables_map vm; try { po::store( po::parse_command_line( argc, argv, desc ), vm ); po::notify( vm ); } catch(...) { // malformatted input of some kind, so just show the user the help and exit the program std::cout << "\nError: Invalid parameters!\n\n" << desc << "\n"; return 1; } // show the help and exit if that's what they asked for if( vm.count( "help" ) ) { std::cout << "\n" << desc << "\n"; return 0; } // detect their desired time format (24 hour or 12 hour time; default to 12h) and time reference (UTC or local time; default to local) uint8_t timeFormat = ( vm["timefmt"].as<std::string>() == "24h" || vm["timefmt"].as<std::string>() == "utc24h" ? 2 : 1 ); // used for formatTime() input, where 2=24h, 1=12h int8_t timeReference = ( vm["timefmt"].as<std::string>() == "utc12h" || vm["timefmt"].as<std::string>() == "utc24h" ? 0 : 1 ); // 0=utc, 1=local // verify the provided database and output paths and turn them into boost filesystem objects, then create the output path if needed fs::path dbPath( vm["db"].as<std::string>() ); fs::path outPath( vm["outpath"].as<std::string>() ); dbPath.make_preferred(); // formats all slashes according to operating system outPath.make_preferred(); try { if( !fs::exists( dbPath ) || !fs::is_regular_file( dbPath ) ) { std::cout << "\nError: Database " << dbPath.leaf() << " does not exist at the provided path!\n\n" << desc << "\n"; return 1; } if( fs::file_size( dbPath ) == 0 ) { std::cout << "\nError: Database " << dbPath.leaf() << " is empty!\n\n" << desc << "\n"; return 1; } if( fs::exists( outPath ) && !fs::is_directory( outPath ) ) { std::cout << "\nError: Output path " << outPath << " already exists and is not a directory!\n\n" << desc << "\n"; return 1; } else if( !fs::exists( outPath ) ) { // outPath either exists and is a directory, or doesn't exist. // we must now create the path if missing. will throw an exception on errors such as lack of write permissions. fs::create_directories( outPath ); // creates any missing directories in the given path. } } catch( const fs::filesystem_error &ex ) { std::cout << "\nError: " << ex.what() << "\n"; return 1; } // if they've provided a space-separated list of contacts to output, we need to tokenize it and store the SkypeIDs std::map<std::string,bool> outputContacts; // filled with all contacts to output, or blank to output all std::map<std::string,bool>::iterator outputContacts_it; if( vm.count( "contacts" ) ) { boost::char_separator<char> sep( " " ); boost::tokenizer< boost::char_separator<char> > tokens( vm["contacts"].as<std::string>(), sep ); for( boost::tokenizer< boost::char_separator<char> >::iterator identities_it( tokens.begin() ); identities_it != tokens.end(); ++identities_it ) { outputContacts_it = outputContacts.find( (*identities_it) ); if( outputContacts_it == outputContacts.end() ) { // makes sure we only add each unique skypeID once, even if the idiot user has provided it multiple times outputContacts.insert( std::pair<std::string,bool>( (*identities_it), false ) ); // NOTE: we initialize the skypeID as false, and will set it to true if it's been output } } } // alright, let's begin output... try { // open Skype history database SkypeParser::CSkypeParser sp( dbPath.string() ); // display all options (input database, output path, and all names to output (if specified)) std::cout << " DATABASE: [ " << dbPath << " ]\n" // note: no newline prefix (aligns it perfectly with version header) << " TIMEFMT: [ \"" << ( timeFormat == 1 ? "12h" : "24h" ) << " " << ( timeReference == 0 ? "UTC" : "Local Time" ) << "\" ]\n" << " OUTPUT: [ " << outPath << " ]\n"; if( outputContacts.size() > 0 ) { std::cout << " CONTACTS: [ \""; for( std::map<std::string,bool>::const_iterator it( outputContacts.begin() ); it != outputContacts.end(); ++it ) { std::cout << (*it).first; if( boost::next( it ) != outputContacts.end() ) { std::cout << "\", \""; // appended after every element except the last one } } std::cout << "\" ]\n\n"; } else { std::cout << " CONTACTS: [ \"*\" ]\n\n"; } // grab a list of all contacts encountered in the database const SkypeParser::skypeIDs_t &users = sp.getSkypeUsers(); // output statistics std::cout << "Found " << users.size() << " contacts in the database...\n\n"; // output contacts, skipping some in case the user provided a list of contacts to export for( SkypeParser::skypeIDs_t::const_iterator it( users.begin() ); it != users.end(); ++it ) { const std::string &skypeID = (*it); // skip if we're told to filter contacts outputContacts_it = outputContacts.find( (*it) ); // store iterator here since we'll set it to true after outputting, if contact filters are enabled if( outputContacts.size() > 0 && ( outputContacts_it == outputContacts.end() ) ) { continue; // if no filters, it's always false; if filters it's true if the contact is to be skipped } // construct the final path to the log file for this user fs::path logPath( outPath ); logPath /= ( (*it) + ".skypelog.htm" ); // appends the log filename and chooses the appropriate path separator // output exporting header std::cout << " * Exporting: " << skypeID << " (" << sp.getDisplayNameAtTime( skypeID, -1 ) << ")\n"; std::cout << " => " << logPath << "\n"; sp.exportUserHistory( skypeID, logPath.string(), timeFormat, timeReference ); if( outputContacts.size() > 0 ) { (*outputContacts_it).second = true; // since filters are enabled and we've come here, we know we've output the person as requested, so mark them as such } } } catch( const std::exception &e ) { std::cout << "Error while processing Skype database: \"" << e.what() << "\".\n"; return 1; } // check for any missing IDs if filtered output was requested for( std::map<std::string,bool>::const_iterator it( outputContacts.begin() ); it != outputContacts.end(); ++it ) { if( (*it).second == false ) { // a requested ID that was not found in the database std::cout << " * Not Found: " << (*it).first << "\n"; } } std::cout << "\nExport finished.\n"; return 0; }
static void dbPathCmd(char *path) { dbPath(pdbbase,path); }
static long dbReadCOM(DBBASE **ppdbbase,const char *filename, FILE *fp, const char *path,const char *substitutions) { long status; inputFile *pinputFile = NULL; char *penv; char **macPairs; if(*ppdbbase == 0) *ppdbbase = dbAllocBase(); pdbbase = *ppdbbase; if(path && strlen(path)>0) { dbPath(pdbbase,path); } else { penv = getenv("EPICS_DB_INCLUDE_PATH"); if(penv) { dbPath(pdbbase,penv); } else { dbPath(pdbbase,"."); } } my_buffer = dbCalloc(MY_BUFFER_SIZE,sizeof(char)); freeListInitPvt(&freeListPvt,sizeof(tempListNode),100); if(substitutions) { if(macCreateHandle(&macHandle,NULL)) { epicsPrintf("macCreateHandle error\n"); status = -1; goto cleanup; } macParseDefns(macHandle,(char *)substitutions,&macPairs); if(macPairs ==NULL) { macDeleteHandle(macHandle); macHandle = NULL; } else { macInstallMacros(macHandle,macPairs); free((void *)macPairs); mac_input_buffer = dbCalloc(MY_BUFFER_SIZE,sizeof(char)); } } pinputFile = dbCalloc(1,sizeof(inputFile)); if(filename) { pinputFile->filename = macEnvExpand(filename); } if(!fp) { FILE *fp1; if(pinputFile->filename) pinputFile->path = dbOpenFile(pdbbase,pinputFile->filename,&fp1); if(!pinputFile->filename || !fp1) { errPrintf(0,__FILE__, __LINE__, "dbRead opening file %s",pinputFile->filename); free((void *)pinputFile->filename); free((void *)pinputFile); status = -1; goto cleanup; } pinputFile->fp = fp1; } else { pinputFile->fp = fp; } pinputFile->line_num = 0; pinputFileNow = pinputFile; my_buffer[0] = '\0'; my_buffer_ptr = my_buffer; ellAdd(&inputFileList,&pinputFile->node); status = pvt_yy_parse(); dbFreePath(pdbbase); if(!status) { /*add RTYP and VERS as an attribute */ DBENTRY dbEntry; DBENTRY *pdbEntry = &dbEntry; long localStatus; dbInitEntry(pdbbase,pdbEntry); localStatus = dbFirstRecordType(pdbEntry); while(!localStatus) { localStatus = dbPutRecordAttribute(pdbEntry,"RTYP", dbGetRecordTypeName(pdbEntry)); if(!localStatus) { localStatus = dbPutRecordAttribute(pdbEntry,"VERS", "none specified"); } if(localStatus) { fprintf(stderr,"dbPutRecordAttribute status %ld\n",status); } else { localStatus = dbNextRecordType(pdbEntry); } } dbFinishEntry(pdbEntry); } cleanup: if(macHandle) macDeleteHandle(macHandle); macHandle = NULL; if(mac_input_buffer) free((void *)mac_input_buffer); mac_input_buffer = NULL; if(freeListPvt) freeListCleanup(freeListPvt); freeListPvt = NULL; if(my_buffer) free((void *)my_buffer); my_buffer = NULL; freeInputFileList(); return(status); }