KiCad PCB EDA Suite
Loading...
Searching...
No Matches
env_paths.cpp File Reference
#include <env_paths.h>
#include <project.h>
#include <wx/filename.h>

Go to the source code of this file.

Functions

static bool normalizeAbsolutePaths (const wxFileName &aPathA, const wxFileName &aPathB, wxString *aResultPath)
 
wxString NormalizePath (const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
 Normalize a file path to an environmental variable, if possible.
 
wxString NormalizePath (const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const PROJECT *aProject)
 Normalize a file path to an environmental variable, if possible.
 
static wxString createFilePath (const wxString &aPath, const wxString &aFileName)
 
wxString ResolveFile (const wxString &aFileName, const ENV_VAR_MAP *aEnvVars, const PROJECT *aProject)
 Search the default paths trying to find one with the requested file.
 
bool PathIsInsideProject (const wxString &aFileName, const PROJECT *aProject, wxFileName *aSubPath)
 

Function Documentation

◆ createFilePath()

static wxString createFilePath ( const wxString &  aPath,
const wxString &  aFileName 
)
static

Definition at line 153 of file env_paths.cpp.

References path.

Referenced by ResolveFile().

◆ normalizeAbsolutePaths()

static bool normalizeAbsolutePaths ( const wxFileName &  aPathA,
const wxFileName &  aPathB,
wxString *  aResultPath 
)
static

Definition at line 27 of file env_paths.cpp.

Referenced by NormalizePath().

◆ NormalizePath() [1/2]

wxString NormalizePath ( const wxFileName &  aFilePath,
const ENV_VAR_MAP aEnvVars,
const PROJECT aProject 
)

Normalize a file path to an environmental variable, if possible.

Parameters
aFilePathis the full file path (path and file name) to be normalized.
aEnvVarsis an optional map of environmental variables to try substitution with.
aProjectis an optional project, to normalize the file path to the project path.
Returns
Normalized full file path (path and file name) if succeeded or the input path if the path could not be normalized.

Definition at line 140 of file env_paths.cpp.

References PROJECT::GetProjectPath(), and NormalizePath().

◆ NormalizePath() [2/2]

wxString NormalizePath ( const wxFileName &  aFilePath,
const ENV_VAR_MAP aEnvVars,
const wxString &  aProjectPath 
)

Normalize a file path to an environmental variable, if possible.

Parameters
aFilePathis the full file path (path and file name) to be normalized.
aEnvVarsis an optional map of environmental variables to try substitution with.
aProjectPathis an optional string to normalize the file path to the project path.
Returns
Normalized full file path (path and file name) if succeeded or the input path if the path could not be normalized.

Definition at line 71 of file env_paths.cpp.

References normalizeAbsolutePaths(), and PROJECT_VAR_NAME.

Referenced by SCH_EDIT_FRAME::AddDesignBlockLibrary(), SYMBOL_LIBRARY_MANAGER::addLibrary(), PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::addLibTableEntry(), PANEL_DESIGN_BLOCK_LIB_TABLE::browseLibrariesHandler(), PANEL_FP_LIB_TABLE::browseLibrariesHandler(), PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), NormalizePath(), TEXT_BUTTON_FILE_BROWSER::OnButtonClick(), PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries(), PANEL_DESIGN_BLOCK_LIB_TABLE::onMigrateLibraries(), PANEL_FP_LIB_TABLE::onMigrateLibraries(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), and SYMBOL_EDIT_FRAME::replaceLibTableEntry().

◆ PathIsInsideProject()

bool PathIsInsideProject ( const wxString &  aFileName,
const PROJECT aProject,
wxFileName *  aSubPath 
)

Definition at line 195 of file env_paths.cpp.

References PROJECT::GetProjectPath().

◆ ResolveFile()

wxString ResolveFile ( const wxString &  aFileName,
const ENV_VAR_MAP aEnvVars,
const PROJECT aProject 
)

Search the default paths trying to find one with the requested file.

Parameters
aFileNameis the name of the searched file. It might be a relative path.
aEnvVarsis an optional map of environmental variables that can contain paths.
aProjectis an optional project, to check the project path.
Returns
Full path (apth and file name) if the file was found in one of the paths, otherwise an empty string.

Definition at line 164 of file env_paths.cpp.

References createFilePath(), and PROJECT::GetProjectPath().

Referenced by NETLIST_EXPORTER_SPICE::writeInclude().