Skip to content

Commit

Permalink
xLightsSequencer#4115 Handle the directory if found in a faces zip
Browse files Browse the repository at this point in the history
  • Loading branch information
derwin12 authored and dkulp committed Jan 22, 2024
1 parent 5b0f06e commit 6e0cf17
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions xLights/ModelFaceDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,23 +1261,31 @@ void ModelFaceDialog::OnButton_DownloadImagesClick(wxCommandEvent& event)
wxZipEntry *ent = zin.GetNextEntry();
while (ent != nullptr)
{
wxString filename = dir + wxFileName::GetPathSeparator() + ent->GetName();
files.push_back(filename);
if (ent->IsDir()) {
wxString dirname = dir + wxFileName::GetPathSeparator() + ent->GetName();
if (!wxDirExists(dirname)) {
logger_base.debug("Extracting dir %s:%s to %s.", (const char*)faceZip.c_str(), (const char*)ent->GetName().c_str(), (const char*)dirname.c_str());
wxFileName::Mkdir(dirname, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
}
} else {
wxString filename = dir + wxFileName::GetPathSeparator() + ent->GetName();
files.push_back(filename);

if (!FileExists(filename))
{
if (!FileExists(filename))
{
#ifdef __WXMSW__
if (filename.length() > MAX_PATH) {
logger_base.warn("Target filename longer than %d chars (%d). This will likely fail. %s.", MAX_PATH, (int)filename.length(), (const char*) filename.c_str());
}
if (filename.length() > MAX_PATH) {
logger_base.warn("Target filename longer than %d chars (%d). This will likely fail. %s.", MAX_PATH, (int)filename.length(), (const char*) filename.c_str());
}
#endif

logger_base.debug("Extracting %s:%s to %s.", (const char*)faceZip.c_str(), (const char*)ent->GetName().c_str(), (const char*)filename.c_str());
wxFileOutputStream fout(filename);
zin.Read(fout);
}
if (!FileExists(filename)) {
logger_base.error("File extract failed.");
logger_base.debug("Extracting %s:%s to %s.", (const char*)faceZip.c_str(), (const char*)ent->GetName().c_str(), (const char*)filename.c_str());
wxFileOutputStream fout(filename);
zin.Read(fout);
}
if (!FileExists(filename)) {
logger_base.error("File extract failed.");
}
}
ent = zin.GetNextEntry();
}
Expand Down

0 comments on commit 6e0cf17

Please sign in to comment.