# File lib/archive/tar/minitar/command.rb, line 622 622: def altname 623: "ls" 624: end
# File lib/archive/tar/minitar/command.rb, line 634 634: def call(args, opts = {}, ioe = {}) 635: argv = [] 636: output = nil 637: dest = "." 638: files = [] 639: opts[:field] = "name" 640: 641: while (arg = args.shift) 642: case arg 643: when '--sort', '-S' 644: opts[:sort] = true 645: opts[:field] = args.shift 646: when '--reverse', '-R' 647: opts[:reverse] = true 648: opts[:sort] = true 649: when '--uncompress', '-z' 650: opts[:uncompress] = true 651: when '-l' 652: opts[:verbose] = true 653: else 654: argv << arg 655: end 656: end 657: 658: if argv.size < 1 659: ioe[:output] << "Not enough arguments.\n\n" 660: CommandPattern["help"][["list"]] 661: return 255 662: end 663: 664: input = argv.shift 665: if '-' == input 666: opts[:name] = "STDIN" 667: input = ioe[:input] 668: else 669: opts[:name] = input 670: input = File.open(input, "rb") 671: end 672: 673: if opts[:name] =~ /\.tar\.gz$|\.tgz$/ or opts[:uncompress] 674: input = Zlib::GzipReader.new(input) 675: end 676: 677: files << argv.to_a 678: files.flatten! 679: 680: if opts[:verbose] or opts[:progress] 681: format = "%10s %4d %8s %8s %8d %12s %s" 682: datefmt = "%b %d %Y" 683: timefmt = "%b %d %H:%M" 684: fields = %(permissions inodes user group size date fullname) 685: else 686: format = "%s" 687: fields = %(fullname) 688: end 689: 690: opts[:field] = opts[:field].intern 691: opts[:field] = :full_name if opts[:field] == :name 692: 693: output = [] 694: 695: Archive::Tar::Minitar::Input.open(input) do |inp| 696: today = Time.now 697: oneyear = Time.mktime(today.year - 1, today.month, today.day) 698: inp.each do |entry| 699: value = format % fields.map do |ff| 700: case ff 701: when "permissions" 702: s = entry.directory? ? "d" : "-" 703: s << modestr(entry.mode / 0100) 704: s << modestr(entry.mode / 0010) 705: s << modestr(entry.mode) 706: when "inodes" 707: entry.size / 512 708: when "user" 709: entry.uname || entry.uid || 0 710: when "group" 711: entry.gname || entry.gid || 0 712: when "size" 713: entry.size 714: when "date" 715: if Time.at(entry.mtime) > (oneyear) 716: Time.at(entry.mtime).strftime(timefmt) 717: else 718: Time.at(entry.mtime).strftime(datefmt) 719: end 720: when "fullname" 721: entry.full_name 722: end 723: end 724: 725: if opts[:sort] 726: output << [entry.send(opts[:field]), value] 727: else 728: ioe[:output] << value << "\n" 729: end 730: 731: end 732: end 733: 734: if opts[:sort] 735: output = output.sort { |a, b| a[0] <=> b[0] } 736: if opts[:reverse] 737: output.reverse_each { |oo| ioe[:output] << oo[1] << "\n" } 738: else 739: output.each { |oo| ioe[:output] << oo[1] << "\n" } 740: end 741: end 742: 743: 0 744: end
# File lib/archive/tar/minitar/command.rb, line 746 746: def help 747: help = minitar list [OPTIONS] <tarfile|-> [<file>+]Lists files in an existing tarfile. If the tarfile is named .tar.gz or.tgz, then it will be uncompressed automatically. If the tarfile is "-",then it will be read from standard input (stdin) so that minitar may bepiped.If --verbose or --progress is specified, then the file list will besimilar to that produced by the Unix command "ls -l".list Options: --uncompress, -z Uncompresses the tarfile with gzip. --sort [<FIELD>], -S Sorts the list of files by the specified field. The sort defaults to the filename. --reverse, -R Reverses the sort. -l Lists the files in detail.Sort Fields: name, mtime, size 748: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.