28#include <unordered_set>
32#include <wx/filename.h>
33#include <wx/process.h>
34#include <wx/zipstrm.h>
40#define UNIX_STRING_DIR_SEP wxT( "/" )
41#define WIN_STRING_DIR_SEP wxT( "\\" )
70 bool MakeFile(
const wxString& aPrefix );
90 wxString* aError =
nullptr,
119 std::function<
bool(
const std::string& token, wxString& value )> aCallback,
133 const wxString& aFileName = wxEmptyString,
134 wxProcess* aCallback =
nullptr,
bool aFileForKicad =
true );
197 const std::vector<wxString>& aOverwriteExclusions, wxString& aErrors );
200 wxString& aErrors, std::vector<wxString>& aPathsWritten );
211 const wxString& aParentDir =
"" );
230 const wxString& aFileSpec = wxEmptyString,
231 int aFlags = wxDIR_DEFAULT );
245 int aFlags = wxDIR_DIRS );
267 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
SCOPED_TEMP_PATH(const SCOPED_TEMP_PATH &)=delete
bool MakeFile(const wxString &aPrefix)
Create an empty file with a unique name after aPrefix.
bool MakeDirectory(const wxString &aPrefix)
Create an empty directory with a unique name after aPrefix.
SCOPED_TEMP_PATH & operator=(const SCOPED_TEMP_PATH &)=delete
SCOPED_TEMP_PATH()=default
const wxString & Path() const
KICOMMON_API bool CopyFilesOrDirectory(const wxString &aSourceDir, const wxString &aDestDir, bool aAllowOverwrite, wxString &aErrors, std::vector< wxString > &aPathsWritten)
KICOMMON_API wxString QuoteFullPath(wxFileName &fn, wxPathFormat format=wxPATH_NATIVE)
Quote return value of wxFileName::GetFullPath().
KICOMMON_API 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.
KICOMMON_API bool CopyDirectory(const wxString &aSourceDir, const wxString &aDestDir, const std::vector< wxString > &aOverwriteExclusions, wxString &aErrors)
Copy a directory and its contents to another directory.
KICOMMON_API void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
KICOMMON_API int ExecuteCommandThroughShell(const wxString &aCommand, wxProcess *aProcess=nullptr)
Run a user-supplied command line through the platform shell so glob expansion, pipes,...
KICOMMON_API bool OpenPDF(const wxString &file)
Run the PDF viewer and display a PDF file.
KICOMMON_API void QuoteString(wxString &string)
Add un " to the start and the end of string (if not already done).
KICOMMON_API wxString FindKicadFile(const wxString &shortname)
Search the executable file shortname in KiCad binary path and return full file name if found or short...
KICOMMON_API void CollectSubdirsLoopSafe(const wxString &aRoot, wxArrayString &aDirs, int aFlags=wxDIR_DIRS)
Recursively collect every subdirectory under aRoot using the same loop detection as CollectFilesLoopS...
KICOMMON_API void CollectFilesLoopSafe(const wxString &aRoot, wxArrayString &aFiles, const wxString &aFileSpec=wxEmptyString, int aFlags=wxDIR_DEFAULT)
Recursively collect every file under aRoot, deduplicating subdirectories by their resolved path.
std::function< std::unique_ptr< wxOutputStream >(wxFFile &)> ARCHIVE_STREAM_FACTORY
KICOMMON_API wxString FromFsPath(const std::filesystem::path &aPath)
KICOMMON_API bool RmDirRecursive(const wxString &aDirName, wxString *aErrors=nullptr)
Remove the directory aDirName and all its contents including subdirectories and their files.
KICOMMON_API void CopySexprFile(const wxString &aSrcPath, const wxString &aDestPath, std::function< bool(const std::string &token, wxString &value)> aCallback, wxString &aErrors)
KICOMMON_API int ExecuteFile(const wxString &aEditorName, const wxString &aFileName=wxEmptyString, wxProcess *aCallback=nullptr, bool aFileForKicad=true)
Call the executable file aEditorName with the parameter aFileName.
KICOMMON_API std::filesystem::path ToFsPath(const wxString &aPath)
Give aPath to std::filesystem without a detour through the C locale.
KICOMMON_API bool AddDirectoryToZip(wxZipOutputStream &aZip, const wxString &aSourceDir, wxString &aErrors, const wxString &aParentDir="")
Add a directory and its contents to a zip file.