Audio plugin host https://kx.studio/carla
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.

86 lines
1.6KB

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #ifdef WIN32
  4. # include <windows.h>
  5. #endif
  6. #include "appDetails.h"
  7. #define CMD_BUF_LEN 1024
  8. static int sfx_app_argc = 0;
  9. static char** sfx_app_argv = NULL;
  10. static char sfx_tmp_path[512] = { 0 };
  11. void sfx_app_set_args(int argc, char** argv)
  12. {
  13. sfx_app_argc = argc;
  14. sfx_app_argv = argv;
  15. }
  16. int sfx_app_autorun_now()
  17. {
  18. int i, cmdBufLen = 0;
  19. char cmdBuf[CMD_BUF_LEN];
  20. #ifdef WIN32
  21. strcpy(cmdBuf, sfx_get_tmp_path(1));
  22. strcat(cmdBuf, SFX_AUTORUN_CMD);
  23. #else
  24. strcpy(cmdBuf, "cd ");
  25. strcat(cmdBuf, sfx_get_tmp_path(1));
  26. strcat(cmdBuf, "; ");
  27. strcat(cmdBuf, SFX_AUTORUN_CMD);
  28. #endif
  29. cmdBufLen = strlen(cmdBuf);
  30. for (i=0; i < sfx_app_argc; i++)
  31. {
  32. if (! sfx_app_argv[i])
  33. continue;
  34. cmdBufLen += strlen(sfx_app_argv[i]) + 1;
  35. if (cmdBufLen >= CMD_BUF_LEN-1)
  36. break;
  37. strcat(cmdBuf, " ");
  38. strcat(cmdBuf, sfx_app_argv[i]);
  39. }
  40. #ifdef WIN32
  41. ShellExecute(NULL, "open", cmdBuf, NULL, NULL, SW_SHOWNORMAL);
  42. return 0;
  43. #else
  44. return system(cmdBuf);
  45. #endif
  46. }
  47. char* sfx_get_tmp_path(int withAppName)
  48. {
  49. #ifdef WIN32
  50. {
  51. GetTempPathA(512 - strlen(SFX_APP_MININAME), sfx_tmp_path);
  52. if (withAppName == 1)
  53. strcat(sfx_tmp_path, SFX_APP_MININAME);
  54. }
  55. #else
  56. {
  57. char* tmp = getenv("TMP");
  58. if (tmp)
  59. strcpy(sfx_tmp_path, tmp);
  60. else
  61. strcpy(sfx_tmp_path, "/tmp");
  62. if (withAppName == 1)
  63. strcat(sfx_tmp_path, "/" SFX_APP_MININAME);
  64. }
  65. #endif
  66. return sfx_tmp_path;
  67. }