bool BaseSetupDlg::Run(String& vars) { upp <<= GetVar("UPP"); output <<= GetVar("OUTPUT"); base <<= vars; new_base = IsNull(vars); while(TopWindow::Run() == IDOK) { String varname = ~base; String varfile = VarFilePath(varname); if(varname != vars) { if(FileExists(varfile) && !PromptOKCancel(NFormat("Overwrite existing assembly [* \1%s\1]?", varfile))) continue; if(!SaveVars(varname)) { Exclamation(NFormat("Error writing assmbly [* \1%s\1].", VarFilePath(varname))); continue; } } SetVar("UPP", ~upp); SetVar("OUTPUT", ~output); Vector<String> paths = SplitDirs(upp.GetText().ToString()); for(int i = 0; i < paths.GetCount(); i++) RealizeDirectory(paths[i]); RealizeDirectory(output); vars = varname; return true; } return false; }
/////////////////////////////////////////////////////////////////////////////////////// // main updater call // returns TRUE if app should continue, FALSE if should terminate // BEWARE, app MUST check for return value AND behave as needed // te SELF_UPDATE() macro does all what is needed bool Updater::Run() { // create user config path only on normal run if(state == NormalRun) RealizeDirectory(userConfigPath); // creates system config path on superuser mode if(state == InsideUpdater) RealizeDirectory(systemConfigPath); switch(state) { case NormalRun : return DO_NormalRun(); case InsideUpdater : return DO_InsideUpdater(); case UninstallFailed : return DO_UninstallFailed(); case InstallFailed : return DO_InstallFailed(); case UpdateFailed : return DO_UpdateFailed(); case UninstallSucceeded : return DO_UninstallSucceeded(); case InstallSucceeded : return DO_InstallSucceeded(); case UpdateSucceeded : return DO_UpdateSucceeded(); default: NEVER(); break; } // dummy return false; }
void WorkspaceWork::AddFile(ADDFILE af) { String active = GetActivePackage(); if(active.IsEmpty()) return; FileSel *fs = &OutputFs(); RealizeDirectory(GetLocalDir()); switch(af) { case PACKAGE_FILE: fs = &BasedSourceFs(); fs->BaseDir(GetFileFolder(PackagePathA(active))); break; case ANY_FILE: fs = &AnySourceFs(); break; case OUTPUT_FILE: fs->ActiveDir(GetOutputDir()); break; case CONFIG_FILE: fs->ActiveDir(GetConfigDir()); break; case HOME_FILE: fs->ActiveDir(GetHomeDirectory()); break; case LOCAL_FILE: fs->ActiveDir(GetLocalDir()); break; default: ; // GCC warns otherwise } if(!fs->ExecuteOpen("Add files to package..")) return; int fci = filelist.GetCursor(); int cs = filelist.GetSbPos(); int ci = fci >= 0 && fci < fileindex.GetCount() ? fileindex[fci] : -1; for(int i = 0; i < fs->GetCount(); i++) { Package::File& f = ci >= 0 ? actual.file.Insert(ci++) : actual.file.Add(); f = (*fs)[i]; f.readonly = fs->GetReadOnly(); } SaveLoadPackage(false); filelist.SetSbPos(cs); filelist.SetCursor(fci >= 0 ? fci : filelist.GetCount() - 1); FileSelected(); }
///////////////////////////////////////////////////////////////////////////////////// // adds a document void TPdfFrontend::AddDocument(String const &name, String const &Title) { if(FileExists(name)) { // create the dest path, if needed RealizeDirectory(GetPdfDataPath()); // opens sequence file, if any end read sequence number int Seq; String SeqPath = GetPdfDataPath() + "seqf"; if(FileExists(SeqPath)) { FileIn SeqFile(SeqPath); Seq = atoi(SeqFile.GetLine()); } else Seq = 1; // creates destination file name String DestName = GetPdfDataPath() + FormatIntDec(Seq, 4, '0') + "-" + Title; // copies the file to data folder FileCopy(name, DestName); // adds to document lists DocumentList.Add(Title); Documents.Add(DestName); // stores the next sequence number Seq++; FileOut SeqFile(SeqPath); SeqFile.PutLine(FormatInt(Seq)); } } // END TPdfFrontend::AddDocument()
String Ide::WorkspaceFile() { String nm; for(const char *s = main; *s; s++) nm.Cat(*s == '\\' || *s == '/' ? '$' : *s); String cfg = ConfigFile("cfg"); RealizeDirectory(cfg); return AppendFileName(cfg, ForceExt(nm + '@' + GetVarsName(), ".cfg")); }
///////////////////////////////////////////////////////////////////////////////////// // create handler void TPdfFrontend::onCreate(void) { FileSel fs; // if no documents, just do nothing if(!Documents.GetCount()) return; // first, gets last browsed path (if any) String cfgPath = GetPdfConfigPath() + "lastpath"; if(FileExists(cfgPath)) { FileIn f(cfgPath); fs.Set(f.GetLine()); } // gets the output file name, returns if cancelled fs.DefaultExt(".pdf").Type("documenti pdf", "*.pdf"); if(!fs.ExecuteSaveAs("Nome del documento pdf:")) return; // stores last active output path RealizeDirectory(GetPdfConfigPath()); FileOut f(cfgPath); f.PutLine(fs.Get()); // creates the command line and executes ghostscript String FileName = fs.Get(); String args = "-q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"" + FileName + "\" \"" + Documents[0] + "\""; for(int i = 1 ; i < Documents.GetCount(); i++) args = args + " \"" + Documents[i] + "\""; String OutStr, ErrStr; bool res = SysExec("gs", args, Environment(), OutStr, ErrStr); // creates progress bar and hooks inside client // Progress progress("Creazione pdf in corso...."); // Client.setProgress(progress); // progress.Create(); // Client.setProgress(0); // if(progress.Canceled()) // res = false; // if error, does nothing if(!res) return; // clear collected documents ClearDocuments(); // closes application Break(0); } // END TPdfFrontend::onCreate()
void Themed::WriteTheme() { if(IsNull(sWriteDir)) return; RealizeDirectory(sWriteDir); String imgdir = AppendFileName(sWriteDir, GetClass() + ".image"); FileOut out(AppendFileName(sWriteDir, GetClass() + ".class")); VectorMap<String, String> prop; VectorMap<String, Image> img; ThemeProperties tm(prop, img, false); Properties(tm); RealizeDirectory(imgdir); SaveImages(imgdir, NULL, img); SaveProp(out, prop, ""); Ctrl *p = dynamic_cast<Ctrl *>(this); if(p) for(Ctrl *q = p->GetFirstChild(); q; q = q->GetNext()) { Themed *t = dynamic_cast<Themed *>(q); if(t && t->id.GetCount()) { // prop.Clear(); // ThemeProperties tm(prop, img, false); // t->Properties(tm); out << t->id; Ctrl::LogPos pos = q->GetPos(); switch(pos.x.GetAlign()) { case Ctrl::LEFT: out << Format(" left %d, %d", pos.x.GetA(), pos.x.GetB()); break; case Ctrl::RIGHT: out << Format(" right %d, %d", pos.x.GetA(), pos.x.GetB()); break; case Ctrl::SIZE: out << Format(" hsize %d, %d", pos.x.GetA(), pos.x.GetB()); break; case Ctrl::CENTER: out << Format(" hcenter %d, %d", pos.x.GetB(), pos.x.GetA()); break; } switch(pos.y.GetAlign()) { case Ctrl::TOP: out << Format(" top %d, %d", pos.y.GetA(), pos.y.GetB()); break; case Ctrl::BOTTOM: out << Format(" bottom %d, %d", pos.y.GetA(), pos.y.GetB()); break; case Ctrl::SIZE: out << Format(" vsize %d, %d", pos.y.GetA(), pos.y.GetB()); break; case Ctrl::CENTER: out << Format(" vcenter %d, %d", pos.y.GetB(), pos.y.GetA()); break; } out << "\r\n"; // SaveProp(out, prop, " "); } } }
void WorkspaceWork::AddTopicGroup() { String package = GetActivePackage(); if(IsNull(package)) return; Tpp dlg; dlg.Load(PackageDirectory(package)); if(dlg.Run() != IDOK) return; String g = dlg.GetName(); if(g == "app.tpp") { String h = SourcePath(package, g); RealizeDirectory(h); SaveFile(AppendFileName(h, "all.i"), ""); } if(g.GetCount()) AddItem(g, false, false); }
void WorkspaceWork::DoImportTree(const String& dir, const String& mask, bool sep, Progress& pi, int from) { String active = GetActivePackage(); if(active.IsEmpty()) return; FindFile ff(AppendFileName(dir, "*.*")); Vector<String> dirs, files; while(ff) { String p = AppendFileName(dir, ff.GetName()); if(ff.IsFile() && PatternMatchMulti(mask, ff.GetName())) files.Add(p); if(ff.IsFolder()) dirs.Add(p); ff.Next(); } String relPath(dir.Mid(from)), absPath = SourcePath(active, relPath); if(sep && files.GetCount()) { if(!DirectoryExists(absPath)) if(!RealizeDirectory(absPath)) throw Format("An error occurred while creating the directory:&\1%s", absPath); Package::File& f = actual.file.Add(); f = relPath; f.separator = f.readonly = true; } Sort(files, &FileOrder_); Sort(dirs, &FileOrder_); for(int i = 0; i < files.GetCount(); i++) { if(pi.StepCanceled()) throw String(); String name = GetFileName(files[i]); if(FileCopy(files[i], AppendFileName(absPath, name))) { Package::File& f = actual.file.Add(); f = AppendFileName(relPath, name); f.separator = f.readonly = false; } else throw Format("An error occurred while copying the file:&\1%s", files[i]); } for(int i = 0; i < dirs.GetCount(); i++) DoImportTree(dirs[i], mask, true, pi, from); }
String WorkspaceWork::PackagePathA(const String& pn) { if(pn == prjaux) { String nm; String cfg = ConfigFile("cfg"); for(const char *s = main; *s; s++) nm.Cat(*s == '\\' || *s == '/' ? '$' : *s); RealizeDirectory(cfg); return AppendFileName(cfg, ForceExt(nm + '@' + GetVarsName(), ".aux")); } if(pn == ideaux) return ConfigFile("ide.aux"); if(pn == tempaux) return ConfigFile(Sprintf("aux%x.tmp", #ifdef PLATFORM_WIN32 GetCurrentProcessId() #endif #ifdef PLATFORM_POSIX getpid() #endif )); if(pn == METAPACKAGE) return Null; return PackagePath(pn); }
String TopicCacheName(const char *path) { String cfg = ConfigFile("cfg"); RealizeDirectory(cfg); return AppendFileName(cfg, ForceExt(Filter(path, NoSlashDot), ".tdx")); }
bool RealizePath(const String& file) { return RealizeDirectory(GetFileFolder(file)); }