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.

66 lines
2.8 KiB

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