1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 //===========================================================================
26 //#####DESCRIPTIONBEGIN####
33 // Description: Interface to various global utility functions. Everything in this
34 // class is static (there are no instances).
41 //####DESCRIPTIONEND####
43 //===========================================================================
47 #define INCLUDEFILE <string>
48 #include "IncludeSTL.h"
49 #include <stdarg.h> // vsnprintf
53 static bool Launch (const CFileName &strFileName,const CFileName &strViewer);
54 static CString GetLastErrorMessageString ();
56 static bool AddToPath (const CFileName &strFolder, bool bAtFront=true);
57 static const CString LoadString (UINT id);
59 // Messagebox functions
61 // Vararg message box compositor
62 static int MessageBoxF (LPCTSTR pszFormat, ...);
64 static int MessageBoxFT (UINT nType, LPCTSTR pszFormat, ...);
65 // As above but with resource
66 static int MessageBoxFR (UINT nID, UINT nType, LPCTSTR pszFormat, ...);
68 static int MessageBoxFR (UINT nID, LPCTSTR pszFormat, ...);
70 static int vMessageBox(UINT nType, LPCTSTR pszFormat, va_list marker);
74 // Chop the string into pieces using separator cSep.
75 // The Boolean controls whether " and \ make a difference
76 static int Chop(LPCTSTR psz,CStringArray &ar,TCHAR cSep=_TCHAR(' '),bool bObserveStrings=false,bool bBackslashQuotes=false);
77 static int Chop(LPCTSTR psz,CStringArray &ar,LPCTSTR pszSep, bool bObserveStrings=false,bool bBackslashQuotes=false);
78 // String -> Integer, observing the current hex/decimal setting
79 static BOOL StrToItemIntegerType(const CString &str,__int64 &d);
80 static BOOL StrToDouble (const CString &strValue, double &dValue);
81 // Integer -> String, observing the current hex/decimal setting
82 static const CString IntToStr(__int64 d,bool bHex=false);
83 static const CString DoubleToStr (double dValue);
84 static CString StripExtraWhitespace (const CString & strInput);
86 // Provide a failure explanation for what just went wrong
87 static const CString Explanation (CFileException &exc);
88 static void UnicodeToCStr(LPCTSTR str,char *&psz);
89 static std::string UnicodeToStdStr(LPCTSTR str);
90 static CFileName WPath(const std::string &str);
91 static bool CopyFile (LPCTSTR pszSource,LPCTSTR pszDest);