]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/volume.cpp
compilation fixes
[wxWidgets.git] / src / msw / volume.cpp
index 378c3fff1b638309a7d905599f5bd05701abb298..628dc4e66ca94f85a8807e17991a5aef7f077201 100644 (file)
     #pragma hdrstop
 #endif
 
+#if wxUSE_FSVOLUME
+
 #ifndef WX_PRECOMP
-#include <wx/icon.h>
-#include <wx/intl.h>
+    #include "wx/icon.h"
+    #include "wx/intl.h"
 #endif // WX_PRECOMP
 
 #include "wx/dir.h"
 
 #include "wx/volume.h"
 
-// Win32 headers
-#include <shlobj.h>
+#include <shellapi.h>
+
+#ifndef SHGetFileInfo
+#ifdef UNICODE
+#define SHGetFileInfo SHGetFileInfoW
+#else
+#define SHGetFileInfo SHGetFileInfoA
+#endif
+#endif
+
+#ifndef SHGFI_ATTRIBUTES
+    #define SHGFI_ATTRIBUTES 2048
+#endif
+
+#ifndef SFGAO_READONLY
+    #define SFGAO_READONLY 0x00040000L
+#endif
+
+#ifndef SFGAO_REMOVABLE
+    #define SFGAO_REMOVABLE 0x02000000L
+#endif
+
+#ifndef SHGFI_DISPLAYNAME
+    #define SHGFI_DISPLAYNAME 512
+#endif
+
+#ifndef SHGFI_ICON
+    #define SHGFI_ICON 256
+#endif
+
+#ifndef SHGFI_SMALLICON
+     #define SHGFI_SMALLICON 1
+#endif
+
+#ifndef SHGFI_SHELLICONSIZE
+    #define SHGFI_SHELLICONSIZE 4
+#endif
+
+#ifndef SHGFI_OPENICON
+    #define SHGFI_OPENICON 2
+#endif
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 // Dynamic library function defs.
@@ -61,20 +102,39 @@ static WNetCloseEnumPtr s_pWNetCloseEnum;
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 static long s_cancelSearch = FALSE;
 
-struct FileInfo : public wxObject
+struct FileInfo
 {
     FileInfo(unsigned flag=0, wxFSVolumeKind type=wxFS_VOL_OTHER) :
         m_flags(flag), m_type(type) {}
+
+    FileInfo(const FileInfo& other) { *this = other; }
+    FileInfo& operator=(const FileInfo& other)
+    {
+        m_flags = other.m_flags;
+        m_type = other.m_type;
+        return *this;
+    }
+
     unsigned m_flags;
     wxFSVolumeKind m_type;
 };
 WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap);
-static FileInfoMap s_fileInfo(25);
+// Cygwin bug (?) destructor for global s_fileInfo is called twice...
+static FileInfoMap& GetFileInfoMap()
+{
+    static FileInfoMap s_fileInfo(25);
+
+    return s_fileInfo;
+}
+#define s_fileInfo (GetFileInfoMap())
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 // Other initialization.
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-WX_DEFINE_OBJARRAY(wxIconArray);
+#if wxUSE_GUI
+// already in wx/iconbndl.h
+// WX_DEFINE_OBJARRAY(wxIconArray);
+#endif
 
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 // Local helper functions.
@@ -219,8 +279,8 @@ static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc,
     //----------------------------------------------------------------------
     if (rc = s_pWNetOpenEnum(scope, RESOURCETYPE_DISK, 0, pResSrc, &hEnum), rc == NO_ERROR)
     {
-        unsigned long count = 1;
-        unsigned long size = 256;
+        DWORD count = 1;
+        DWORD size = 256;
         NETRESOURCE* pRes = (NETRESOURCE*)malloc(size);
         memset(pRes, 0, sizeof(NETRESOURCE));
         while (rc = s_pWNetEnumResource(hEnum, &count, pRes, &size), rc == NO_ERROR || rc == ERROR_MORE_DATA)
@@ -369,7 +429,7 @@ wxArrayString wxFSVolume::GetVolumes(int flagsSet, int flagsUnset)
     {
 #ifdef UNICODE
         s_pWNetOpenEnum = (WNetOpenEnumPtr)s_mprLib.GetSymbol(_T("WNetOpenEnumW"));
-        s_pWNetEnumResource = (WNetEnumResourcePtr)s_mprLib.GetSymbol("WNetEnumResourceW");
+        s_pWNetEnumResource = (WNetEnumResourcePtr)s_mprLib.GetSymbol(_T("WNetEnumResourceW"));
 #else
         s_pWNetOpenEnum = (WNetOpenEnumPtr)s_mprLib.GetSymbol(_T("WNetOpenEnumA"));
         s_pWNetEnumResource = (WNetEnumResourcePtr)s_mprLib.GetSymbol(_T("WNetEnumResourceA"));
@@ -475,7 +535,7 @@ bool wxFSVolume::Create(const wxString& name)
     }
     m_dispName = fi.szDisplayName;
 
-#ifdef wxUSE_GUI
+#if wxUSE_GUI
 
     m_icons.Alloc(wxFS_VOL_ICO_MAX);
     int idx;
@@ -533,7 +593,7 @@ int wxFSVolume::GetFlags() const
     return itr->second.m_flags;
 } // GetFlags
 
-#ifdef wxUSE_GUI
+#if wxUSE_GUI
 
 //=============================================================================
 // Function: GetIcon
@@ -586,3 +646,5 @@ wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
 
 #endif // wxUSE_GUI
 
+#endif // wxUSE_FSVOLUME
+