+ #ifdef __CYGWIN__
+ // Cygwin returns unix type path but that does not work well
+ static wxChar windowsPath[MAX_PATH];
+ cygwin_conv_to_full_win32_path(strDir, windowsPath);
+ strDir = windowsPath;
+ #endif
+ #else // Windows
+ #ifdef __WIN32__
+ strDir.clear();
+
+ // If we have a valid HOME directory, as is used on many machines that
+ // have unix utilities on them, we should use that.
+ const wxChar *szHome = wxGetenv(wxT("HOME"));
+
+ if ( szHome != NULL )
+ {
+ strDir = szHome;
+ }
+ else // no HOME, try HOMEDRIVE/PATH
+ {
+ szHome = wxGetenv(wxT("HOMEDRIVE"));
+ if ( szHome != NULL )
+ strDir << szHome;
+ szHome = wxGetenv(wxT("HOMEPATH"));
+
+ if ( szHome != NULL )
+ {
+ strDir << szHome;
+
+ // the idea is that under NT these variables have default values
+ // of "%systemdrive%:" and "\\". As we don't want to create our
+ // config files in the root directory of the system drive, we will
+ // create it in our program's dir. However, if the user took care
+ // to set HOMEPATH to something other than "\\", we suppose that he
+ // knows what he is doing and use the supplied value.
+ if ( wxStrcmp(szHome, wxT("\\")) == 0 )
+ strDir.clear();
+ }
+ }
+
+ if ( strDir.empty() )
+ {
+ // If we have a valid USERPROFILE directory, as is the case in
+ // Windows NT, 2000 and XP, we should use that as our home directory.
+ szHome = wxGetenv(wxT("USERPROFILE"));
+
+ if ( szHome != NULL )
+ strDir = szHome;
+ }
+
+ if ( !strDir.empty() )
+ {
+ return strDir.c_str();
+ }
+ //else: fall back to the prograrm directory
+ #else // Win16
+ // Win16 has no idea about home, so use the executable directory instead
+ #endif // WIN16/32
+
+ // 260 was taken from windef.h
+ #ifndef MAX_PATH
+ #define MAX_PATH 260
+ #endif
+
+ wxString strPath;
+ ::GetModuleFileName(::GetModuleHandle(NULL),
+ strPath.GetWriteBuf(MAX_PATH), MAX_PATH);
+ strPath.UngetWriteBuf();
+
+ // extract the dir name
+ wxSplitPath(strPath, &strDir, NULL, NULL);
+
+ #endif // UNIX/Win
+
+ return strDir.c_str();
+}
+
+wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
+{
+ // VZ: the old code here never worked for user != "" anyhow! Moreover, it
+ // returned sometimes a malloc()'d pointer, sometimes a pointer to a
+ // static buffer and sometimes I don't even know what.
+ static wxString s_home;
+
+ return (wxChar *)wxGetHomeDir(&s_home);
+}
+
+bool wxDirExists(const wxString& dir)
+{
+#ifdef __WXMICROWIN__
+ return wxPathExist(dir);
+#elif defined(__WIN32__)
+ DWORD attribs = GetFileAttributes(dir);
+ return ((attribs != (DWORD)-1) && (attribs & FILE_ATTRIBUTE_DIRECTORY));
+#else // Win16
+ #ifdef __BORLANDC__
+ struct ffblk fileInfo;
+ #else
+ struct find_t fileInfo;
+ #endif
+ // In Borland findfirst has a different argument
+ // ordering from _dos_findfirst. But _dos_findfirst
+ // _should_ be ok in both MS and Borland... why not?
+ #ifdef __BORLANDC__
+ return (findfirst(dir, &fileInfo, _A_SUBDIR) == 0 &&
+ (fileInfo.ff_attrib & _A_SUBDIR) != 0);
+ #else
+ return (_dos_findfirst(dir, _A_SUBDIR, &fileInfo) == 0) &&
+ ((fileInfo.attrib & _A_SUBDIR) != 0);
+ #endif
+#endif // Win32/16
+}
+
+bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
+{
+ if ( path.empty() )
+ return FALSE;
+
+// old w32api don't have ULARGE_INTEGER
+#if defined(__WIN32__) && \
+ (!defined(__GNUWIN32__) || wxCHECK_W32API_VERSION( 0, 3 ))
+ // GetDiskFreeSpaceEx() is not available under original Win95, check for
+ // it
+ typedef BOOL (WINAPI *GetDiskFreeSpaceEx_t)(LPCTSTR,
+ PULARGE_INTEGER,
+ PULARGE_INTEGER,
+ PULARGE_INTEGER);
+
+ GetDiskFreeSpaceEx_t
+ pGetDiskFreeSpaceEx = (GetDiskFreeSpaceEx_t)::GetProcAddress
+ (
+ ::GetModuleHandle(_T("kernel32.dll")),
+#if wxUSE_UNICODE
+ "GetDiskFreeSpaceExW"
+#else
+ "GetDiskFreeSpaceExA"
+#endif
+ );
+
+ if ( pGetDiskFreeSpaceEx )