27#include <wx/mimetype.h>
29#include <wx/stdpaths.h>
42#include "wx/tokenzr.h"
47#include <wx/wfstream.h>
49#include <wx/zipstrm.h>
50#include <wx/tarstrm.h>
51#include <wx/zstream.h>
56#include <system_error>
57#include <unordered_set>
64 if( !
string.StartsWith( wxT(
"\"" ) ) )
66 string.Prepend ( wxT(
"\"" ) );
67 string.Append ( wxT(
"\"" ) );
81 if( wxFileExists( fullFileName ) )
86 wxFileName buildDir(
Pgm().GetExecutablePath(), shortname );
89 if( !buildDir.GetDirs().IsEmpty()
90 && buildDir.GetDirs().Last().Lower().EndsWith( wxT(
".app" ) ) )
92 buildDir.RemoveLastDir();
95 buildDir.RemoveLastDir();
97 buildDir.AppendDir( shortname );
99 buildDir.AppendDir( shortname.BeforeLast(
'.' ) );
102 if( buildDir.GetDirs().Last() ==
"pl_editor" )
104 buildDir.RemoveLastDir();
105 buildDir.AppendDir(
"pagelayout_editor" );
109 buildDir.AppendDir( shortname + wxT(
".app" ) );
110 buildDir.AppendDir( wxT(
"Contents" ) );
111 buildDir.AppendDir( wxT(
"MacOS" ) );
114 if( wxFileExists( buildDir.GetFullPath() ) )
115 return buildDir.GetFullPath();
120 if(
Pgm().IsKicadEnvVariableDefined() )
124 if( wxFileExists( fullFileName ) )
128#if defined( __WINDOWS__ )
135 const static wxChar* possibilities[] = {
136#if defined( __WXMAC__ )
138 wxT(
"Contents/Applications/pcbnew.app/Contents/MacOS/" ),
139 wxT(
"Contents/Applications/eeschema.app/Contents/MacOS/" ),
140 wxT(
"Contents/Applications/gerbview.app/Contents/MacOS/" ),
141 wxT(
"Contents/Applications/pcb_calculator.app/Contents/MacOS/" ),
142 wxT(
"Contents/Applications/pl_editor.app/Contents/MacOS/" ),
145 wxT(
"/usr/local/bin/" ),
146 wxT(
"/usr/local/kicad/bin/" ),
151 for(
unsigned i=0; i<
arrayDim(possibilities); ++i )
154 fullFileName = possibilities[i] + shortname;
160 if( wxFileExists( fullFileName ) )
170int ExecuteFile(
const wxString& aEditorName,
const wxString& aFileName, wxProcess* aCallback,
173 wxString fullEditorName;
174 std::vector<wxString> params;
178 bool inSingleQuotes =
false;
179 bool inDoubleQuotes =
false;
184 if( !param.IsEmpty() )
186 params.push_back( param );
191 for( wxUniChar ch : aEditorName )
198 inSingleQuotes =
false;
206 else if( inDoubleQuotes )
211 inDoubleQuotes =
false;
218 else if( ch ==
'\'' )
221 inSingleQuotes =
true;
226 inDoubleQuotes =
true;
243 fullEditorName = params[0];
245 params.erase( params.begin() );
251 fullEditorName = aEditorName;
254 if( wxFileExists( fullEditorName ) )
256 std::vector<const wchar_t*> args;
258 args.emplace_back( fullEditorName.wc_str() );
260 if( !params.empty() )
262 for(
const wxString& p : params )
263 args.emplace_back( p.wc_str() );
266 if( !aFileName.IsEmpty() )
267 args.emplace_back( aFileName.wc_str() );
269 args.emplace_back(
nullptr );
271 return wxExecute(
const_cast<wchar_t**
>( args.data() ), wxEXEC_ASYNC, aCallback );
275 msg.Printf(
_(
"Command '%s' could not be found." ), fullEditorName );
292 for(
auto& [
name, value] : aEnv )
294 if(
name.CmpNoCase( wxS(
"PATH" ) ) == 0 )
299 return aEnv[wxS(
"PATH" )];
303#if !defined( __WXMSW__ ) && !defined( __WXMAC__ )
308 std::filesystem::path resolved =
309 std::filesystem::weakly_canonical( std::filesystem::path( aPath.utf8_str().data() ), ec );
314 return wxString::FromUTF8( resolved.string().c_str() );
323 while( tokenizer.HasMoreTokens() )
337 wxGetEnvMap( &env.env );
343 for(
auto it = dirs.rbegin(); it != dirs.rend(); ++it )
345#if defined( __WXMSW__ ) || defined( __WXMAC__ )
362 wxString shellCmd = wxS(
"cmd.exe /d /s /c \"" ) + aCommand + wxS(
"\"" );
364 return static_cast<int>( wxExecute( shellCmd, wxEXEC_SYNC, aProcess, &env ) );
369 wxWCharBuffer shell = wxString( wxS(
"/bin/sh" ) ).wc_str();
370 wxWCharBuffer
flag = wxString( wxS(
"-c" ) ).wc_str();
371 wxWCharBuffer command = aCommand.wc_str();
373 const wchar_t* argv[] = { shell.data(),
flag.data(), command.data(),
nullptr };
375 return static_cast<int>( wxExecute( argv, wxEXEC_SYNC, aProcess, &env ) );
383 wxString filename = file;
387 if(
Pgm().UseSystemPdfBrowser() )
391 msg.Printf(
_(
"Unable to find a PDF viewer for '%s'." ), filename );
398 const wchar_t* args[3];
401 args[1] = filename.wc_str();
404 if( wxExecute(
const_cast<wchar_t**
>( args ) ) == -1 )
406 msg.Printf(
_(
"Problem while running the PDF viewer '%s'." ), args[0] );
416void KiCopyFile(
const wxString& aSrcPath,
const wxString& aDestPath, wxString& aErrors )
418 if( !wxCopyFile( aSrcPath, aDestPath ) )
422 if( !aErrors.IsEmpty() )
425 msg.Printf(
_(
"Cannot copy file '%s'." ), aDestPath );
444 std::function<
bool(
const std::string& token, wxString& value )> aCallback,
447 bool success =
false;
457 if( node->IsList() && node->GetNumberOfChildren() > 1 && node->GetChild( 0 )->IsSymbol() )
459 std::string token = node->GetChild( 0 )->GetSymbol();
460 SEXPR::SEXPR_STRING* pathNode = dynamic_cast<SEXPR::SEXPR_STRING*>( node->GetChild( 1 ) );
461 SEXPR::SEXPR_SYMBOL* symNode = dynamic_cast<SEXPR::SEXPR_SYMBOL*>( node->GetChild( 1 ) );
465 path = pathNode->m_value;
467 path = symNode->m_value;
469 if( aCallback( token, path ) )
472 pathNode->m_value = path;
474 symNode->m_value = path;
484 formatter.
Print(
"%s", sexpr->AsString( 0 ).c_str() );
486 success = formatter.
Finish();
497 if( !aErrors.empty() )
498 aErrors += wxS(
"\n" );
500 msg.Printf(
_(
"Cannot copy file '%s'." ), aDestPath );
508 return wxT(
"\"" ) + fn.GetFullPath( format ) + wxT(
"\"" );
514 namespace fs = std::filesystem;
516 std::string rmDir = aFileName.ToStdString();
518 if( rmDir.length() < 3 )
521 *aErrors =
_(
"Invalid directory name, cannot remove root" );
526 if( !fs::exists( rmDir ) )
529 *aErrors = wxString::Format(
_(
"Directory '%s' does not exist" ), aFileName );
534 fs::path
path( rmDir );
536 if( !fs::is_directory(
path ) )
539 *aErrors = wxString::Format(
_(
"'%s' is not a directory" ), aFileName );
546 fs::remove_all(
path );
548 catch(
const fs::filesystem_error& e )
551 *aErrors = wxString::Format(
_(
"Error removing directory '%s': %s" ), aFileName, e.what() );
561 const std::vector<wxString>& aPathsWithOverwriteDisallowed, wxString& aErrors )
563 wxDir dir( aSourceDir );
565 if( !dir.IsOpened() )
567 aErrors += wxString::Format(
_(
"Could not open source directory: %s" ), aSourceDir );
568 aErrors += wxT(
"\n" );
572 if( !wxFileName::Mkdir( aDestDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
574 aErrors += wxString::Format(
_(
"Could not create destination directory: %s" ), aDestDir );
575 aErrors += wxT(
"\n" );
580 bool cont = dir.GetFirst( &filename );
584 wxString sourcePath = dir.GetNameWithSep() + filename;
585 wxString destPath = aDestDir + wxFileName::GetPathSeparator() + filename;
587 if( wxFileName::DirExists( sourcePath ) )
590 if( !
CopyDirectory( sourcePath, destPath, aPathsWithOverwriteDisallowed, aErrors ) )
596 if(
alg::contains( aPathsWithOverwriteDisallowed, sourcePath ) && wxFileExists( destPath ) )
600 else if( !wxCopyFile( sourcePath, destPath ) )
602 aErrors += wxString::Format(
_(
"Could not copy file: %s to %s" ), sourcePath, destPath );
607 cont = dir.GetNext( &filename );
615 wxString& aErrors, std::vector<wxString>& aPathsWritten )
618 wxFileName sourceFn( aSourcePath );
619 wxString sourcePath = sourceFn.GetFullPath();
620 bool isSourceDirectory = wxFileName::DirExists( sourcePath );
621 wxString baseDestDir = aDestDir;
624 [&](
const wxString& src,
const wxString& dest ) ->
bool
626 if( wxCopyFile( src, dest, aAllowOverwrites ) )
628 aPathsWritten.push_back( dest );
632 aErrors += wxString::Format(
_(
"Could not copy file: %s to %s" ), src, dest );
633 aErrors += wxT(
"\n" );
637 auto processEntries =
638 [&](
const wxString& srcDir,
const wxString& pattern,
const wxString& destDir ) ->
bool
642 if( !dir.IsOpened() )
644 aErrors += wxString::Format(
_(
"Could not open source directory: %s" ), srcDir );
645 aErrors += wxT(
"\n" );
653 bool cont = dir.GetFirst( &filename, pattern, wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN );
657 const wxString entrySrc = srcDir + wxFileName::GetPathSeparator() + filename;
658 const wxString entryDest = destDir + wxFileName::GetPathSeparator() + filename;
660 if( !filename.Matches( wxT(
"~*.lck" ) ) && !filename.Matches( wxT(
"*.lck" ) ) )
662 if( wxFileName::DirExists( entrySrc ) )
667 aErrors += wxString::Format(
_(
"Could not copy directory: %s to %s" ),
668 entrySrc, entryDest );
669 aErrors += wxT(
"\n" );
677 if( !performCopy( entrySrc, entryDest ) )
684 cont = dir.GetNext( &filename );
691 if( isSourceDirectory )
693 wxString sourceDirName = sourceFn.GetFullName();
694 baseDestDir = wxFileName( aDestDir, sourceDirName ).GetFullPath();
698 if( !wxFileName::Mkdir( baseDestDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
700 aErrors += wxString::Format(
_(
"Could not create destination directory: %s" ), baseDestDir );
701 aErrors += wxT(
"\n" );
707 if( !isSourceDirectory )
709 const wxString fileName = sourceFn.GetFullName();
712 if( fileName.Contains(
'*' ) || fileName.Contains(
'?' ) )
714 const wxString dirPath = sourceFn.GetPath();
716 if( !wxFileName::DirExists( dirPath ) )
718 aErrors += wxString::Format(
_(
"Source directory does not exist: %s" ), dirPath );
719 aErrors += wxT(
"\n" );
725 return processEntries( dirPath, fileName, baseDestDir );
729 return performCopy( sourcePath, wxFileName( baseDestDir, fileName ).GetFullPath() );
733 return processEntries( sourcePath, wxEmptyString, baseDestDir );
738 const wxString& aParentDir )
740 wxDir dir( aSourceDir );
742 if( !dir.IsOpened() )
744 aErrors += wxString::Format(
_(
"Could not open source directory: %s" ), aSourceDir );
750 bool cont = dir.GetFirst( &filename );
754 wxString sourcePath = aSourceDir + wxFileName::GetPathSeparator() + filename;
755 wxString zipPath = aParentDir + filename;
757 if( wxFileName::DirExists( sourcePath ) )
760 aZip.PutNextDirEntry( zipPath +
"/" );
769 aZip.PutNextEntry( zipPath );
770 wxFFileInputStream fileStream( sourcePath );
772 if( !fileStream.IsOk() )
774 aErrors += wxString::Format(
_(
"Could not read file: %s" ), sourcePath );
778 aZip.Write( fileStream );
781 cont = dir.GetNext( &filename );
799bool collectArchiveSources(
const wxString& aSourceDir,
const wxString& aParent,
802 wxDir dir( aSourceDir );
804 if( !dir.IsOpened() )
808 bool cont = dir.GetFirst( &
name, wxEmptyString, wxDIR_DEFAULT );
812 wxString
path = wxFileName( aSourceDir,
name ).GetFullPath();
813 wxString relative = aParent.IsEmpty() ?
name : aParent + wxS(
"/" ) +
name;
814 bool isDirectory = wxDirExists(
path );
815 wxString key = relative + ( isDirectory ? wxS(
"/" ) : wxS(
"" ) );
816 aSources.push_back( {
path, relative, key, isDirectory } );
824 cont = dir.GetNext( &
name );
831bool writeArchiveContents( wxArchiveOutputStream& aArchive,
const std::vector<ARCHIVE_SOURCE>& aSources )
833 for(
const ARCHIVE_SOURCE&
source : aSources )
835 if(
source.m_isDirectory )
837 if( !aArchive.PutNextDirEntry(
source.m_name ) )
843 wxFFileInputStream input(
source.m_path );
844 wxFileOffset expectedLength = input.IsOk() ? input.GetLength() : wxInvalidOffset;
846 if( !input.IsOk() || !aArchive.PutNextEntry(
source.m_name, wxDateTime::Now(), expectedLength ) )
849 input.Read( aArchive );
851 if( input.TellI() != expectedLength || !aArchive.IsOk() || aArchive.GetLastError() != wxSTREAM_NO_ERROR
852 || !aArchive.CloseEntry() )
864 if( !aOut.IsOk() || !wxDirExists( aSourceDir ) )
868 std::vector<ARCHIVE_SOURCE> sources;
870 if( !guard.
IsRooted() || !collectArchiveSources( aSourceDir, aTopDir, guard, sources ) )
873 std::sort( sources.begin(), sources.end(), [](
const ARCHIVE_SOURCE& a,
const ARCHIVE_SOURCE& b )
875 return a.m_key < b.m_key;
880 wxZlibOutputStream gzip( aOut, -1, wxZLIB_GZIP );
881 wxTarOutputStream archive( gzip, wxTAR_PAX, wxConvUTF8 );
882 bool ok = ( aTopDir.IsEmpty() || archive.PutNextDirEntry( aTopDir ) )
883 && writeArchiveContents( archive, sources );
884 bool archiveOk = archive.IsOk() && archive.GetLastError() == wxSTREAM_NO_ERROR;
885 bool archiveClosed = archive.Close();
886 bool gzipClosed = gzip.Close();
887 return ok && archiveOk && archiveClosed && gzipClosed && aOut.IsOk();
890 wxZipOutputStream archive( aOut );
891 bool ok = ( aTopDir.IsEmpty() || archive.PutNextDirEntry( aTopDir ) )
892 && writeArchiveContents( archive, sources );
893 bool archiveOk = archive.IsOk() && archive.GetLastError() == wxSTREAM_NO_ERROR;
894 bool archiveClosed = archive.Close();
895 return ok && archiveOk && archiveClosed && aOut.IsOk();
900 ARCHIVE_FORMAT aFormat,
const wxString& aTopDir, wxString* aError,
910 *aError = error.IsEmpty() ?
_(
"Cannot create temporary archive file" ) : error;
926 std::unique_ptr<wxOutputStream> output = aOpen ? aOpen( file )
927 : std::make_unique<wxFFileOutputStream>( file );
932 catch(
const std::exception& exception )
935 error = wxString::FromUTF8( exception.what() );
939 bool streamError = file.Error();
940 FILE* raw = file.Detach();
942 bool closed = fclose( raw ) == 0;
943 ok = writeOk && !streamError && flushed && closed;
945 if( !writeOk || streamError )
947 if( error.IsEmpty() )
948 error =
_(
"Write error" );
950 else if( !flushed || !closed )
952 error =
_(
"Cannot flush or close temporary file" );
960 if( !ok && error.IsEmpty() )
961 error =
_(
"Cannot replace archive" );
964 if( !ok && wxFileExists( tempPath ) )
966 if( !wxRemoveFile( tempPath ) )
967 error +=
_(
"\nCannot remove temporary archive file" );
977std::filesystem::path
ToFsPath(
const wxString& aPath )
980 return std::filesystem::path( std::wstring( aPath.wc_str() ) );
982 return std::filesystem::path( aPath.utf8_string() );
990 return wxString( aPath.wstring() );
992 std::u8string
utf8 = aPath.u8string();
993 return wxString::FromUTF8(
reinterpret_cast<const char*
>(
utf8.data() ),
utf8.size() );
1000 if( wxDirExists(
m_path ) )
1001 wxFileName::Rmdir(
m_path, wxPATH_RMDIR_RECURSIVE );
1002 else if( wxFileExists(
m_path ) )
1009 m_path = wxFileName::CreateTempFileName( aPrefix );
1010 return !
m_path.IsEmpty();
1018 if( !tempFile.
MakeFile( aPrefix ) || !wxRemoveFile( tempFile.
Path() ) )
1027 if( !wxFileName::Mkdir(
path, aPermissions, 0 ) )
1042std::filesystem::path canonicalPath(
const std::filesystem::path& aPath )
1045 std::filesystem::path canon = std::filesystem::weakly_canonical( aPath, ec );
1047 return ec ? std::filesystem::path() : canon;
1054bool isAncestorOrSame(
const std::filesystem::path& aAncestor,
1055 const std::filesystem::path& aDescendant )
1057 auto a = aAncestor.begin();
1058 auto d = aDescendant.begin();
1060 for( ; a != aAncestor.end() && d != aDescendant.end(); ++a, ++d )
1066 return a == aAncestor.end();
1071class LOOP_SAFE_COLLECTOR :
public wxDirTraverser
1074 LOOP_SAFE_COLLECTOR( wxArrayString& aOutput,
const wxString& aRoot,
bool aCollectFiles,
1075 bool aCollectDirs ) :
1076 m_output( aOutput ),
1078 m_collectFiles( aCollectFiles ),
1079 m_collectDirs( aCollectDirs )
1083 wxDirTraverseResult OnFile(
const wxString& aFilename )
override
1085 if( m_collectFiles )
1086 m_output.Add( aFilename );
1088 return wxDIR_CONTINUE;
1091 wxDirTraverseResult OnDir(
const wxString& aDirname )
override
1093 if( !m_guard.ShouldDescend( aDirname ) )
1094 return wxDIR_IGNORE;
1097 m_output.Add( aDirname );
1099 return wxDIR_CONTINUE;
1103 wxArrayString& m_output;
1104 DIR_LOOP_GUARD m_guard;
1105 bool m_collectFiles;
1110void traverseLoopSafe(
const wxString& aRoot, wxArrayString& aOutput,
bool aCollectFiles,
1111 bool aCollectDirs,
const wxString& aFileSpec,
int aFlags )
1115 if( !dir.IsOpened() )
1118 LOOP_SAFE_COLLECTOR collector( aOutput, aRoot, aCollectFiles, aCollectDirs );
1119 dir.Traverse( collector, aFileSpec, aFlags );
1138 const std::filesystem::path raw =
ToFsPath( aDir );
1139 std::filesystem::path key;
1145 const std::filesystem::path canon = canonicalPath( raw );
1150 if( !
m_root.empty() && !isAncestorOrSame(
m_root, canon ) )
1160 const bool isLink = std::filesystem::is_symlink( raw, ec );
1164 const std::filesystem::path canon = canonicalPath( raw );
1169 if( !
m_root.empty() && isAncestorOrSame( canon,
m_root ) )
1176 key = raw.lexically_normal();
1180 return m_visited.insert( key.generic_string() ).second;
1190 traverseLoopSafe( aRoot, aFiles,
true,
false, aFileSpec, aFlags | wxDIR_FILES | wxDIR_DIRS );
1196 traverseLoopSafe( aRoot, aDirs,
false,
true, wxEmptyString, aFlags | wxDIR_DIRS );
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
bool ShouldDescend(const wxString &aDir)
std::unordered_set< std::string > m_visited
DIR_LOOP_GUARD(const wxString &aRoot, DIR_LOOP_POLICY aPolicy=DIR_LOOP_POLICY::CONFINE_TO_ROOT)
std::filesystem::path m_root
static bool RunningFromBuildDir()
True when KiCad runs from its build tree or KICAD_RUN_FROM_BUILD_DIR is set.
static std::vector< wxString > GetToolDirectories(const wxString &aExecutableDir)
Return the directories holding tools shipped alongside KiCad, most specific first.
static wxString GetExecutableDir()
Return the directory holding the running executable itself.
virtual const wxString & GetKicadEnvVariable() const
virtual void ReadPdfBrowserInfos()
Read the PDF browser choice from the common configuration.
virtual const wxString & GetPdfBrowserName() const
virtual const wxString & GetExecutablePath() const
bool MakeDirectory(const wxString &aPrefix, int aPermissions=wxS_DIR_DEFAULT)
Create an empty directory with a unique name after aPrefix.
bool MakeFile(const wxString &aPrefix)
Create an empty file with a unique name after aPrefix.
SCOPED_TEMP_PATH()=default
const wxString & Path() const
std::unique_ptr< SEXPR > ParseFromFile(const std::string &aFilename)
size_t GetNumberOfChildren() const
SEXPR * GetChild(size_t aIndex) const
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
std::string utf8(const wxString &aText)
wxString FromFsPath(const std::filesystem::path &aPath)
static wxString & envPathEntry(wxEnvVariableHashMap &aEnv)
static bool pathListContains(const wxString &aPathList, const wxString &aDir)
bool WriteDirectoryArchive(const wxString &aSourceDir, wxOutputStream &aOut, ARCHIVE_FORMAT aFormat, const wxString &aTopDir)
Write directory entries in sorted archive path order, using the archive root when aTopDir is empty.
wxString FindKicadFile(const wxString &shortname)
Search the executable file shortname in KiCad binary path and return full file name if found or short...
wxString QuoteFullPath(wxFileName &fn, wxPathFormat format)
Quote return value of wxFileName::GetFullPath().
int ExecuteCommandThroughShell(const wxString &aCommand, wxProcess *aProcess)
Run a user-supplied command line through the platform shell so glob expansion, pipes,...
void CopySexprFile(const wxString &aSrcPath, const wxString &aDestPath, std::function< bool(const std::string &token, wxString &value)> aCallback, wxString &aErrors)
static const wxChar PATH_LIST_SEPARATOR
bool OpenPDF(const wxString &file)
Run the PDF viewer and display a PDF file.
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
bool RmDirRecursive(const wxString &aFileName, wxString *aErrors)
Remove the directory aDirName and all its contents including subdirectories and their files.
void QuoteString(wxString &string)
Add un " to the start and the end of string (if not already done).
bool CopyFilesOrDirectory(const wxString &aSourcePath, const wxString &aDestDir, bool aAllowOverwrites, wxString &aErrors, std::vector< wxString > &aPathsWritten)
void CollectSubdirsLoopSafe(const wxString &aRoot, wxArrayString &aDirs, int aFlags)
Recursively collect every subdirectory under aRoot using the same loop detection as CollectFilesLoopS...
void CollectFilesLoopSafe(const wxString &aRoot, wxArrayString &aFiles, const wxString &aFileSpec, int aFlags)
Recursively collect every file under aRoot, deduplicating subdirectories by their resolved path.
std::filesystem::path ToFsPath(const wxString &aPath)
Give aPath to std::filesystem without a detour through the C locale.
static void traverseSEXPR(SEXPR::SEXPR *aNode, const std::function< void(SEXPR::SEXPR *)> &aVisitor)
bool CopyDirectory(const wxString &aSourceDir, const wxString &aDestDir, const std::vector< wxString > &aPathsWithOverwriteDisallowed, wxString &aErrors)
Copy a directory and its contents to another directory.
bool AddDirectoryToZip(wxZipOutputStream &aZip, const wxString &aSourceDir, wxString &aErrors, const wxString &aParentDir)
Add a directory and its contents to a zip file.
static wxString normalizedDir(const wxString &aPath)
std::function< std::unique_ptr< wxOutputStream >(wxFFile &)> ARCHIVE_STREAM_FACTORY
KICOMMON_API std::filesystem::path ToFsPath(const wxString &aPath)
Give aPath to std::filesystem without a detour through the C locale.
bool LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
PGM_BASE & Pgm()
The global program "get" accessor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.