bool Brewtarget::copyDataFiles(QString newPath) { QString dbFileName; bool success = true; // Database files. dbFileName = getUserDataDir() + "database.sqlite"; success &= QFile::copy(dbFileName, newPath + "database.sqlite"); return success; }
bool Brewtarget::initialize() { // Need these for changed(QMetaProperty,QVariant) to be emitted across threads. qRegisterMetaType<QMetaProperty>(); qRegisterMetaType<Equipment*>(); qRegisterMetaType<Mash*>(); qRegisterMetaType<Style*>(); qRegisterMetaType<Brewtarget::DBTable>(); qRegisterMetaType< QList<BrewNote*> >(); qRegisterMetaType< QList<Hop*> >(); qRegisterMetaType< QList<Instruction*> >(); qRegisterMetaType< QList<Fermentable*> >(); qRegisterMetaType< QList<Misc*> >(); qRegisterMetaType< QList<Yeast*> >(); qRegisterMetaType< QList<Water*> >(); // In Unix, make sure the user isn't running 2 copies. #if defined(Q_OS_LINUX) pidFile.setFileName(QString("%1.pid").arg(getUserDataDir())); if( pidFile.exists() ) { // Read the pid. qint64 pid; pidFile.open(QIODevice::ReadOnly); { QTextStream pidStream(&pidFile); pidStream >> pid; } pidFile.close(); // If the pid is in the proc filesystem, another instance is running. // Have to check /proc, because perhaps the last instance crashed without // cleaning up after itself. QDir procDir(QString("/proc/%1").arg(pid)); if( procDir.exists() ) { std::cerr << "Brewtarget is already running. PID: " << pid << std::endl; return false; } }
// // main // int main(int argc, char **argv) { #ifdef __unix__ // Load wxWindows Stub (for pop-up dialogues) (void)dlopen(WXSTUB_DLL_NAME, RTLD_NOW|RTLD_NODELETE); #endif #ifdef LOG char buff[1000]; if (getUserDataDir(buff, sizeof(buff)) != 0) { strcpy(buff, "c:"); } strcat(buff, "/gdbServer.log"); FILE *errorLog = fopen(buff, "wt"); Logging::setLogFileHandle(errorLog); #endif Logging::setLoggingLevel(100); LOGGING; #ifdef LOG Logging::print("Args = "); for (int index=0; index<argc; index++) { Logging::printq("%s ", argv[index]); } Logging::printq("\n"); #endif if (signal(SIGINT, signalHandler) == SIG_IGN) { (void)signal(SIGINT, SIG_IGN); } shared = SharedPtr(new Shared(TARGET_TYPE)); USBDM_ErrorCode rc = doArgs(argc, argv); if (rc != BDM_RC_OK) { Logging::print("Error %s\n", USBDM_GetErrorString(rc)); exit (-1); } Logging::print("After doArgs\n"); rc = shared->initBdm(); if (rc != BDM_RC_OK) { Logging::print("Error %s\n", USBDM_GetErrorString(rc)); exit (-1); } Logging::print("After shared->initBdm()\n"); // setDefaultWindowParent(FindEclipseWindowHwnd()); GdbInOutPipe *gdbInOut = GdbInOutPipe::getGdbInOut(); Logging::print("After GdbInOutPipe::getGdbInOut()\n"); // Redirect stdout to stderr dup2(2,1); if (gdbInOut == NULL) { Logging::print("Error gdbInOut() creation failed\n"); exit (-1); } Logging::print("After gdbInOut()\n"); // Now do the actual processing of GDB messages gdbHandlerInit(gdbInOut, *shared->getCurrentDevice(), callBack); gdbLoop(gdbInOut); gdbInOut->finish(); delete gdbInOut; return 0; }