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.

110 lines
3.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2009-2014 Jerry Jacobs
  5. * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.TXT for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef GESTFICH_H
  25. #define GESTFICH_H
  26. #include <kicommon.h>
  27. #include <wx/filename.h>
  28. #include <wx/process.h>
  29. /**
  30. * @note Do we really need these defined?
  31. */
  32. #define UNIX_STRING_DIR_SEP wxT( "/" )
  33. #define WIN_STRING_DIR_SEP wxT( "\\" )
  34. /* Forward class declarations. */
  35. class EDA_LIST_DIALOG;
  36. /**
  37. * Run the PDF viewer and display a PDF file.
  38. *
  39. * @param file the PDF file to open.
  40. * @return true is success or false if no PDF viewer found.
  41. */
  42. KICOMMON_API bool OpenPDF( const wxString& file );
  43. KICOMMON_API void OpenFile( const wxString& file );
  44. /**
  45. * @param aSrcPath is the full filename of the source.
  46. * @param aDestPath is the full filename of the target
  47. * @param aErrors a wxString to *append* any errors to
  48. */
  49. KICOMMON_API void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath,
  50. wxString& aErrors );
  51. /**
  52. * Call the executable file \a aEditorName with the parameter \a aFileName.
  53. * @param aEditorName is the full filename for the binary.
  54. * @param aFileName is the full filename of the file to open.
  55. * @param aCallback a wxProcess* for the call.
  56. * @param aFileForKicad a boolean to flag if aFileName runs with a KiCad binary.
  57. * In this case aFileName is a shortname and FindKicadFile() is called to return the path.
  58. * In the other case, aFileName is a full file name (passed prefixed with the path).
  59. */
  60. KICOMMON_API int ExecuteFile( const wxString& aEditorName, const wxString& aFileName = wxEmptyString,
  61. wxProcess* aCallback = nullptr, bool aFileForKicad = true );
  62. /**
  63. * Add un " to the start and the end of string (if not already done).
  64. *
  65. * @param string string to modify.
  66. */
  67. KICOMMON_API void QuoteString( wxString& string );
  68. /**
  69. * Search the executable file shortname in KiCad binary path and return full file
  70. * name if found or shortname if the kicad binary path is kicad/bin.
  71. *
  72. * The binary path is found from:
  73. * - binary path.
  74. * - KICAD environment variable.
  75. * - c:\\kicad or /usr/local/kicad (the default).
  76. * - default binary path.
  77. */
  78. KICOMMON_API wxString FindKicadFile( const wxString& shortname );
  79. /**
  80. * Quote return value of wxFileName::GetFullPath().
  81. *
  82. * This allows file name paths with spaces to be used as parameters to ProcessExecute
  83. * function calls.
  84. *
  85. * @param fn is the filename to wrap.
  86. * @param format if provided, can be used to transform the nature of the wrapped filename
  87. * to another platform.
  88. */
  89. KICOMMON_API extern wxString QuoteFullPath( wxFileName& fn, wxPathFormat format = wxPATH_NATIVE );
  90. /**
  91. * Removes the directory \a aDirName and all its contents including
  92. * subdirectories and their files
  93. */
  94. KICOMMON_API bool RmDirRecursive( const wxString& aDirName, wxString* aErrors = nullptr );
  95. #endif /* GESTFICH_H */