return false if the file passed to Load() doesn't exist or is an archive without XRC files inside

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-10-03 15:51:25 +00:00
parent 14c140606b
commit e5bb501b98

View File

@@ -164,10 +164,6 @@ bool wxXmlResource::IsArchive(const wxString& filename)
bool wxXmlResource::Load(const wxString& filemask) bool wxXmlResource::Load(const wxString& filemask)
{ {
wxString fnd;
bool iswild = wxIsWild(filemask);
bool rt = true;
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
wxFileSystem fsys; wxFileSystem fsys;
# define wxXmlFindFirst fsys.FindFirst(filemask, wxFILE) # define wxXmlFindFirst fsys.FindFirst(filemask, wxFILE)
@@ -176,10 +172,13 @@ bool wxXmlResource::Load(const wxString& filemask)
# define wxXmlFindFirst wxFindFirstFile(filemask, wxFILE) # define wxXmlFindFirst wxFindFirstFile(filemask, wxFILE)
# define wxXmlFindNext wxFindNextFile() # define wxXmlFindNext wxFindNextFile()
#endif #endif
if (iswild) wxString fnd = wxXmlFindFirst;
fnd = wxXmlFindFirst; if ( fnd.empty() )
else {
fnd = filemask; wxLogError(_("Cannot load resources from '%s'."), filemask);
return false;
}
while (!fnd.empty()) while (!fnd.empty())
{ {
fnd = ConvertFileNameToURL(fnd); fnd = ConvertFileNameToURL(fnd);
@@ -187,7 +186,8 @@ bool wxXmlResource::Load(const wxString& filemask)
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
if ( IsArchive(fnd) ) if ( IsArchive(fnd) )
{ {
rt = rt && Load(fnd + wxT("#zip:*.xrc")); if ( !Load(fnd + wxT("#zip:*.xrc")) )
return false;
} }
else // a single resource URL else // a single resource URL
#endif // wxUSE_FILESYSTEM #endif // wxUSE_FILESYSTEM
@@ -197,14 +197,12 @@ bool wxXmlResource::Load(const wxString& filemask)
Data().push_back(drec); Data().push_back(drec);
} }
if (iswild) fnd = wxXmlFindNext;
fnd = wxXmlFindNext;
else
fnd = wxEmptyString;
} }
# undef wxXmlFindFirst # undef wxXmlFindFirst
# undef wxXmlFindNext # undef wxXmlFindNext
return rt && UpdateResources();
return UpdateResources();
} }
bool wxXmlResource::Unload(const wxString& filename) bool wxXmlResource::Unload(const wxString& filename)