fix use of getcwd in delete_empty_subdirs. We use absolute paths

pull/2562/head
Isaac Connor 2018-12-03 11:08:24 -05:00
parent 23124d634c
commit 14272a42b4
1 changed files with 4 additions and 2 deletions

View File

@ -981,10 +981,11 @@ sub deleteSwapImage {
# Deletes empty sub directories of the given path. # Deletes empty sub directories of the given path.
# Does not delete the path if empty. Is not meant to be recursive. # Does not delete the path if empty. Is not meant to be recursive.
# Assumes absolute path
sub delete_empty_subdirs { sub delete_empty_subdirs {
my $DIR; my $DIR;
if ( !opendir($DIR, $_[0]) ) { if ( !opendir($DIR, $_[0]) ) {
Error("delete_empty_directories: Can't open directory '".getcwd()."/$_[0]': $!" ); Error("delete_empty_subdirs: Can't open directory '/$_[0]': $!" );
return; return;
} }
my @contents = map { ( $_ eq '.' or $_ eq '..' ) ? () : $_ } readdir( $DIR ); my @contents = map { ( $_ eq '.' or $_ eq '..' ) ? () : $_ } readdir( $DIR );
@ -997,10 +998,11 @@ sub delete_empty_subdirs {
closedir($DIR); closedir($DIR);
} }
# Assumes absolute path
sub delete_empty_directories { sub delete_empty_directories {
my $DIR; my $DIR;
if ( !opendir($DIR, $_[0]) ) { if ( !opendir($DIR, $_[0]) ) {
Error("delete_empty_directories: Can't open directory '".getcwd()."/$_[0]': $!" ); Error("delete_empty_directories: Can't open directory '/$_[0]': $!" );
return; return;
} }
my @contents = map { ( $_ eq '.' or $_ eq '..' ) ? () : $_ } readdir( $DIR ); my @contents = map { ( $_ eq '.' or $_ eq '..' ) ? () : $_ } readdir( $DIR );