diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl index b07ee2fabd5a06fa2bca78ae368806bfad7d63ae..e7b7d5bdbd80f63d2905bc5dec36d588eaae4668 100644 --- a/bin/slubsipbuilderbagit.pl +++ b/bin/slubsipbuilderbagit.pl @@ -374,11 +374,11 @@ PATCH my $i = 1; foreach my $file(@addMetaFile){ # check reserved file names - my $meta_file_name = getFileName($file); + my $meta_file_name = basename($file); if($meta_file_name eq "rights.xml" || $meta_file_name eq "mods.xml"){ foreach my $f(@addMetaFile){ # check if numbered xml file exists - my $f_name = getFileName($f); + my $f_name = basename($f); while($f_name eq "$i.xml"){ $i++; } @@ -410,28 +410,14 @@ PATCH } } - sub getFileName($){ - if(! defined $_[0]) { croak "path with file name is not defined!"; } - if($_[0] eq ""){ croak "invalid parameters!"; } - - my $file_name = $_[0]; - - # grep last directory from a path - if ($file_name =~ m/([^\/]+)$/){ - $file_name = $1; - } - - return $file_name; - } - sub validateRightsXML($$){ - if(! defined $_[0]) { croak "rightsFilePath not defined!"; } + if(! $_[0]) { croak "rightsFilePath not defined!"; } if(! defined $_[1]) { croak "xsd name not defined!"; } my $rightsFilePath = $_[0]; my $xsdName = $_[1]; - my $rightsName = getFileName($rightsFilePath); + my $rightsName = basename($rightsFilePath); my $xsd_file = path(__FILE__)->parent->realpath->parent->child("xsd")->child($xsdName); # absolute path my $schema = XML::LibXML::Schema->new(location => $xsd_file);