KiCad PCB EDA Suite
filename_resolver.h
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) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
33 #ifndef FILENAME_RESOLVER_H
34 #define FILENAME_RESOLVER_H
35 
36 #include <list>
37 #include <map>
38 #include <vector>
39 #include <wx/string.h>
40 
41 class PGM_BASE;
42 
44 {
45  wxString m_alias; // alias to the base path
46  wxString m_pathvar; // base path as stored in the config file
47  wxString m_pathexp; // expanded base path
48  wxString m_description; // description of the aliased path
49 };
50 
52 {
53 private:
54  wxString m_ConfigDir; // 3D configuration directory
55  std::list< SEARCH_PATH > m_Paths; // list of base paths to search from
58  wxString m_curProjDir;
59 
69  bool createPathList( void );
70 
78  bool addPath( const SEARCH_PATH& aPath );
79 
87  bool readPathList( void );
88 
96  bool writePathList( void );
97 
104  void checkEnvVarPath( const wxString& aPath );
105 
106 public:
108 
117  bool Set3DConfigDir( const wxString& aConfigDir );
118 
129  bool SetProjectDir( const wxString& aProjDir, bool* flgChanged = NULL );
130  wxString GetProjectDir( void );
131 
137  void SetProgramBase( PGM_BASE* aBase );
138 
139 
145  bool UpdatePathList( std::vector< SEARCH_PATH >& aPathList );
146 
155  wxString ResolvePath( const wxString& aFileName );
156 
166  wxString ShortenPath( const wxString& aFullPathName );
167 
177  const std::list< SEARCH_PATH >* GetPaths( void );
178 
185  bool SplitAlias( const wxString& aFileName, wxString& anAlias, wxString& aRelPath );
186 
192  bool ValidateFileName( const wxString& aFileName, bool& hasAlias );
193 
200  bool GetKicadPaths( std::list< wxString >& paths );
201 };
202 
203 #endif // FILENAME_RESOLVER_H
Class PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:149
wxString m_alias
std::list< SEARCH_PATH > m_Paths
wxString m_description
wxString m_pathexp
wxString m_pathvar