From f2fb69f021ef6b199730cecc10212f2ac8615ddd Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 25 Aug 2010 15:18:04 +0000 Subject: [PATCH] add support for array of file names in get_filelist git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7227 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index ddc9b6265..ccff57232 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -3478,6 +3478,8 @@ sub getAutoIncrementColumns { Example: my @filelist =get_filelist($directory,$filelist,$type); where type = "sql" or "pm" + Note either input a directory path in $directory of an array of + full path to filenames in $filelist. See runsqlcmd for example. =cut @@ -3493,7 +3495,6 @@ sub get_filelist my $ext = shift; my $dbname = "sqlite"; my $xcatcfg = get_xcatcfg(); - if ($xcatcfg =~ /^DB2:/) { $dbname = "db2"; @@ -3513,28 +3514,32 @@ sub get_filelist } } $directory .= "/"; - + my @list; + # check whether input files or a directory + if (@$files) { + @list=@$files; + } else { + @list = glob($directory . "*.$ext"); # all files + } my @filelist = (); - - my @list = glob($directory . "*.$ext"); # all files foreach my $file (@list) { - my $filename= basename($file); # strip filename - my($name,$ext1) = split '\.', $filename; - my($name,$ext2) = split '\_', $name; - if ($ext2 eq $dbname) - { + my $filename= basename($file); # strip filename + my($name,$ext1) = split '\.', $filename; + my($name,$ext2) = split '\_', $name; + if ($ext2 eq $dbname) + { push @filelist, $file; - } - else - { + } + else + { if ($ext2 eq "") { push @filelist, $file; } - } - $ext2 = ""; - $ext1 = ""; + } + $ext2 = ""; + $ext1 = ""; } return @filelist; }