# File lib/archive/tar/minitar/command.rb, line 363 def altname "cr" end
# File lib/archive/tar/minitar/command.rb, line 367 def call(args, opts = {}, ioe = {}) argv = [] while (arg = args.shift) case arg when '--compress', '-z' opts[:compress] = true else argv << arg end end if argv.size < 2 ioe[:output] << "Not enough arguments.\n\n" CommandPattern["help"][["create"]] return 255 end output = argv.shift if '-' == output opts[:name] = "STDOUT" output = ioe[:output] opts[:output] = ioe[:error] else opts[:name] = output output = File.open(output, "wb") opts[:output] = ioe[:output] end if opts[:name] =~ /\.tar\.gz$|\.tgz$/ or opts[:compress] output = Zlib::GzipWriter.new(output) end files = [] if argv.include?("--") # Read stdin for the list of files. files = "" files << ioe[:input].read while not ioe[:input].eof? files = files.split(/\r\n|\n|\r/) args.delete("--") end files << argv.to_a files.flatten! if opts[:verbose] watcher = lambda do |action, name, stats| opts[:output] << "#{name}\n" if action == :dir or action == :file_done end finisher = lambda { opts[:output] << "\n" } elsif opts[:progress] progress = ProgressBar.new(opts[:name], 1) watcher = lambda do |action, name, stats| case action when :file_start, :dir progress.title = File.basename(name) if action == :dir progress.total += 1 progress.inc else progress.total += stats[:size] end when :file_progress progress.inc(stats[:currinc]) end end finisher = lambda do progress.title = opts[:name] progress.finish end else watcher = nil finisher = lambda { } end Archive::Tar::Minitar.pack(files, output, &watcher) finisher.call 0 ensure output.close if output and not output.closed? end
# File lib/archive/tar/minitar/command.rb, line 449 def help help = minitar create [OPTIONS] <tarfile|-> <file|directory|-->+Creates a new tarfile. If the tarfile is named .tar.gz or .tgz, then itwill be compressed automatically. If the tarfile is "-", then it will beoutput to standard output (stdout) so that minitar may be piped.The files or directories that will be packed into the tarfile arespecified after the name of the tarfile itself. Directories will beprocessed recursively. If the token "--" is found in the list of filesto be packed, additional filenames will be read from standard input(stdin). If any file is not found, the packaging will be halted.create Options: --compress, -z Compresses the tarfile with gzip. end
Generated with the Darkfish Rdoc Generator 2.