ソースを参照

Merge pull request #685 from jubalh/master

Improve OpenURL()
pull/687/head
Ray 6年前
committed by GitHub
コミット
657897b493
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 4AEE18F83AFDEB23
1個のファイルの変更5行の追加7行の削除
  1. +5
    -7
      src/core.c

+ 5
- 7
src/core.c ファイルの表示

@ -1822,22 +1822,20 @@ int StorageLoadValue(int position)
// Open URL with default system browser (if available) // Open URL with default system browser (if available)
void OpenURL(const char *url) void OpenURL(const char *url)
{ {
// Max length is "explorer ".length + url.maxlength (which is 2083),
// but we are not wasting that much memory here... let's set it up to 512
static char cmd[512] = { 0 };
char *cmd = calloc(10 + strlen(url), sizeof(char));
#if defined(_WIN32) #if defined(_WIN32)
strcpy(cmd, "explorer "); strcpy(cmd, "explorer ");
strcat(cmd, url);
#elif defined(__linux__) #elif defined(__linux__)
strcpy(cmd, "xdg-open "); // Alternatives: firefox, x-www-browser
sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
#elif defined(__APPLE__) #elif defined(__APPLE__)
strcpy(cmd, "open "); strcpy(cmd, "open ");
strcat(cmd, url);
#endif #endif
strcat(cmd, url);
system(cmd); system(cmd);
memset(cmd, 0, 512);
free(cmd);
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

読み込み中…
キャンセル
保存