char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
- if (virFileAbsPath(to, &absolute_to) < 0) {
+ if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute output file path"));
goto error;
char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
- if (virFileAbsPath(to, &absolute_to) < 0) {
+ if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute output file path"));
goto error;
char *absolute_from;
/* We must absolutize the file path as the restore is done out of process */
- if (virFileAbsPath(from, &absolute_from) < 0) {
+ if (!(absolute_from = g_canonicalize_filename(from, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
char *absolute_from;
/* We must absolutize the file path as the restore is done out of process */
- if (virFileAbsPath(from, &absolute_from) < 0) {
+ if (!(absolute_from = g_canonicalize_filename(from, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
char *absolute_file;
/* We must absolutize the file path as the read is done out of process */
- if (virFileAbsPath(file, &absolute_file) < 0) {
+ if (!(absolute_file = g_canonicalize_filename(file, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
char *absolute_file;
/* We must absolutize the file path as the read is done out of process */
- if (virFileAbsPath(file, &absolute_file) < 0) {
+ if (!(absolute_file = g_canonicalize_filename(file, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute input file path"));
goto error;
char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
- if (virFileAbsPath(to, &absolute_to) < 0) {
+ if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute core file path"));
goto error;
char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
- if (virFileAbsPath(to, &absolute_to) < 0) {
+ if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not build absolute core file path"));
goto error;
if (!virFileIsExecutable(file))
return NULL;
- ignore_value(virFileAbsPath(file, &abspath));
- return abspath;
+ return g_canonicalize_filename(file, NULL);
}
/* copy PATH env so we can tweak it */
}
#endif /* WIN32 */
-/*
- * Creates an absolute path for a potentially relative path.
- * Return 0 if the path was not relative, or on success.
- * Return -1 on error.
- *
- * You must free the result.
- */
-int
-virFileAbsPath(const char *path, char **abspath)
-{
- if (g_path_is_absolute(path)) {
- *abspath = g_strdup(path);
- } else {
- g_autofree char *buf = g_get_current_dir();
-
- *abspath = g_build_filename(buf, path, NULL);
- }
-
- return 0;
-}
-
/* Remove spurious / characters from a path. The result must be freed */
char *
virFileSanitizePath(const char *path)