From ab18f6c3a6cf4887f280acdf2d5328bfa38594aa Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Tue, 18 Jul 2017 20:56:01 +0000 Subject: [PATCH] version: add support for controls_fhem.txt update via "svn update" (Forum: #74372) git-svn-id: https://svn.fhem.de/fhem/trunk@14745 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_version.pm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fhem/FHEM/98_version.pm b/fhem/FHEM/98_version.pm index 0b020cb43..b973302cc 100755 --- a/fhem/FHEM/98_version.pm +++ b/fhem/FHEM/98_version.pm @@ -98,19 +98,20 @@ sub version_sortModules($$) sub version_getRevFromControls(;$) { my ($name) = @_; - $name = "fhem" unless(defined($name)); - my $control_file = AttrVal("global","modpath",".")."/FHEM/controls_$name.txt"; + $name //= "fhem"; + my $cf = "controls_$name.txt"; + my $filename = (-e "./$cf") ? "./$cf" : AttrVal("global","modpath",".")."/FHEM/$cf"; + my ($err, @content) = FileRead({FileName => $filename, ForceType => "file"}); + if ($err) { + Log 3, "version: unable to open $filename: $err"; + return undef; + } my $revision; - - if(open(FH, $control_file)) { - while() { - chomp; - if(/^REV\s+(\S+.*)$/) { - $revision = $1; - last; - } + foreach my $l (@content) { + if($l =~ /^REV\s+(\S+.*)$/) { + $revision = $1; + last; } - close(FH); } return $revision; }