]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blobdiff - src/wget_downloader.rb
Added GetOpt option parsing.
[dead/whatever-dl.git] / src / wget_downloader.rb
index 2cbdd4556dc4be305fb39795432afa4975853977..825ee12b9865f556733e4d05078036990d068fff 100644 (file)
 
 class WgetDownloader < Downloader
 
-  def download(url, outfile)
+  def download(url, outfile, continue=false)
+    if (continue == false and File.exists?(outfile))
+      raise IOError.new("Output file already exists. Please remove #{outfile}, and try again. If this is a partially-downloaded file, you can use the --continue flag to pick up where it left off.")
+    end
+
+    options = ''
+
+    if continue == true
+      options += '--continue'
+    end
+
     # This one's easy.
-    Kernel.exec("wget -O \"#{outfile}\" \"#{url}\"")
+    cmd = "wget #{options} -O \"#{outfile}\" \"#{url}\""
+    puts "\nExecuting external command: #{cmd}\n\n"
+    Kernel.exec(cmd)
   end
   
 end