- 591 名前:login:Penguin mailto:sage [2009/12/02(水) 03:08:21 ID: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; }
|

|