Utils_Mac.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Utils/Utils.h>
  9. #include <AzCore/PlatformIncl.h>
  10. #include <Atom/RHI.Edit/Utils.h>
  11. #include <iostream>
  12. #include <errno.h>
  13. namespace AtomSampleViewer
  14. {
  15. namespace Utils
  16. {
  17. bool SupportsResizeClientArea()
  18. {
  19. return true;
  20. }
  21. bool RunDiffTool(const AZStd::string& filePathA, const AZStd::string& filePathB)
  22. {
  23. bool result = true;
  24. AZStd::string executablePath = "/usr/local/bin/bcompare";
  25. //Fork a process to run Beyond Compare app
  26. pid_t childPid = fork();
  27. if (childPid == 0)
  28. {
  29. //In child process
  30. char* args[] = { const_cast<char*>(executablePath.c_str()), const_cast<char*>(filePathA.c_str()), const_cast<char*>(filePathB.c_str()), static_cast<char*>(0)};
  31. execv(executablePath.c_str(), args);
  32. AZ_TracePrintf("RunDiffTool", "RunDiffTool: Unable to launch Beyond Compare %s : errno = %s . Make sure you have installed Beyond Compare command line tools.", executablePath.c_str(), strerror(errno));
  33. std::cerr << strerror(errno) << std::endl;
  34. _exit(errno);
  35. }
  36. else if (childPid > 0)
  37. {
  38. //In parent process
  39. int status;
  40. pid_t result = waitpid(childPid, &status, WNOHANG);
  41. if (result == -1)
  42. {
  43. result = false;
  44. }
  45. }
  46. else
  47. {
  48. result = false;
  49. }
  50. return result;
  51. }
  52. } // namespace Utils
  53. } // namespace AtomSampleViewer