added include_file subroutine to statelite.pm copied from packimage.pm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.6@10407 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mellor
2011-08-31 12:09:25 +00:00
parent cad30f609e
commit 5236326c33
+25
View File
@@ -559,6 +559,31 @@ sub getRelDir {
return $l
}
sub include_file
{
my $file = shift;
my $idir = shift;
my @text = ();
unless ($file =~ /^\//) {
$file = $idir."/".$file;
}
open(INCLUDE,$file) || \
return "#INCLUDEBAD:cannot open $file#";
while(<INCLUDE>) {
chomp($_);
s/\s+$//; #remove trailing spaces
next if /^\s*$/; #-- skip empty lines
push(@text, $_);
}
close(INCLUDE);
return join("\n", @text);
}
=head3 parseLiteFiles
In the liteentry table, one directory and its sub-items (including sub-directory and entries) can co-exist;
In order to handle such a scenario, one hash is generated to show the hirarachy relationship