#endif //__BORLANDC__
#ifndef WX_PRECOMP
- #include <wx/string.h>
- #include <wx/intl.h>
+ #include "wx/string.h"
+ #include "wx/intl.h"
#endif //WX_PRECOMP
-#include <wx/app.h>
-#include <wx/dynarray.h>
-#include <wx/file.h>
-#include <wx/log.h>
-#include <wx/textfile.h>
-#include <wx/config.h>
-#include <wx/fileconf.h>
+#include "wx/app.h"
+#include "wx/dynarray.h"
+#include "wx/file.h"
+#include "wx/log.h"
+#include "wx/textfile.h"
+#include "wx/config.h"
+#include "wx/fileconf.h"
+
+#include "wx/utils.h" // for wxGetHomeDir
// _WINDOWS_ is defined when windows.h is included,
// __WXMSW__ is defined for MS Windows compilation
// ----------------------------------------------------------------------------
#define CONST_CAST ((wxFileConfig *)this)->
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+#ifndef MAX_PATH
+ #define MAX_PATH 512
+#endif
+
// ----------------------------------------------------------------------------
// global functions declarations
// ----------------------------------------------------------------------------
#ifdef __UNIX__
strDir = "/etc/";
#elif defined(__WXSTUBS__)
- // TODO
- wxASSERT( TRUE ) ;
+ wxASSERT_MSG( FALSE, "TODO" ) ;
#else // Windows
- #ifndef _MAX_PATH
- #define _MAX_PATH 512
- #endif
-
- char szWinDir[_MAX_PATH];
- ::GetWindowsDirectory(szWinDir, _MAX_PATH);
+ char szWinDir[MAX_PATH];
+ ::GetWindowsDirectory(szWinDir, MAX_PATH);
strDir = szWinDir;
strDir << '\\';
{
wxString strDir;
- #ifdef __UNIX__
- const char *szHome = getenv("HOME");
- if ( szHome == NULL ) {
- // we're homeless...
- wxLogWarning(_("can't find user's HOME, using current directory."));
- strDir = ".";
- }
- else
- strDir = szHome;
- strDir << '/'; // a double slash is no problem, a missin one yes
- #else // Windows
- #ifdef __WIN32__
- const char *szHome = getenv("HOMEDRIVE");
- if ( szHome != NULL )
- strDir << szHome;
- szHome = getenv("HOMEPATH");
- if ( szHome != NULL )
- strDir << szHome;
- #else // Win16
- // Win16 has no idea about home, so use the current directory instead
- strDir = ".\\";
- #endif // WIN16/32
- #endif // UNIX/Win
+ wxGetHomeDir(&strDir);
+
+#ifdef __UNIX__
+ if (strDir.Last() != '/') strDir << '/';
+#else
+ if (strDir.Last() != '\\') strDir << '\\';
+#endif
return strDir;
}
bool wxFileConfig::Write(const wxString& key, long lValue)
{
// ltoa() is not ANSI :-(
- char szBuf[40]; // should be good for sizeof(long) <= 16 (128 bits)
- sprintf(szBuf, "%ld", lValue);
- return Write(key, szBuf);
+ wxString buf;
+ buf.Printf("%ld", lValue);
+ return Write(key, buf);
}
bool wxFileConfig::Flush(bool /* bCurrentOnly */)
// last entry?
if ( pNext == NULL )
m_linesTail = pPrev;
- else
+ else
pNext->SetPrev(pPrev);
delete pLine;
// this group wasn't present in local config file, add it now
if ( pParent != NULL ) {
wxString strFullName;
- strFullName << "[" << GetFullName().c_str() + 1 << "]"; // +1: no '/'
+ strFullName << "[" << (GetFullName().c_str() + 1) << "]"; // +1: no '/'
m_pLine = m_pConfig->LineListInsert(strFullName,
pParent->GetLastGroupLine());
pParent->SetLastGroup(this); // we're surely after all the others
{
if(str.IsEmpty())
return str;
-
+
wxString strResult;
strResult.Alloc(str.Len());