// Return absolute pathname of item FXString FXDirList::getItemPathname(const FXTreeItem* item) const { FXString path; if(item){ while(1){ path.prepend(item->getText()); item=item->parent; if(!item) break; if(item->parent) path.prepend(PATHSEP); } } return path; }
// Return item path FXString FXDirBox::getItemPathname(FXTreeItem *item) const { FXString string; if(item){ while(item->getParent()){ string.prepend(getItemText(item)); item=item->getParent(); if(item->getParent()) string.prepend(PATHSEPSTRING); } string.prepend(getItemText(item)); } return string; }
bool BackupMgr::SaveBackup(SciDoc*sci) { FXString savename; FXString untitled; untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci)); if (SciDocUtils::Filename(sci).empty()) { savename=untitled; } else { if (FXStat::isFile(untitled)) { RemoveBackup(untitled); } #ifdef WIN32 savename=SciDocUtils::Filename(sci).text(); savename.substitute(':', '%', true); savename.prepend(backupdir.text()); #else savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text()); #endif } if (MakePath(FXPath::directory(savename))) { if (SciDocUtils::SaveToFile(sci,savename.text(),false)) { SciDocUtils::NeedBackup(sci, false); return true; } else { lasterror=SciDocUtils::GetLastError(sci); ErrorMessage(_("Failed to save backup"), savename); return false; } } else { return false; } }
FXString ProjectBrowser::getPathname(FXTreeItem* item) { FXString path; FXTreeItem* current = item; while (true) { path.prepend(current->getText()); path.prepend(FS::dirSeparator()); FXTreeItem* parent = current->getParent(); if (parent == NULL) break; current = parent; } path.prepend(mainWin->settings->getStringValue("baseDir")); return path; }
void MigrateConfigDir(FXApp*a, const FXString &src, const FXString &dst, FXString &errors) { if (!FXStat::isDirectory(src)) { return; } if (FXStat::isDirectory(dst)) { return; } FXMessageBox dlg(a, _("IMPORTANT NOTICE"), _( "\n" "The location of the "APP_NAME" configuration directory has changed.\n" "\n" #ifndef WIN32 "This is due to changes in the FOX toolkit, in accordance with\n" "the freedesktop.org \"XDG base directory specification\".\n" "\n" #endif "Migration options:\n" " Click [ Yes ] to automatically copy your old settings (recommended).\n" " Click [ No ] to create a new configuration.\n" " Click [Cancel] to exit "APP_NAME" now without any changes.\n" "\n" "Do you want me to copy your existing configuration?" ), NULL,MBOX_YES_NO_CANCEL ); a->create(); FXint rv=dlg.execute(PLACEMENT_SCREEN); switch (rv) { case MBOX_CLICKED_YES: { copyConfigFiles(src,dst,errors,0); if (!errors.empty()) { errors.prepend("================================\n"); errors.prepend(_("Settings migration messages:\n")); errors.prepend("================================\n"); } a->reg().read(); return; } case MBOX_CLICKED_NO: { return; } default: { ::exit(0); } } }
void BackupMgr::RemoveBackup(SciDoc*sci) { FXString untitled; SciDocUtils::NeedBackup(sci,false); untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci)); RemoveBackup(untitled); if (!SciDocUtils::Filename(sci).empty()) { FXString savename; #ifdef WIN32 savename=SciDocUtils::Filename(sci).text(); savename.substitute(':', '%', true); savename.prepend(backupdir.text()); #else savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text()); #endif RemoveBackup(savename); } }