mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-30 04:44:16 +02:00
gio: New API for GFile from remote commandline arg
Add a pair of new APIs: one to GFile to create a new file from a commandline arg relative to a given cwd and one to GApplicationCommandLine to create a GFile from an arg, relative to the cwd of the invoking commandline. https://bugzilla.gnome.org/show_bug.cgi?id=689037
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "gapplicationcommandline.h"
|
||||
|
||||
#include "glibintl.h"
|
||||
#include "gfile.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -619,3 +620,34 @@ g_application_command_line_get_platform_data (GApplicationCommandLine *cmdline)
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_application_command_line_create_file_for_arg:
|
||||
* @cmdline: a #GApplicationCommandLine
|
||||
* @arg: an argument from @cmdline
|
||||
*
|
||||
* Creates a #GFile corresponding to a filename that was given as part
|
||||
* of the invocation of @cmdline.
|
||||
*
|
||||
* This differs from g_file_new_for_commandline_arg() in that it
|
||||
* resolves relative pathnames using the current working directory of
|
||||
* the invoking process rather than the local process.
|
||||
*
|
||||
* Returns: (transfer full): a new #GFile
|
||||
*
|
||||
* Since: 2.36
|
||||
**/
|
||||
GFile *
|
||||
g_application_command_line_create_file_for_arg (GApplicationCommandLine *cmdline,
|
||||
const gchar *arg)
|
||||
{
|
||||
g_return_val_if_fail (arg != NULL, NULL);
|
||||
|
||||
if (cmdline->priv->cwd)
|
||||
return g_file_new_for_commandline_arg_and_cwd (arg, cmdline->priv->cwd);
|
||||
|
||||
g_warning ("Requested creation of GFile for commandline invocation that did not send cwd. "
|
||||
"Using cwd of local process to resolve relative path names.");
|
||||
|
||||
return g_file_new_for_commandline_arg (arg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user