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参数一起使用。



©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客