You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.9 KiB

5 years ago
5 years ago
5 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Wayne Stambaugh <stambaughw@verizon.net>
  5. * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. * Copyright (C) 2017 CERN
  7. *
  8. * @author Maciej Suminski <maciej.suminski@cern.ch>
  9. *
  10. * This program is free software: you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation, either version 3 of the License, or (at your
  13. * option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. ///< Helper functions to substitute paths with environmental variables.
  24. #ifndef ENV_PATHS_H
  25. #define ENV_PATHS_H
  26. #include <wx/string.h>
  27. #include <settings/environment.h>
  28. class wxFileName;
  29. class PROJECT;
  30. /**
  31. * Normalize a file path to an environmental variable, if possible.
  32. *
  33. * @param aFilePath is the full file path (path and file name) to be normalized.
  34. * @param aEnvVars is an optional map of environmental variables to try substitution with.
  35. * @param aProject is an optional project, to normalize the file path to the project path.
  36. * @return Normalized full file path (path and file name) if succeeded or the input path if
  37. * the path could not be normalized.
  38. */
  39. wxString NormalizePath( const wxFileName& aFilePath, const ENV_VAR_MAP* aEnvVars,
  40. const PROJECT* aProject );
  41. /**
  42. * Normalize a file path to an environmental variable, if possible.
  43. *
  44. * @param aFilePath is the full file path (path and file name) to be normalized.
  45. * @param aEnvVars is an optional map of environmental variables to try substitution with.
  46. * @param aProjectPath is an optional string to normalize the file path to the project path.
  47. * @return Normalized full file path (path and file name) if succeeded or the input path if
  48. * the path could not be normalized.
  49. */
  50. wxString NormalizePath( const wxFileName& aFilePath, const ENV_VAR_MAP* aEnvVars,
  51. const wxString& aProjectPath );
  52. /**
  53. * Search the default paths trying to find one with the requested file.
  54. *
  55. * @param aFileName is the name of the searched file. It might be a relative path.
  56. * @param aEnvVars is an optional map of environmental variables that can contain paths.
  57. * @param aProject is an optional project, to check the project path.
  58. * @return Full path (apth and file name) if the file was found in one of the paths, otherwise
  59. * an empty string.
  60. */
  61. wxString ResolveFile( const wxString& aFileName, const ENV_VAR_MAP* aEnvVars,
  62. const PROJECT* aProject );
  63. #endif /* ENV_PATHS_H */