bool NativeFileSystem::CopyDir(const gd::String & source, const gd::String & destination) { wxString sFrom = source.ToWxString(); wxString sTo = destination.ToWxString(); //As seen on https://forums.wxwidgets.org/viewtopic.php?t=2080 if (sFrom[sFrom.Len() - 1] != '\\' && sFrom[sFrom.Len() - 1] != '/') sFrom += wxFILE_SEP_PATH; if (sTo[sTo.Len() - 1] != '\\' && sTo[sTo.Len() - 1] != '/') sTo += wxFILE_SEP_PATH; if (!::wxDirExists(sFrom)) { return false; } if (!wxDirExists(sTo)) { if (!wxFileName::Mkdir(sTo, 0777, wxPATH_MKDIR_FULL)) { return false; } } wxDir fDir(sFrom); wxString sNext = wxEmptyString; bool bIsFile = fDir.GetFirst(&sNext); while (bIsFile) { const wxString sFileFrom = sFrom + sNext; const wxString sFileTo = sTo + sNext; if (::wxDirExists(sFileFrom)) { CopyDir(sFileFrom, sFileTo); } else { if (!::wxFileExists(sFileTo)) { if (!::wxCopyFile(sFileFrom, sFileTo)) { return false; } } } bIsFile = fDir.GetNext(&sNext); } return true; }