From 44441d8c67f155284af4e5f39f29368dd374fdbd Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 2 Apr 2017 13:35:14 +0200 Subject: Move path resolving to main package Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/App') diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index e8a3edb..d072a31 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -104,6 +104,22 @@ sub new_no_defaults { return $self; } +sub resolve_relative_path { + my $self = shift; + my $path = shift; + + my $canon_path = File::Spec->canonpath($path); + my $abs_path = abs_path($canon_path); + + if (!defined($abs_path)) { + $log->fatalf("Failed to resolve path to absolute path: %s: %s", $canon_path, $!); + $log->fatal("Make sure that all parts of the path, except the last one, exist."); + return; + } + + return $abs_path; +} + sub find_archives { my $self = shift; my $path = shift; -- cgit v1.2.3-24-g4f1b