FileUtil_Mac.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #include "EditorDefs.h"
  8. #include "../../FileUtil_Common.h"
  9. #include <QProcess>
  10. // Editor
  11. #include "Settings.h"
  12. namespace Platform
  13. {
  14. bool RunCommandWithArguments(const QString& command, const QStringList& argsList)
  15. {
  16. return QProcess::startDetached(command, argsList);
  17. }
  18. bool RunEditorWithArg(const QString& editor, const QString& arg)
  19. {
  20. return RunCommandWithArguments(QString("/usr/bin/open"), { "-a", gSettings.textureEditor, editor });
  21. }
  22. bool OpenUri(const QUrl& uri)
  23. {
  24. return RunCommandWithArguments(QString("/usr/bin/open"), { uri.toString() });
  25. }
  26. QString GetDefaultEditor(const Common::EditFileType fileType)
  27. {
  28. switch (fileType)
  29. {
  30. case Common::EditFileType::FILE_TYPE_BSPACE://Drop through
  31. case Common::EditFileType::FILE_TYPE_SCRIPT:
  32. case Common::EditFileType::FILE_TYPE_SHADER:
  33. // Try to use a platform default editor rather than the exe assigned to open the appropriate filetype, as that's not necessarily an editor, e.g. Python.
  34. return "TextEdit";
  35. case Common::EditFileType::FILE_TYPE_TEXTURE:
  36. return "photoshop";
  37. case Common::EditFileType::FILE_TYPE_ANIMATION:
  38. return "";
  39. default:
  40. AZ_Assert(false, "Unknown file type.");
  41. return "";
  42. }
  43. }
  44. QString MakePlatformFileEditString(QString pathToEdit, int lineToEdit)
  45. {
  46. return pathToEdit;
  47. }
  48. bool CreatePath(const QString& strPath)
  49. {
  50. bool pathCreated = true;
  51. QString cleanPath = QDir::cleanPath(strPath);
  52. QDir path(cleanPath);
  53. if (!path.exists())
  54. {
  55. pathCreated = path.mkpath(cleanPath);
  56. }
  57. return pathCreated;
  58. }
  59. const char* GetLuaCompilerName()
  60. {
  61. return "lua";
  62. }
  63. }