From dd22bbb362a9f36d45d3fb0eb22cdee68beebe7e Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Thu, 14 Jun 2012 16:17:41 +0200 Subject: [PATCH] feature #1303: support for STDIN and STDOUT in downloader.rb Now the file "-" means standard input/output --- src/datastore_mad/remotes/downloader.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/datastore_mad/remotes/downloader.rb b/src/datastore_mad/remotes/downloader.rb index 79f3e41653..814d3e8a0a 100755 --- a/src/datastore_mad/remotes/downloader.rb +++ b/src/datastore_mad/remotes/downloader.rb @@ -64,11 +64,15 @@ class Stream end def open_output_file - begin - @output_file=File.open(@to, "w") - rescue - STDERR.puts "Error opening output file '#{@to}" - exit(-1) + if @to=='-' + @output_file=STDOUT + else + begin + @output_file=File.open(@to, "w") + rescue + STDERR.puts "Error opening output file '#{@to}" + exit(-1) + end end end @@ -175,6 +179,8 @@ class Stream begin case @from + when '-' + io=STDIN when /^https?:\/\// io=wget_downloader(@from) when /^file:\/\/(.*)$/ @@ -220,7 +226,7 @@ class Stream check_hashes - postprocess + postprocess if @to!='-' end def postprocess