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:
Vadim Zeitlin 2004-10-20 22:14:55 +00:00
parent 4e689ecdb5
commit e188df5dea
2 changed files with 6 additions and 44 deletions

View File

@ -253,28 +253,10 @@ size_t wxFileDataObject::GetDataSize() const
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();
// 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++ )
{
@ -295,7 +277,7 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
lenPrefix += 2;
}
AddFile(filename.c_str() + lenPrefix);
AddFile(wxURL::ConvertFromURI(filename.c_str() + lenPrefix));
filename.Empty();
}
else
@ -315,7 +297,6 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
filename += *p;
}
}
#endif // 0/1
return TRUE;
}

View File

@ -253,28 +253,10 @@ size_t wxFileDataObject::GetDataSize() const
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();
// 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++ )
{
@ -295,7 +277,7 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
lenPrefix += 2;
}
AddFile(filename.c_str() + lenPrefix);
AddFile(wxURL::ConvertFromURI(filename.c_str() + lenPrefix));
filename.Empty();
}
else
@ -315,7 +297,6 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf)
filename += *p;
}
}
#endif // 0/1
return TRUE;
}