Utils_Mac.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. AZStd::string GetDefaultDiffToolPath_Impl()
  22. {
  23. return AZStd::string("/usr/local/bin/bcompare");
  24. }
  25. bool RunDiffTool_Impl(const AZStd::string& diffToolPath, const AZStd::string& filePathA, const AZStd::string& filePathB)
  26. {
  27. bool result = true;
  28. //Fork a process to run Beyond Compare app
  29. pid_t childPid = fork();
  30. if (childPid == 0)
  31. {
  32. //In child process
  33. char* args[] = { const_cast<char*>(diffToolPath.c_str()), const_cast<char*>(filePathA.c_str()), const_cast<char*>(filePathB.c_str()), static_cast<char*>(0)};
  34. execv(diffToolPath.c_str(), args);
  35. AZ_TracePrintf("RunDiffTool", "RunDiffTool: Unable to launch Diff Tool %s : errno = %s .", diffToolPath.c_str(), strerror(errno));
  36. std::cerr << strerror(errno) << std::endl;
  37. _exit(errno);
  38. }
  39. else if (childPid > 0)
  40. {
  41. //In parent process
  42. int status;
  43. pid_t result = waitpid(childPid, &status, WNOHANG);
  44. if (result == -1)
  45. {
  46. result = false;
  47. }
  48. }
  49. else
  50. {
  51. result = false;
  52. }
  53. return result;
  54. }
  55. } // namespace Utils
  56. } // namespace AtomSampleViewer