g_file_new_for_commandline_arg ()機器翻譯

GFile *
g_file_new_for_commandline_arg (const char *arg);

Creates a GFile with the given argument from the command line. The value of arg can be either a URI, an absolute path or a relative path resolved relative to the current working directory. This operation never fails, but the returned object might not support any I/O operation if arg points to a malformed path.

Note that on Windows, this function expects its argument to be in UTF-8 -- not the system code page. This means that you should not use this function with string from argv as it is passed to main(). g_win32_get_command_line() will return a UTF-8 version of the commandline. GApplication also uses UTF-8 but g_application_command_line_create_file_for_arg() may be more useful for you there. It is also always possible to use this function with GOptionContext arguments of type G_OPTION_ARG_FILENAME.

機器翻譯:

從命令行使用給定的參數創建一個GFile。 arg的值可以是URI,相對於當前工作目錄解析的絕對路徑或相對路徑。 此操作永遠不會失敗,但是如果arg指向格式錯誤的路徑,則返回的對象可能不支持任何I / O操作。

請注意,在Windows上,此函數希望其參數位於UTF-8中,而不是系統代碼頁中。 這意味着您不應將此函數與argv中的字符串一起使用,因爲它會傳遞給main()。 g_win32_get_command_line()將返回命令行的UTF-8版本。 GApplication還使用UTF-8,但在那裏g_application_command_line_create_file_for_arg()可能對您更有用。 也始終可以將此函數與G_OPTION_ARG_FILENAME類型的GOptionContext參數一起使用。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章