Skip to content
Snippets Groups Projects
Commit 0d3d61ba authored by Andy Yates's avatar Andy Yates
Browse files

A more succient version of the method.

parent 09cb57ac
No related branches found
No related tags found
No related merge requests found
......@@ -128,17 +128,19 @@ sub production_name {
return $prod;
}
# Closes file handle, and deletes the file stub if it contains no data
# Returns success type
# Closes file handle, and deletes the file stub if no data was written to
# the file handle (using tell). We can also only close a file handle and unlink
# the data if it was open otherwise we just ignore it
# Returns success if we managed to close/delete the file
sub tidy_file_handle {
my ($self, $fh, $path) = @_;
if ($fh->tell() == 0) {
$fh->close() if $fh->opened();
unlink($path) if -f $path;
if($fh->opened()) {
my $unlink = ($fh->tell() == 0) ? 1 : 0;
$fh->close();
unlink($path) if -f $path && $unlink;
return 1;
}
$fh->close() if $fh->opened();
}
return 0;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment