Expand directory when entered as additonal file

This commit is contained in:
Jamie Cameron
2007-12-28 07:10:53 +00:00
parent 52c28690d8
commit 34d802a181
2 changed files with 34 additions and 2 deletions

View File

@@ -10,3 +10,5 @@ Made the backup email contents translatable.
Added a warning if % is used in filenames but strftime substition is not enabled.
---- Changes since 1.330 ----
Added tabs to reduce the size of the main page.
---- Changes since 1.390 ----
When a directory is entered as an additional path to backup, it will be expanded to the list of all files under it when the backup is done.

View File

@@ -237,8 +237,18 @@ if ($_[4]) {
# Add other files
foreach my $f (@{$_[6]}) {
push(@files, $f);
push(@{$manifestfiles{"other"}}, $f);
if (-d $f) {
# A directory .. recursively expand
foreach my $sf (&expand_directory($f)) {
push(@files, $sf);
push(@{$manifestfiles{"other"}}, $sf);
}
}
else {
# Just one file
push(@files, $f);
push(@{$manifestfiles{"other"}}, $f);
}
}
# Save the manifest files
@@ -576,5 +586,25 @@ $webmin || !$nofiles || $others || &error($text{'save_ewebmin'});
return ($webmin, $nofiles, $others);
}
sub expand_directory
{
local ($dir) = @_;
local @rv;
opendir(EXPAND, $dir);
local @sf = readdir(EXPAND);
closedir(EXPAND);
foreach my $sf (@sf) {
next if ($sf eq "." || $sf eq "..");
local $path = "$dir/$sf";
if (-l $path || !-d $path) {
push(@rv, $path);
}
elsif (-d $sf) {
push(@rv, &expand_directory($path));
}
}
return @rv;
}
1;