KiCad PCB EDA Suite
Loading...
Searching...
No Matches
jobs_output_folder.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 Mark Roszko <[email protected]>
5 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22#include <wx/filename.h>
23#include <gestfich.h>
24
27{
28
29}
30
31
32bool JOBS_OUTPUT_FOLDER::HandleOutputs( const wxString& baseTempPath,
33 const std::vector<JOB_OUTPUT>& aOutputsToHandle )
34{
35 if( wxFileName::DirExists( m_outputPath ) )
36 {
37 wxFileName::Rmdir( m_outputPath, wxPATH_RMDIR_RECURSIVE );
38 }
39
40 bool success = true;
41 if( !wxFileName::Mkdir( m_outputPath, wxS_DIR_DEFAULT ) )
42 {
43 return false;
44 }
45
46 wxString errors;
47 if( !CopyDirectory( baseTempPath, m_outputPath, errors ) )
48 {
49 success = false;
50 }
51
52 return success;
53}
54
55
57{
58 if( m_outputPath.IsEmpty() )
59 {
60 return false;
61 }
62
63 return true;
64}
65
66
67void JOBS_OUTPUT_FOLDER::FromJson( const nlohmann::json& j )
68{
69 m_outputPath = j.value( "output_path", "" );
70}
71
72
73void JOBS_OUTPUT_FOLDER::ToJson( nlohmann::json& j ) const
74{
75 j["output_path"] = m_outputPath;
76}
bool OutputPrecheck() override
Checks if the output process can proceed before doing anything else This can include user prompts.
void FromJson(const nlohmann::json &j) override
void ToJson(nlohmann::json &j) const override
bool HandleOutputs(const wxString &baseTempPath, const std::vector< JOB_OUTPUT > &aOutputsToHandle) override
wxString m_outputPath
Definition: jobs_output.h:54
bool CopyDirectory(const wxString &aSourceDir, const wxString &aDestDir, wxString &aErrors)
Copy a directory and its contents to another directory.
Definition: gestfich.cpp:377