From 4bd599d58cfce37c40be5d5dc0213dbe5458ef07 Mon Sep 17 00:00:00 2001 From: ligc Date: Mon, 25 Jan 2010 08:59:52 +0000 Subject: [PATCH] add full_path subroutine in Utils.pm, for relative path support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5027 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 97d7ff713..c4c2c235f 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -5508,4 +5508,41 @@ sub get_DBName return $name; } +#------------------------------------------------------------------------------- + +=head3 full_path + Description: + Convert the relative path to full path. + + Arguments: + relpath: relative path + cwdir: current working directory, use the cwd() if not specified + Returns: + Return the full path + NULL - Failed to get the full path. + Globals: + none + Error: + none + Example: + my $fp = xCAT::Utils::full_path('./test', '/home/guest'); + Comments: + +=cut + +#------------------------------------------------------------------------------- +sub full_path +{ + my ($class, $relpath, $cwdir) = @_; + + my $fullpath; + + if (!$cwdir) { #cwdir is not specified + $fullpath = Cwd::abs_path($relpath); + } else { + $fullpath = $cwdir . "/$relpath"; + } + + return $fullpath; +} 1;