void Themed::LoadTheme(const char *dir) { theme.Clear(); FindFile ff(AppendFileName(dir, "*.class")); while(ff) { String cls = ToLower(GetFileTitle(ff.GetName())); theme.GetAdd(cls).Load(dir, cls); ff.Next(); } }
String Ide::GetLogPath() { if(target.GetCount() == 0) return Null; #ifdef PLATFORM_WIN32 return ForceExt(target, ".log"); #else String p = GetFileTitle(target); return GetHomeDirFile(".upp/" + p + "/" + p + ".log"); #endif }
// Get the long name of a file, since the $#^%#@ Windows shell // passes the short one, *grumble* BOOL CFileFilter::GetLongPath(CString &fpath, CString *pflong) { if(pflong == NULL) pflong= &fpath; // no "~", i.e. already long if(fpath.Find("~") == -1) { *pflong=fpath; return TRUE; } // file is short WIN32_FIND_DATA fd; if( ::FindFirstFile(fpath, &fd) == INVALID_HANDLE_VALUE ) return FALSE; CString fname(fd.cFileName); if(fpath.Find("\\") == -1) // no src dir, we're done { *pflong= fname; return TRUE; } if(fname.Find("\\") == -1) // src dir, but no dst dir, add one { // one // directory // level // at // a // time // It's absolutely insane, but the only way :( CString fdir, str, dirfull, dirtitle; GetFileDir(fpath, fdir); while(fdir.Find("~") != -1) { ::FindFirstFile(fdir, &fd); // c:\foo~1\bar\test str= fd.cFileName; GetFileTitle(str, dirtitle); // test GetFileDir(fdir, str); // c:\foo~1\bar; fdir= str; dirfull= dirtitle + "\\" + dirfull; // \test } fname= fdir+"\\"+dirfull+fname; } *pflong= fname; return TRUE; }
void Load(const char *dir) { Index<String> exist; FindFile ff(AppendFileName(dir, "*.tpp")); while(ff) { if(ff.IsFolder()) { String s = GetFileTitle(ff.GetName()); group.Add(s, AttrText(TppName(s)).SetFont(StdFont().Bold())); exist.Add(s); } ff.Next(); } static const char *h[4] = { "src.tpp", "srcdoc.tpp", "srcimp.tpp", "app.tpp" }; for(int i = 0; i < __countof(h); i++) { String s = GetFileTitle(h[i]); if(exist.Find(s) < 0) group.Add(s, TppName(s) + " (new)"); } group.Add(Null, "<other new>"); group.GoBegin(); }
BOOL CCoolFormat3Doc::SaveModified() { if (!IsModified()) return TRUE; // ok to continue // get name/title of document CString name; if (m_strPathName.IsEmpty()) { // get name based on caption name = GetTitle(); if (name.IsEmpty()) ENSURE(name.LoadString(AFX_IDS_UNTITLED)); if (m_bTitleMark) { name = name.Left(name.GetLength() - 2); } } else { // get name based on file title of path name name = m_strPathName; GetFileTitle(m_strPathName, name.GetBuffer(_MAX_PATH), _MAX_PATH); name.ReleaseBuffer(); } CString prompt; BOOL bNameVaild = prompt.LoadString(IDS_IS_WANTSAVE); ASSERT(bNameVaild); CString strMsg; strMsg.Format(prompt, name); switch (CFMessageBox(strMsg, MB_YESNOCANCEL| MB_ICONINFORMATION)) { case IDCANCEL: return FALSE; // don't continue case IDYES: // If so, either Save or Update, as appropriate if (!DoFileSave()) return FALSE; // don't continue break; case IDNO: // If not saving changes, revert the document break; default: ASSERT(FALSE); break; } return TRUE; // keep going }
void InitWwwTpp() { String wwwtpp = AppendFileName(uppbox, "uppweb/www.tpp"); FindFile ff(AppendFileName(wwwtpp, "*")); static Vector<String> data; while(ff) { RLOG(ff.GetName()); Topic p = ReadTopic0(LoadFile(AppendFileName(wwwtpp, ff.GetName()))); data.Add(p.text); RegisterTopic__("<uppweb/www.tpp/all.i>", GetFileTitle(ff.GetName()), p.title, data.Top(), data.Top().GetCount()); ff.Next(); } };
ObjectFile::ObjectFile(LinkJob& j, int i, String lf, String of, FILETYPE ft, int lo, Time tm, int os) : linkjob(j), index(i), library_file(lf), object_file(of) , filetype(ft), library_offset(lo), file_time(tm), object_size(os) { autocollect = collected = used_any = false; dll_atom = 0; stab_index = -1; stabstr_index = -1; has_ctors_dtors = false; //!! terrible kludge String title = ToLower(GetFileTitle(object_file)); export_symbols = (filetype == DIRECT && title != "dllcrt2" && title != "crtbegin"); }
void TopicLinkDlg::Package() { String pg = group.GetCurrentName(); group.Clear(); if(!package.IsCursor()) return; FindFile ff(PackageGroup("*")); while(ff) { if(ff.IsFolder()) group.Add(GetFileTitle(ff.GetName()), TopicImg::Group()); ff.Next(); } topic.Clear(); group.FindSetCursor(pg); }
void SelectPackageDlg::SyncBase(String initvars) { Vector<String> varlist; for(FindFile ff(ConfigFile("*.var")); ff; ff.Next()) if(ff.IsFile()) varlist.Add(GetFileTitle(ff.GetName())); Sort(varlist, &PackageLess); base.Clear(); Append(base, varlist); if(!base.FindSetCursor(initvars)) if(base.GetCount() > 0) base.SetCursor(0); else OnBase(); }
void TopicEditor::Hyperlink(String& link, WString& text) { TopicLinkDlg d; d.link <<= link; String label; TopicLink tl; int q = link.ReverseFind('#'); if(q >= 0) { label = link.Mid(q + 1); tl = ParseTopicLink(link.Mid(0, q)); } else tl = ParseTopicLink(link); if(IsNull(tl.topic)) { d.package.FindSetCursor(GetFileTitle(GetFileFolder(grouppath))) && d.group.FindSetCursor(GetFileTitle(grouppath)) && d.topic.FindSetCursor(topic.GetCurrentName()); } else { d.package.FindSetCursor(tl.package) && d.group.FindSetCursor(tl.group) && d.topic.FindSetCursor(tl.topic) && d.label.FindSetCursor(label); } int c = d.Run(); if(c == IDCANCEL) return; link = ~d.link; if(c == IDOK) return; if(d.topic.IsCursor()) { String fn = AppendFileName(d.PackageGroup(d.group.GetCurrentName()), d.topic.GetCurrentName() + ".tpp"); text = ReadTopic(LoadFile(fn)).title.ToWString(); } }
void Ide::SetupDefaultMethod() { if(IsNull(method)) { SetMethod(GetDefaultMethod()); if(IsNull(method)) { FindFile ff(ConfigFile("*.bm")); if(!ff) return; SetMethod(GetFileTitle(ff.GetName())); } VectorMap<String, String> map = GetMethodVars(method); debug.linkmode = atoi(map.Get("DEBUG_LINKMODE", "0")); debug.def.debug = atoi(map.Get("DEBUG_INFO", "0")); debug.def.blitz = MapFlag(map, "DEBUG_BLITZ"); release.linkmode = atoi(map.Get("RELEASE_LINKMODE", "0")); release.def.debug <<= 0; release.def.blitz = MapFlag(map, "RELEASE_BLITZ"); } }
void Ide::SyncBuildMode() { SetupDefaultMethod(); Vector<String> bmlist; for(FindFile ff(ConfigFile("*.bm")); ff; ff.Next()) bmlist.Add(GetFileTitle(ff.GetName())); Sort(bmlist); methodlist.Clear(); Append(methodlist, bmlist); String h = method + ' '; switch(targetmode) { case 1: h << "Optimal"; break; case 2: h << "Speed"; break; case 3: h << "Size"; break; default: h << "Debug"; } buildmode <<= h; }
bool CScript::Open( LPCTSTR pszFilename, UINT wFlags ) { ADDTOCALLSTACK("CScript::Open"); // If we are in read mode and we have no script file. // ARGS: wFlags = OF_READ, OF_NONCRIT etc // RETURN: true = success. InitBase(); if ( pszFilename == NULL ) { pszFilename = GetFilePath(); } else { SetFilePath( pszFilename ); } LPCTSTR pszTitle = GetFileTitle(); if ( pszTitle == NULL || pszTitle[0] == '\0' ) return( false ); LPCTSTR pszExt = GetFilesExt( GetFilePath() ); if ( pszExt == NULL ) { TCHAR szTemp[ _MAX_PATH ]; strcpy( szTemp, GetFilePath() ); strcat( szTemp, GRAY_SCRIPT ); SetFilePath( szTemp ); wFlags |= OF_TEXT; } if ( !PhysicalScriptFile::Open( GetFilePath(), wFlags )) { if ( ! ( wFlags & OF_NONCRIT )) { g_Log.Event(LOGL_WARN, "'%s' not found...\n", static_cast<LPCTSTR>(GetFilePath())); } return( false ); } return( true ); }
void Ide::PreprocessInternal() { if(editor.GetLength() >= 1000000) // Sanity... return; int l = editor.GetCurrentLine(); PPSync(GetIncludePath()); String pfn = ConfigFile(GetFileTitle(editfile) + ".i.tmp"); Cpp cpp; StringStream in(editor.Get()); String p = NormalizeSourcePath(editfile); cpp.Preprocess(p, in, GetMasterFile(p)); Upp::SaveFile(pfn, cpp.output); HideBottom(); EditFile(pfn); EditAsText(); if(!editor.IsReadOnly()) ToggleReadOnly(); editor.SetCursor(editor.GetPos(l)); }
/** * Callback for FiosGetFileList. It tells if a file is a scenario or not. * @param mode Save/load mode. * @param file Name of the file to check. * @param ext A pointer to the extension identifier inside file * @param title Buffer if a callback wants to lookup the title of the file * @param last Last available byte in buffer (to prevent buffer overflows) * @return a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a scenario * @see FiosGetFileList * @see FiosGetScenarioList */ static FiosType FiosGetScenarioListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last) { /* Show scenario files * .SCN OpenTTD style scenario file * .SV0 Transport Tycoon Deluxe (Patch) scenario * .SS0 Transport Tycoon Deluxe preset scenario */ if (strcasecmp(ext, ".scn") == 0) { GetFileTitle(file, title, last, SCENARIO_DIR); return FIOS_TYPE_SCENARIO; } if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) { if (strcasecmp(ext, ".sv0") == 0 || strcasecmp(ext, ".ss0") == 0 ) { GetOldSaveGameName(file, title, last); return FIOS_TYPE_OLD_SCENARIO; } } return FIOS_TYPE_INVALID; }
void defMsg::Save() { if (path.IsEmpty()) { path = ConfigFile(name + ".msg") ; } else if ( name != GetFileTitle(path)) { path = GetFileDirectory(path) + name + ".msg" ; } String f ; f << "from=" << from << "\r\n" << "subject="<< subject << "\r\n" ; Vector<String> lines = String2VectorString(qtfBody) ; for (int i = 0; i < lines.GetCount(); i++) f << "body" << i << "=" << lines[i] << "\r\n" ; SaveFile(path, f) ; }
CString CFileDialog::GetFileName() const { ASSERT_VALID(this); #ifndef _MAC if (m_ofn.nFileExtension == 0 || m_ofn.lpstrFile[m_ofn.nFileExtension] == '\0') { return m_ofn.lpstrFile + m_ofn.nFileOffset; } else { TCHAR szFileName[_MAX_PATH]; ASSERT(m_ofn.nFileExtension - m_ofn.nFileOffset < _countof(szFileName)); lstrcpyn(szFileName, m_ofn.lpstrFile + m_ofn.nFileOffset, m_ofn.nFileExtension - m_ofn.nFileOffset); return szFileName; } #else return GetFileTitle(); #endif }
DWORD CSettingDlg::CreateSettingDialog(HINSTANCE hInstance) { DWORD dwRet = 0; WCHAR filePath[512] = L""; GetModuleFileName(hInstance, filePath, 512); wstring folder = L""; wstring fileTitle = L""; wstring iniPath = L""; GetFileFolder(filePath, folder); GetFileTitle(filePath, fileTitle); Format(grfPath, L"%s\\%s.grf", folder.c_str(), fileTitle.c_str()); Format(iniPath, L"%s\\%s.ini", folder.c_str(), fileTitle.c_str()); WCHAR buff[256] = L""; GetPrivateProfileString(L"SET", L"ext", L"ts", buff, 256, iniPath.c_str()); ext = buff; HANDLE file = _CreateFile( grfPath.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( file == INVALID_HANDLE_VALUE ) { //設定ファイルないので新規作成 ctrl.CreateNewGraph(); } else { CloseHandle(file); //設定ファイルあるのでロード ctrl.LoadGraph(grfPath.c_str()); } dwRet = (DWORD)DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG_SET), NULL, (DLGPROC)DlgProc ); if( dwRet == IDOK ) { WritePrivateProfileString( L"SET", L"ext", ext.c_str(), iniPath.c_str() ); } return dwRet; }
void OutMode::Load() { config.Clear(); const DropList& list = ide.mainconfiglist; for (int i = 0; i < list.GetCount(); ++i) config.Add(list.GetKey(i), list[i]); config <<= ide.mainconfigparam; method.Clear(); FindFile ff(ConfigFile("*.bm")); while(ff) { method.Add(GetFileTitle(ff.GetName())); ff.Next(); } method <<= ide.method; mode <<= ide.targetmode; export_dir <<= ide.export_dir; debug.Load(ide.debug); LoadFromWorkspace(debug, "outputmode-debug"); release.Load(ide.release); LoadFromWorkspace(release, "outputmode-release"); SyncLock(); }
/** * Callback for FiosGetFileList. It tells if a file is a savegame or not. * @param mode Save/load mode. * @param file Name of the file to check. * @param ext A pointer to the extension identifier inside file * @param title Buffer if a callback wants to lookup the title of the file; NULL to skip the lookup * @param last Last available byte in buffer (to prevent buffer overflows); not used when title == NULL * @return a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a savegame * @see FiosGetFileList * @see FiosGetSavegameList */ FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last) { /* Show savegame files * .SAV OpenTTD saved game * .SS1 Transport Tycoon Deluxe preset game * .SV1 Transport Tycoon Deluxe (Patch) saved game * .SV2 Transport Tycoon Deluxe (Patch) saved 2-player game */ if (strcasecmp(ext, ".sav") == 0) { GetFileTitle(file, title, last, SAVE_DIR); return FIOS_TYPE_FILE; } if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) { if (strcasecmp(ext, ".ss1") == 0 || strcasecmp(ext, ".sv1") == 0 || strcasecmp(ext, ".sv2") == 0) { if (title != NULL) GetOldSaveGameName(file, title, last); return FIOS_TYPE_OLDFILE; } } return FIOS_TYPE_INVALID; }
BOOL CBrowserView::RefreshView() { CBonfireDoc* pDoc = (CBonfireDoc*)GetDocument(); CString docPath = pDoc->GetPathName(); if (!pDoc->IsModified()) { // display the file in the browser viewer Navigate(docPath); } else { CString strAbsPath = theApp.m_pszHelpFilePath; DWORD nSize = 128; char* lpValue = (char*)malloc( nSize ); int retVal = GetEnvironmentVariable("TEMP", lpValue, nSize); if (retVal <= (int)nSize) strAbsPath = lpValue; else if (retVal == 0) { // try TMP retVal = GetEnvironmentVariable("TMP", lpValue, nSize); if (retVal <= (int)nSize) strAbsPath = lpValue; } // generate a temp file CString navPath = GetFilePath( AddSlash(strAbsPath) ) + "btmp_" + GetFileTitle( docPath ); pDoc->m_xTextBuffer.SaveToFile(navPath, CRLF_STYLE_AUTOMATIC, FALSE); // mark the file as temporary for later deletion theApp.AddTempFile( navPath ); // display the file in the browser viewer Navigate(navPath); } return TRUE; }
void CBonfireDoc::UpdateDocumentTitle(LPCTSTR lpszPathName /*=NULL*/) { CString title; // get the name from the file node if (lpszPathName != NULL) title = GetFileTitle(lpszPathName); else if (m_pXFile != NULL) title = m_pXFile->m_strName; else return; SetTitle(title); POSITION pos = GetFirstViewPosition(); CView* pView; if (pos && (pView = GetNextView(pos)) && pView->GetParentFrame()) { CString strTitle = title; if (IsModified())strTitle += " *"; if (m_xTextBuffer.GetReadOnly())strTitle += " (Read Only)"; pView->GetParentFrame()->SetWindowText(strTitle); } }
void WorkspaceWork::DoImport(const String& dir, const String& mask, bool sep, Progress& pi) { 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(); } if(sep && files.GetCount()) { Package::File& f = actual.file.Add(); f = GetFileTitle(dir); 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], SourcePath(active, name))) { Package::File& f = actual.file.Add(); f = 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++) DoImport(dirs[i], mask, true, pi); }
/*********************************************************************** * SetFileName * * Sets global file name and title * * ARGUMENTS: * - file name: * const char *FileName * RETURNS: none */ void SetFileName(const char *FileName) { lstrcpy(Globals.FileName, FileName); Globals.FileTitle[0] = 0; GetFileTitle(FileName, Globals.FileTitle, sizeof(Globals.FileTitle)); }
/*********************************************************************** * * SetFileName * * Sets Global File Name. */ VOID SetFileName(LPCTSTR szFileName) { _tcscpy(Globals.szFileName, szFileName); Globals.szFileTitle[0] = 0; GetFileTitle(szFileName, Globals.szFileTitle, SIZEOF(Globals.szFileTitle)); }
String Ide::GetConfigDir() { return GetHomeDirFile(".upp/" + GetFileTitle(target)); }
/**************************************************************************** * * FUNCTION: ExtractDlgProc * * PURPOSE: Window Procedure for the Extract Dialog * * PARAMS: HWND hWnd - This window handle * UINT Msg - Which Message? * WPARAM wParam - message parameter * LPARAM lParam - message parameter * * RETURNS: BOOL - FALSE for cancel, TRUE for ok * * History: * July '95 - Created * \****************************************************************************/ BOOL CALLBACK ExtractDlgProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ) { // Variable that holds info on this EXE/DLL static LPEXEDLLICONINFO lpEDII; switch( Msg ) { // During Paint, we will draw the currently selected icon case WM_PAINT: { HDC hDC; PAINTSTRUCT ps; DWORD nIndex; LPTSTR lpIconID; hDC = BeginPaint( hWnd, &ps ); // Get the current selection if( (nIndex = SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETCURSEL, 0, 0 )) != CB_ERR ) { // Get the data associated with the current selection - its the icon name if( (lpIconID = (LPTSTR)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETITEMDATA, nIndex, 0 )) != (LPTSTR)CB_ERR ) { RECT Rect, ButtonRect, DlgRect; HWND hWndButton; HICON hIcon; ICONINFO IconInfo; BITMAP bm; POINT UpperLeft, LowerRight; // Make an Icon hIcon = GetIconFromInstance( lpEDII->hInstance, lpIconID ); // Locate the icon GetIconInfo( hIcon, &IconInfo ); GetObject( IconInfo.hbmColor, sizeof(BITMAP), &bm ); hWndButton = GetDlgItem( hWnd, IDCANCEL ); GetWindowRect( hWndButton, &ButtonRect ); GetWindowRect( hWnd, &DlgRect ); UpperLeft.x = ButtonRect.left; UpperLeft.y = ButtonRect.bottom; LowerRight.x = ButtonRect.right; LowerRight.y = DlgRect.bottom; ScreenToClient( hWnd, &UpperLeft ); ScreenToClient( hWnd, &LowerRight ); SetRect( &Rect, UpperLeft.x, UpperLeft.y, LowerRight.x, LowerRight.y ); // Draw it DrawIcon( hDC, Rect.left + ((Rect.right - Rect.left - bm.bmWidth)/2), Rect.top + ((Rect.bottom - Rect.top - bm.bmHeight)/2), hIcon ); // Kill it DestroyIcon( hIcon ); } } EndPaint( hWnd, &ps ); } break; // End WM_PAINT // Dialog is being initialized case WM_INITDIALOG: { UINT nCount; TCHAR szBuffer[MAX_PATH], szFileTitle[MAX_PATH]; // Are we being sent data about an EXE/DLL? if( (lpEDII = (LPEXEDLLICONINFO)lParam) != NULL ) { // Set the title of the dialog to reflect the EXE/DLL filename GetFileTitle( lpEDII->szFileName, szFileTitle, MAX_PATH ); wsprintf( szBuffer, "Extract Icon [%s]", szFileTitle ); SetWindowText( hWnd, szBuffer ); // Fill in the listbox with the icons available if( ! EnumResourceNames( lpEDII->hInstance, RT_GROUP_ICON, MyEnumProcedure, (LPARAM)hWnd ) ) { MessageBox( hWnd, "Error Enumerating Icons", "Error", MB_OK ); PostMessage( hWnd, WM_CLOSE, 0, 0 ); } SendDlgItemMessage( hWnd, IDC_LIST1, LB_SETCURSEL, 0, 0 ); // If we have <= 1, post an OK message if( (nCount = SendDlgItemMessage(hWnd, IDC_LIST1, LB_GETCOUNT, 0, 0)) == 1 ) { PostMessage( hWnd, WM_COMMAND, IDOK, 0 ); } // If there were no icons, let the user know if( nCount == 0 ) { MessageBox( hWnd, "No Icons in this File", "Error", MB_OK ); PostMessage( hWnd, WM_CLOSE, 0, 0 ); } } return FALSE; } break; // End WM_INITDIALOG // Shut 'er down case WM_CLOSE: PostMessage( hWnd, WM_COMMAND, IDCANCEL, 0l ); break; // End WM_CLOSE // Children are sending messages case WM_COMMAND: switch( LOWORD(wParam) ) { // Its the listbox, just redraw the icon case IDC_LIST1: switch( HIWORD(wParam) ) { case CBN_SELCHANGE: case CBN_SELENDOK: InvalidateRect( hWnd, NULL, TRUE ); break; } break; // End IDC_LIST1 // User has chosen an icon, shut it down case IDOK: { LONG nIndex; lpEDII->lpID = NULL; if( (nIndex = SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETCURSEL, 0, 0 )) != LB_ERR ) lpEDII->lpID = (LPTSTR)SendDlgItemMessage( hWnd, IDC_LIST1, LB_GETITEMDATA, nIndex, 0 ); EndDialog( hWnd, TRUE ); } break; // End IDOK // BAIL! case IDCANCEL: EndDialog( hWnd, FALSE ); break; // End IDCANCEL } break; default: return FALSE; break; } return TRUE; }
bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, int pkcount, String mainparam, String outfile, Vector<String>& linkfile, String& linkopt, bool link) { String package = wspc[pkindex]; String mainpackage = wspc[0]; const Package& pkg = wspc.package[pkindex]; VectorMap<String, String> bm = GetMethodVars(method); if(bm.GetCount() == 0) { PutConsole("Invalid build method"); ConsoleShow(); return false; } One<Host> host = CreateHost(false); if(!IsNull(onefile)) { OneFileHost *h = new OneFileHost; h->host = host; h->onefile = onefile; host = h; } One<Builder> b = CreateBuilder(~host); if(!b) return false; b->config = PackageConfig(wspc, pkindex, bm, mainparam, *host, *b); const TargetMode& m = targetmode == 0 ? debug : release; b->version = m.version; b->method = method; b->outdir = OutDir(b->config, package, bm); host->RealizeDir(b->outdir); String mainfn = Null; Index<String> mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, &mainfn); HdependClearDependencies(); for(int i = 0; i < pkg.GetCount(); i++) { const Array<OptItem>& f = pkg[i].depends; for(int j = 0; j < f.GetCount(); j++) if(MatchWhen(f[j].when, mcfg.GetKeys())) HdependAddDependency(SourcePath(package, pkg[i]), SourcePath(package, f[j].text)); } String tout = OutDir(mcfg, mainpackage, bm, use_target); host->RealizeDir(tout); if(IsNull(mainfn)) mainfn = GetFileTitle(mainpackage) + b->GetTargetExt(); if(!IsNull(outfile)) target = NormalizePath(outfile, tout); else { if(m.target_override && !IsNull(m.target) && IsFolder(m.target)) target = host->NormalizePath(AppendFileName(m.target, mainfn)); else if(m.target_override && (IsFullPath(m.target) || *m.target == '/' || *m.target == '\\')) target = m.target; else if(m.target_override && !IsNull(m.target)) target = host->NormalizePath(AppendFileName(tout, m.target)); else if(IsFullPath(mainfn)) target = mainfn; else target = host->NormalizePath(AppendFileName(tout, mainfn)); } b->target = target; b->mainpackage = mainpackage; if(IsNull(onefile)) { String out; out << "----- " << package << " ( " << Join(b->config.GetKeys(), " ") << " )"; if(pkcount > 1) out << " (" << (pknumber + 1) << " / " << pkcount << ')'; PutConsole(out); } else b->config.FindAdd("NOLIB"); bool ok = b->BuildPackage(package, linkfile, linkopt, GetAllUses(wspc, pkindex), GetAllLibraries(wspc, pkindex, bm, mainparam, *host, *b), targetmode - 1); Vector<String> errors = PickErrors(); host->DeleteFile(errors); if(!ok || !errors.IsEmpty()) return false; if(link) { ok = b->Link(linkfile, linkopt, GetTargetMode().createmap); errors = PickErrors(); host->DeleteFile(errors); if(!ok || !errors.IsEmpty()) return false; } return true; }
int NTAPI PathGetTailLength(LPCTSTR path) { //GetFileTitle() returns garbage when passed in empty path... return *path ? GetFileTitle(path, 0, 0) : 0; }
Vector<String> CppBuilder::CustomStep(const String& pf, const String& package_, bool& error) { String package = Nvl(package_, mainpackage); String path = (*pf == '.' && pf[1] != '.') ? target : SourcePath(package, pf); String file = GetHostPath(path); String ext = ToLower(GetFileExt(pf)); if(ext == ".ext") { Vector<String> files; Vector<String> dirs; sGatherAllExt(files, dirs, GetFileFolder(path), ""); Index<String> pkg_files; Package pkg; pkg.Load(PackagePath(package)); for(int i = 0; i < pkg.GetCount(); i++) pkg_files.Add(pkg[i]); Index<String> out; Index<String> include_path; String f = LoadFile(path); try { CParser p(f); while(!p.IsEof()) { if(p.Id("files")) { Vector<String> e = ReadPatterns(p); for(int i = 0; i < files.GetCount(); i++) for(int j = 0; j < e.GetCount(); j++) { String f = files[i]; if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) out.FindAdd(f); } } if(p.Id("exclude")) { ExtExclude(p, out); } if(p.Id("include_path")) { Vector<String> e = ReadPatterns(p); for(int j = 0; j < e.GetCount(); j++) { String ee = e[j]; if(ee.Find('*') >= 0) for(int i = 0; i < dirs.GetCount(); i++) { String d = dirs[i]; if(PatternMatch(e[j], d)) { include_path.FindAdd(d); } } else include_path.Add(ee); } } if(p.Id("exclude_path")) { ExtExclude(p, include_path); } if(p.Id("includes")) { Vector<String> e = ReadPatterns(p); for(int i = 0; i < files.GetCount(); i++) for(int j = 0; j < e.GetCount(); j++) { String f = files[i]; if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) include_path.FindAdd(GetFileFolder(f)); } } } } catch(CParser::Error) { PutConsole("Invalid .ext file"); error = true; return Vector<String>(); } for(int i = 0; i < include_path.GetCount(); i++) include.Add(NormalizePath(include_path[i], GetFileFolder(path))); Vector<String> o; for(int i = 0; i < out.GetCount(); i++) o.Add(SourcePath(package, out[i])); return o; } for(int i = 0; i < wspc.GetCount(); i++) { const Array< ::CustomStep >& mv = wspc.GetPackage(i).custom; for(int j = 0; j < mv.GetCount(); j++) { const ::CustomStep& m = mv[j]; if(MatchWhen(m.when, config.GetKeys()) && m.MatchExt(ext)) { VectorMap<String, String> mac; AddPath(mac, "PATH", file); AddPath(mac, "RELPATH", pf); AddPath(mac, "DIR", GetFileFolder(PackagePath(package))); AddPath(mac, "FILEDIR", GetFileFolder(file)); AddPath(mac, "PACKAGE", package); mac.Add("FILE", GetFileName(file)); mac.Add("TITLE", GetFileTitle(file)); AddPath(mac, "EXEPATH", GetHostPath(target)); AddPath(mac, "EXEDIR", GetHostPath(GetFileFolder(target))); mac.Add("EXEFILE", GetFileName(target)); mac.Add("EXETITLE", GetFileTitle(target)); AddPath(mac, "OUTDIR", GetHostPath(outdir)); //BW AddPath(mac, "OUTDIR", GetHostPath(GetFileFolder(target))); AddPath(mac, "OUTFILE", GetHostPath(GetFileName(target))); AddPath(mac, "OUTTITLE", GetHostPath(GetFileTitle(target))); mac.Add("INCLUDE", Join(include, ";")); Vector<String> out = Cuprep(m.output, mac, include); bool dirty = out.IsEmpty(); for(int i = 0; !dirty && i < out.GetCount(); i++) dirty = (GetFileTime(file) > GetFileTime(out[i])); if(dirty) { HdependTimeDirty(); PutConsole(GetFileName(file)); Vector<String> cmd = Cuprep(m.command, mac, include); String cmdtext; for(int c = 0; c < cmd.GetCount(); c++) { PutVerbose(cmd[c]); if(!Cd(cmd[c]) && !Cp(cmd[c], package, error)) { String ctext = cmd[c]; const char *cm = ctext; if(*cm == '?') cm++; if(*ctext != '?' && Execute(cm)) { for(int t = 0; t < out.GetCount(); t++) DeleteFile(out[t]); PutConsole("FAILED: " + ctext); error = true; return Vector<String>(); } } } } return out; } } } Vector<String> out; out.Add(path); return out; }