#if defined(__CYGWIN__)
#include <sys/unistd.h>
#include <sys/stat.h>
- #include <sys/cygwin.h> // for cygwin_conv_to_full_win32_path()
+ #include <sys/cygwin.h> // for cygwin_conv_path()
+ // and cygwin_conv_to_full_win32_path()
+ #include <cygwin/version.h>
#endif //GNUWIN32
#ifdef __BORLANDC__ // Please someone tell me which version of Borland needs
static const wxChar eUSERNAME[] = wxT("UserName");
#endif
+WXDLLIMPEXP_DATA_BASE(const wxChar *) wxUserResourceStr = wxT("TEXT");
+
// ============================================================================
// implementation
// ============================================================================
// first branch is for Cygwin
#if defined(__UNIX__) && !defined(__WINE__)
- const wxChar *szHome = wxGetenv("HOME");
+ const wxChar *szHome = wxGetenv(wxT("HOME"));
if ( szHome == NULL ) {
// we're homeless...
wxLogWarning(_("can't find user's HOME, using current directory."));
#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);
+ #if CYGWIN_VERSION_DLL_MAJOR >= 1007
+ cygwin_conv_path(CCP_POSIX_TO_WIN_W, strDir, windowsPath, MAX_PATH);
+ #else
+ cygwin_conv_to_full_win32_path(strDir, windowsPath);
+ #endif
strDir = windowsPath;
#endif
#elif defined(__WXWINCE__)
ULARGE_INTEGER bytesFree, bytesTotal;
// may pass the path as is, GetDiskFreeSpaceEx() is smart enough
- if ( !pGetDiskFreeSpaceEx(path.fn_str(),
+ if ( !pGetDiskFreeSpaceEx(path.t_str(),
&bytesFree,
&bytesTotal,
NULL) )
// FIXME: this is wrong, we should extract the root drive from path
// instead, but this is the job for wxFileName...
- if ( !::GetDiskFreeSpace(path.fn_str(),
+ if ( !::GetDiskFreeSpace(path.t_str(),
&lSectorsPerCluster,
&lBytesPerSector,
&lNumberOfFreeClusters,
#endif
}
+// ----------------------------------------------------------------------------
+// working with MSW resources
+// ----------------------------------------------------------------------------
+
+bool
+wxLoadUserResource(const void **outData,
+ size_t *outLen,
+ const wxString& resourceName,
+ const wxString& resourceType,
+ WXHINSTANCE instance)
+{
+ wxCHECK_MSG( outData && outLen, false, "output pointers can't be NULL" );
+
+ HRSRC hResource = ::FindResource(instance,
+ resourceName.wx_str(),
+ resourceType.wx_str());
+ if ( !hResource )
+ return false;
+
+ HGLOBAL hData = ::LoadResource(instance, hResource);
+ if ( !hData )
+ {
+ wxLogSysError(_("Failed to load resource \"%s\"."), resourceName);
+ return false;
+ }
+
+ *outData = ::LockResource(hData);
+ if ( !*outData )
+ {
+ wxLogSysError(_("Failed to lock resource \"%s\"."), resourceName);
+ return false;
+ }
+
+ *outLen = ::SizeofResource(instance, hResource);
+
+ // Notice that we do not need to call neither UnlockResource() (which is
+ // obsolete in Win32) nor GlobalFree() (resources are freed on process
+ // termination only)
+
+ return true;
+}
+
+char *
+wxLoadUserResource(const wxString& resourceName,
+ const wxString& resourceType,
+ int* pLen,
+ WXHINSTANCE instance)
+{
+ const void *data;
+ size_t len;
+ if ( !wxLoadUserResource(&data, &len, resourceName, resourceType, instance) )
+ return NULL;
+
+ char *s = new char[len + 1];
+ memcpy(s, data, len);
+ s[len] = '\0'; // NUL-terminate in case the resource itself wasn't
+
+ if (pLen)
+ *pLen = len;
+
+ return s;
+}
+
// ----------------------------------------------------------------------------
// OS version
// ----------------------------------------------------------------------------