mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 06:03:52 +03:00
src: replace getcwd() with g_get_current_dir()
commandhelper.c is not converted since this is a standalone program only run on UNIX, so can rely on getcwd(). Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
8812163124
commit
0b4598b183
@ -3187,10 +3187,7 @@ virFileAbsPath(const char *path, char **abspath)
|
||||
if (path[0] == '/') {
|
||||
*abspath = g_strdup(path);
|
||||
} else {
|
||||
g_autofree char *buf = getcwd(NULL, 0);
|
||||
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
g_autofree char *buf = g_get_current_dir();
|
||||
|
||||
*abspath = g_strdup_printf("%s/%s", buf, path);
|
||||
}
|
||||
|
16
tools/vsh.c
16
tools/vsh.c
@ -3296,21 +3296,11 @@ const vshCmdInfo info_pwd[] = {
|
||||
bool
|
||||
cmdPwd(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
|
||||
{
|
||||
char *cwd;
|
||||
bool ret = true;
|
||||
char ebuf[1024];
|
||||
g_autofree char *cwd = g_get_current_dir();
|
||||
|
||||
cwd = getcwd(NULL, 0);
|
||||
if (!cwd) {
|
||||
vshError(ctl, _("pwd: cannot get current directory: %s"),
|
||||
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||
ret = false;
|
||||
} else {
|
||||
vshPrint(ctl, _("%s\n"), cwd);
|
||||
VIR_FREE(cwd);
|
||||
}
|
||||
vshPrint(ctl, _("%s\n"), cwd);
|
||||
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
const vshCmdInfo info_quit[] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user