decode URIs in wxFileDataObject::SetData(); fixes problem with filenames with spaces in their names (which were represented as )
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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
|
// we get data in the text/uri-list format, i.e. as a sequence of URIs
|
||||||
// "file:" as far as I see) delimited by "\r\n" of total length size
|
// (filenames prefixed by "file:") delimited by "\r\n"
|
||||||
// (I wonder what happens if the file has '\n' in its filename??)
|
|
||||||
wxString filename;
|
wxString filename;
|
||||||
for ( const char *p = (const char *)buf; ; p++ )
|
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();
|
filename.Empty();
|
||||||
}
|
}
|
||||||
else
|
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;
|
||||||
}
|
}
|
||||||
|
@@ -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
|
// we get data in the text/uri-list format, i.e. as a sequence of URIs
|
||||||
// "file:" as far as I see) delimited by "\r\n" of total length size
|
// (filenames prefixed by "file:") delimited by "\r\n"
|
||||||
// (I wonder what happens if the file has '\n' in its filename??)
|
|
||||||
wxString filename;
|
wxString filename;
|
||||||
for ( const char *p = (const char *)buf; ; p++ )
|
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();
|
filename.Empty();
|
||||||
}
|
}
|
||||||
else
|
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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user