GNOME 4歩目at LINUX
GNOME 4歩目 - 暇つぶし2ch591:login:Penguin
09/12/02 03:08:21 VTtWLB6g
/*
gopen2.c
拡張子の関連付け情報を使用して、アプリを起動するコマンド。(GIO版)
使用方法:
% gopen2 <filename>
compile: $ gcc -Wall -Os $(pkg-config gio-2.0 --cflags --libs) gopen2.c -o gopen2
*/
#include <gio/gio.h>
gint
main (gint argc, const gchar **argv)
{
if (argc != 2)
{
g_print ("Usage: gopen2 <filename>\n");
return 1;
}
g_type_init ();
GFile *file = g_file_new_for_commandline_arg (argv[1]);
if (!file)
return 1;
GAppInfo *app_info = g_file_query_default_handler (file, NULL, NULL);
if (!app_info)
return 1;
const gchar *command = g_app_info_get_executable (app_info);
GString *gstr = g_string_new (NULL);
g_string_printf (gstr, "%s %s", command, argv[1]);
gint exit_status = 1;
g_spawn_command_line_sync (gstr->str, NULL, NULL, &exit_status, NULL);
return exit_status;
}



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch