feature #1303: support for STDIN and STDOUT in downloader.rb

Now the file "-" means standard input/output
This commit is contained in:
Javi Fontan committed 2012-06-14 16:17:41 +02:00
1 parent 7ad904bd41
commit dd22bbb362
1 file changed
+12 -6
+12 -6
View File
@@ -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