2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-18 05:56:03 +00:00

Newer perl versions have problem with split without arg

git-svn-id: https://svn.fhem.de/fhem/trunk@1164 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-01-02 22:31:40 +00:00
parent 56db8f1599
commit e53885cfe4

View File

@ -41,34 +41,37 @@ CommandUpdatefhem($$)
my @commandchain = split(/ +/,$param);
# Check if the first parameter is "backup"
if(uc($commandchain[0]) eq "BACKUP") {
my $backupdir = AttrVal("global", "backupdir", "/tmp/FHEM_Backup");
# create the backupfolder
if(!-d $backupdir) {
if(!mkdir($backupdir)) {
return "Can't create backup folder $!";
}
}
# full backup, for compatibility, we use the native copy unction, not
# dircopy from File::Copy::Recursive
if($commandchain[1] eq "") {
opendir(IMD, $moddir) || return "Cannot open fhem-module directory";
my @files= readdir(IMD);
closedir(IMD);
my $f;
foreach $f (@files) {
unless ( ($f eq ".") || ($f eq "..") ) {
my $ret = copy("$moddir/$f", "$backupdir/$f");
if($param) {
my @commandchain = split(/ +/,$param);
if(uc($commandchain[0]) eq "BACKUP") {
my $backupdir = AttrVal("global", "backupdir", "/tmp/FHEM_Backup");
# create the backupfolder
if(!-d $backupdir) {
if(!mkdir($backupdir)) {
return "Can't create backup folder $!";
}
}
$param = "";
# full backup, for compatibility, we use the native copy unction, not
# dircopy from File::Copy::Recursive
if($commandchain[1] eq "") {
opendir(IMD, $moddir) || return "Cannot open fhem-module directory";
my @files= readdir(IMD);
closedir(IMD);
my $f;
} else {
# one file backup
copy("$moddir/$commandchain[1]", "$backupdir/$commandchain[1]");
# recreate $param for further use
$param = $commandchain[1];
foreach $f (@files) {
unless ( ($f eq ".") || ($f eq "..") ) {
my $ret = copy("$moddir/$f", "$backupdir/$f");
}
}
$param = "";
} else {
# one file backup
copy("$moddir/$commandchain[1]", "$backupdir/$commandchain[1]");
# recreate $param for further use
$param = $commandchain[1];
}
}
}