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 The 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#include <common.h>
25
28{
29
30}
31
32
33bool JOBS_OUTPUT_FOLDER::HandleOutputs( const wxString& baseTempPath, PROJECT* aProject,
34 const std::vector<JOB_OUTPUT>& aOutputsToHandle )
35{
36 wxString outputPath = ExpandTextVars( m_outputPath, aProject );
37 outputPath = ExpandEnvVarSubstitutions( outputPath, aProject );
38
39 if( !wxFileName::DirExists( outputPath ) )
40 {
41 if( !wxFileName::Mkdir( outputPath, wxS_DIR_DEFAULT ) )
42 {
43 return false;
44 }
45 }
46
47 bool success = true;
48
49 wxString errors;
50
51 if( !CopyDirectory( baseTempPath, outputPath, errors ) )
52 {
53 success = false;
54 }
55
56 return success;
57}
58
59
61{
62 if( m_outputPath.IsEmpty() )
63 {
64 return false;
65 }
66
67 return true;
68}
69
70
71void JOBS_OUTPUT_FOLDER::FromJson( const nlohmann::json& j )
72{
73 m_outputPath = j.value( "output_path", "" );
74}
75
76
77void JOBS_OUTPUT_FOLDER::ToJson( nlohmann::json& j ) const
78{
79 j["output_path"] = m_outputPath;
80}
81
82
84{
85 return _( "Folder" );
86}
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
bool HandleOutputs(const wxString &aBaseTempPath, PROJECT *aProject, const std::vector< JOB_OUTPUT > &aOutputsToHandle) override
wxString GetDefaultDescription() const override
void ToJson(nlohmann::json &j) const override
wxString m_outputPath
Definition: jobs_output.h:59
Container for project specific data.
Definition: project.h:64
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:351
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
Definition: common.cpp:59
The common library.
#define _(s)
bool CopyDirectory(const wxString &aSourceDir, const wxString &aDestDir, wxString &aErrors)
Copy a directory and its contents to another directory.
Definition: gestfich.cpp:360