2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

99_Utils.pm: Svn_GetFile added (Forum #97989)

git-svn-id: https://svn.fhem.de/fhem/trunk@21000 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-01-17 11:30:21 +00:00
parent d5b5fa9ca5
commit fd6970a262

View File

@ -264,6 +264,31 @@ sortTopicNum(@)
return @sorted;
}
sub
Svn_GetFile($$)
{
my ($from, $to) = @_;
require HttpUtils;
return "Missing argument from or to" if(!$from || !$to);
return "Forbidden characters in from/to"
if($from =~ m/\.\./ || $to =~ m/\.\./);
HttpUtils_NonblockingGet({
url=>"https://svn.fhem.de/trac/browser/trunk/fhem/$from?format=txt",
callback=>sub($$$){
if($_[1]) {
Log 1, "ERROR Svn_GetFile $from: $_[1]";
return;
}
if(!open(FH,">$to")) {
Log 1, "ERROR Svn_GetFile $to: $!";
return;
}
print FH $_[2];
close(FH);
Log 1, "SVN download of $from to $to finished";
}});
return "Download started, check the FHEM-log";
}
1;
@ -358,6 +383,15 @@ sortTopicNum(@)
(Forum #98578)
</li></br>
<li><b>Svn_GetFile(from, to)</b><br>
Retrieve a file diretly from the fhem.de SVN server.<br>
Example:
<ul>
<code>{ Svn_GetFile("contrib/86_FS10.pm", "FHEM/86_FS10.pm") }</code>
</ul>
</li></br>
</ul>
</ul>
=end html