]> git.saurik.com Git - wxWidgets.git/commitdiff
decode URIs in wxFileDataObject::SetData(); fixes problem with filenames with spaces...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 Oct 2004 22:14:55 +0000 (22:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 20 Oct 2004 22:14:55 +0000 (22:14 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/dataobj.cpp
src/gtk1/dataobj.cpp

index 0602e780372db27ec04a1ec7366240485ade5606..5a22da60b16a0ab6522e3f4189a312d9fb8d8f4f 100644 (file)
@@ -253,28 +253,10 @@ size_t wxFileDataObject::GetDataSize() const
 
 bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
 {
 
 bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
 {
-    // VZ: old format
-#if 0
-    // filenames are stores as a string with #0 as deliminators
-    const char *filenames = (const char*) buf;
-    size_t pos = 0;
-    for(;;)
-    {
-        if (filenames[0] == 0)
-            break;
-        if (pos >= size)
-            break;
-        wxString file( filenames );  // this returns the first file
-        AddFile( file );
-        pos += file.Len()+1;
-        filenames += file.Len()+1;
-    }
-#else // 1
     m_filenames.Empty();
 
     m_filenames.Empty();
 
-    // the text/uri-list format is a sequence of URIs (filenames prefixed by
-    // "file:" as far as I see) delimited by "\r\n" of total length size
-    // (I wonder what happens if the file has '\n' in its filename??)
+    // we get data in the text/uri-list format, i.e. as a sequence of URIs
+    // (filenames prefixed by "file:") delimited by "\r\n"
     wxString filename;
     for ( const char *p = (const char *)buf; ; p++ )
     {
     wxString filename;
     for ( const char *p = (const char *)buf; ; p++ )
     {
@@ -295,7 +277,7 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
                     lenPrefix += 2;
                 }
 
                     lenPrefix += 2;
                 }
 
-                AddFile(filename.c_str() + lenPrefix);
+                AddFile(wxURL::ConvertFromURI(filename.c_str() + lenPrefix));
                 filename.Empty();
             }
             else
                 filename.Empty();
             }
             else
@@ -315,7 +297,6 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
             filename += *p;
         }
     }
             filename += *p;
         }
     }
-#endif // 0/1
 
     return TRUE;
 }
 
     return TRUE;
 }
index 0602e780372db27ec04a1ec7366240485ade5606..5a22da60b16a0ab6522e3f4189a312d9fb8d8f4f 100644 (file)
@@ -253,28 +253,10 @@ size_t wxFileDataObject::GetDataSize() const
 
 bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
 {
 
 bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
 {
-    // VZ: old format
-#if 0
-    // filenames are stores as a string with #0 as deliminators
-    const char *filenames = (const char*) buf;
-    size_t pos = 0;
-    for(;;)
-    {
-        if (filenames[0] == 0)
-            break;
-        if (pos >= size)
-            break;
-        wxString file( filenames );  // this returns the first file
-        AddFile( file );
-        pos += file.Len()+1;
-        filenames += file.Len()+1;
-    }
-#else // 1
     m_filenames.Empty();
 
     m_filenames.Empty();
 
-    // the text/uri-list format is a sequence of URIs (filenames prefixed by
-    // "file:" as far as I see) delimited by "\r\n" of total length size
-    // (I wonder what happens if the file has '\n' in its filename??)
+    // we get data in the text/uri-list format, i.e. as a sequence of URIs
+    // (filenames prefixed by "file:") delimited by "\r\n"
     wxString filename;
     for ( const char *p = (const char *)buf; ; p++ )
     {
     wxString filename;
     for ( const char *p = (const char *)buf; ; p++ )
     {
@@ -295,7 +277,7 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
                     lenPrefix += 2;
                 }
 
                     lenPrefix += 2;
                 }
 
-                AddFile(filename.c_str() + lenPrefix);
+                AddFile(wxURL::ConvertFromURI(filename.c_str() + lenPrefix));
                 filename.Empty();
             }
             else
                 filename.Empty();
             }
             else
@@ -315,7 +297,6 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
             filename += *p;
         }
     }
             filename += *p;
         }
     }
-#endif // 0/1
 
     return TRUE;
 }
 
     return TRUE;
 }