diff -ur tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/ev/ftools.rb tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/ftools.rb
--- tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/ev/ftools.rb	2005-01-13 23:06:41.000000000 +0100
+++ tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/ftools.rb	2005-01-13 23:06:37.000000000 +0100
@@ -0,0 +1,172 @@
+require "ftools"
+
+class Dir
+  def self.copy(from, to)
+    if File.directory?(from)
+      pdir	= Dir.pwd
+      todir	= File.expand_path(to)
+
+      File.mkpath(todir)
+
+      Dir.chdir(from)
+        Dir.new(".").each do |e|
+          Dir.copy(e, todir+"/"+e)	if not [".", ".."].include?(e)
+        end
+      Dir.chdir(pdir)
+    else
+      todir	= File.dirname(File.expand_path(to))
+
+      File.mkpath(todir)
+
+      File.copy(from, to)
+    end
+  end
+
+  def self.move(from, to)
+    Dir.copy(from, to)
+    Dir.rm_rf(from)
+  end
+
+  def self.rm_rf(entry)
+    if File.ftype(entry) == "directory"
+      pdir	= Dir.pwd
+
+      Dir.chdir(entry)
+        Dir.new(".").each do |e|
+          Dir.rm_rf(e)	if not [".", ".."].include?(e)
+        end
+      Dir.chdir(pdir)
+
+      begin
+        Dir.delete(entry)
+      rescue => e
+        $stderr.puts e.message
+      end
+    else
+      begin
+        File.delete(entry)
+      rescue => e
+        $stderr.puts e.message
+      end
+    end
+  end
+
+  def self.find(entry=nil, mask=nil)
+    entry	= "."	if entry.nil?
+
+    entry	= entry.gsub(/[\/\\]*$/, "")	unless entry.nil?
+
+    mask	= /^#{mask}$/i	if mask.kind_of?(String)
+
+    res	= []
+
+    if File.directory?(entry)
+      pdir	= Dir.pwd
+
+      res += ["%s/" % entry]	if mask.nil? or entry =~ mask
+
+      begin
+        Dir.chdir(entry)
+
+        begin
+          Dir.new(".").each do |e|
+            res += Dir.find(e, mask).collect{|e| entry+"/"+e}	unless [".", ".."].include?(e)
+          end
+        ensure
+          Dir.chdir(pdir)
+        end
+      rescue Errno::EACCES => e
+        $stderr.puts e.message
+      end
+    else
+      res += [entry]	if mask.nil? or entry =~ mask
+    end
+
+    res
+  end
+end
+
+class File
+  def self.rollbackup(file, mode=nil)
+    backupfile	= file + ".RB.BACKUP"
+    controlfile	= file + ".RB.CONTROL"
+    res		= nil
+
+    File.touch(file)    unless File.file?(file)
+
+	# Rollback
+
+    if File.file?(backupfile) and File.file?(controlfile)
+      $stderr.puts "Restoring #{file}..."
+
+      File.copy(backupfile, file)				# Rollback from phase 3
+    end
+
+	# Reset
+
+    File.delete(backupfile)	if File.file?(backupfile)	# Reset from phase 2 or 3
+    File.delete(controlfile)	if File.file?(controlfile)	# Reset from phase 3 or 4
+
+	# Backup
+
+    File.copy(file, backupfile)					# Enter phase 2
+    File.touch(controlfile)					# Enter phase 3
+
+	# The real thing
+
+    if block_given?
+      if mode.nil?
+        res	= yield
+      else
+        File.open(file, mode) do |f|
+          res	= yield(f)
+        end
+      end
+    end
+
+	# Cleanup
+
+    File.delete(backupfile)					# Enter phase 4
+    File.delete(controlfile)					# Enter phase 5
+
+	# Return, like File.open
+
+    res	= File.open(file, (mode or "r"))	unless block_given?
+
+    res
+  end
+
+  def self.touch(file)
+    if File.exists?(file)
+      File.utime(Time.now, File.mtime(file), file)
+    else
+      File.open(file, "a"){|f|}
+    end
+  end
+
+  def self.which(file)
+    res	= nil
+
+    if windows?
+      file	= file.gsub(/\.exe$/i, "") + ".exe"
+      sep		= ";"
+    else
+      sep		= ":"
+    end
+
+    catch :stop do
+      ENV["PATH"].split(/#{sep}/).reverse.each do |d|
+        if File.directory?(d)
+          Dir.new(d).each do |e|
+             if e.downcase == file.downcase
+               res	= File.expand_path(e, d)
+               throw :stop
+            end
+          end
+        end
+      end
+    end
+
+    res
+  end
+end
diff -ur tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/init.rb	2004-12-27 11:16:27.000000000 +0100
+++ tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/init.rb	2005-01-11 18:03:37.000000000 +0100
@@ -1,7 +1,36 @@
+$: << File.dirname(File.expand_path(__FILE__))
+
 require "ev/oldandnewlocation"
+require "ev/ftools"
+require "rbconfig"
 
 exit	if ARGV.include?("--tar2rubyscript-exit")
 
+def backslashes(s)
+  s	= s.gsub(/^\.\//, "").gsub(/\//, "\\\\")	if windows?
+  s
+end
+
+def linux?
+  not windows? and not cygwin?			# Hack ???
+end
+
+def windows?
+  not (target_os.downcase =~ /32/).nil?		# Hack ???
+end
+
+def cygwin?
+  not (target_os.downcase =~ /cyg/).nil?	# Hack ???
+end
+
+def target_os
+  Config::CONFIG["target_os"] or ""
+end
+
+PRESERVE	= ARGV.include?("--tar2rubyscript-preserve")
+
+ARGV.delete_if{|arg| arg =~ /^--tar2rubyscript-/}
+
 scriptfile	= newlocation("tarrubyscript.rb")
 tarfile		= oldlocation(ARGV.shift)
 rbfile		= oldlocation(ARGV.shift)
@@ -27,7 +56,8 @@
   exit 1
 end
 
-tarfile.dup.gsub!(/[\/\\]$/, "")
+TARMODE	= File.file?(tarfile)
+DIRMODE	= File.directory?(tarfile)
 
 if not File.exist?(tarfile)
   $stderr.puts "#{tarfile} doesn´t exist."
@@ -41,43 +71,68 @@
 
 script	= File.open(scriptfile){|f| f.read}
 
-if File.file?(tarfile)
-  $stderr.puts "Found archive..."
+pdir	= Dir.pwd
 
-  archive	= File.open(tarfile, "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
-end
+tmpdir	= tmplocation(File.basename(tarfile))
+
+File.mkpath(tmpdir)
 
-if File.directory?(tarfile)
-  pdir	= Dir.pwd
+Dir.chdir(tmpdir)
 
-  Dir.chdir(tarfile)
+  if TARMODE and not PRESERVE
+    begin
+      tar	= "tar"
+      system(backslashes("#{tar} xf #{tarfile}"))
+    rescue
+      tar	= backslashes(newlocation("tar.exe"))
+      system(backslashes("#{tar} xf #{tarfile}"))
+    end
+  end
+
+  if DIRMODE
+    Dir.copy(tarfile, ".")
+  end
 
-  if File.file?("tar2rubyscript.bat")
+  entries	= Dir.entries(".")
+  entries.delete(".")
+  entries.delete("..")
+
+  if entries.length == 1
+    entry	= entries.shift.dup
+    if File.directory?(entry)
+      Dir.chdir(entry)
+    end
+  end
+
+  if File.file?("tar2rubyscript.bat") and windows?
     $stderr.puts "Running tar2rubyscript.bat ..."
 
     system(".\\tar2rubyscript.bat")
   end
 
-  if File.file?("tar2rubyscript.sh")
+  if File.file?("tar2rubyscript.sh") and (linux? or cygwin?)
     $stderr.puts "Running tar2rubyscript.sh ..."
 
     system("sh -c \". ./tar2rubyscript.sh\"")
   end
 
-  $stderr.puts "Creating archive..."
+Dir.chdir("..")
 
-  Dir.chdir("..")
+  $stderr.puts "Creating archive..."
 
-  begin
-    tar	= "tar"
-    archive	= IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
-  rescue
-    tar	= newlocation("tar.exe")
-    archive	= IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+  if TARMODE and PRESERVE
+    archive	= File.open(tarfile, "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+  else
+    begin
+      tar	= "tar"
+      archive	= IO.popen("#{tar} ch *", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+    rescue
+      tar	= backslashes(newlocation("tar.exe"))
+      archive	= IO.popen("#{tar} ch *", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+    end
   end
 
-  Dir.chdir(pdir)
-end
+Dir.chdir(pdir)
 
 if not licensefile.nil? and not licensefile.empty?
   $stderr.puts "Adding license..."
diff -ur tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/tarrubyscript.rb	2004-12-26 22:15:10.000000000 +0100
+++ tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/tarrubyscript.rb	2005-01-11 21:33:08.000000000 +0100
@@ -25,46 +25,55 @@
   ShowContent	= ARGV.include?("--tar2rubyscript-list")
   JustExtract	= ARGV.include?("--tar2rubyscript-justextract")
   ToTar		= ARGV.include?("--tar2rubyscript-totar")
+  Preserve	= ARGV.include?("--tar2rubyscript-preserve")
 end
 
 ARGV.concat	[]
 
-ARGV.delete_if do |arg|
-  arg =~ /^--tar2rubyscript-/
-end
+ARGV.delete_if{|arg| arg =~ /^--tar2rubyscript-/}
+
+ARGV << "--tar2rubyscript-preserve"	if Preserve
 
 # Tar constants
 
 unless defined?(BLOCKSIZE)
-  BLOCKSIZE	= 512
+  BLOCKSIZE		= 512
 
   NAMELEN		= 100
   MODELEN		= 8
   UIDLEN		= 8
   GIDLEN		= 8
-  CHKSUMLEN	= 8
+  CHKSUMLEN		= 8
   SIZELEN		= 12
-  MAGICLEN	= 8
-  MODTIMELEN	= 12
-  UNAMELEN	= 32
-  GNAMELEN	= 32
+  MAGICLEN		= 8
+  MODTIMELEN		= 12
+  UNAMELEN		= 32
+  GNAMELEN		= 32
   DEVLEN		= 8
 
   TMAGIC		= "ustar"
-  GNU_TMAGIC	= "ustar  "
+  GNU_TMAGIC		= "ustar  "
   SOLARIS_TMAGIC	= "ustar\00000"
 
   MAGICS		= [TMAGIC, GNU_TMAGIC, SOLARIS_TMAGIC]
 
-  LF_OLDFILE	= ´\0´
+  LF_OLDFILE		= ´\0´
   LF_FILE		= ´0´
   LF_LINK		= ´1´
-  LF_SYMLINK	= ´2´
+  LF_SYMLINK		= ´2´
   LF_CHAR		= ´3´
-  LF_BLOCK	= ´4´
+  LF_BLOCK		= ´4´
   LF_DIR		= ´5´
   LF_FIFO		= ´6´
-  LF_CONTIG	= ´7´
+  LF_CONTIG		= ´7´
+
+  GNUTYPE_DUMPDIR	= ´D´
+  GNUTYPE_LONGLINK	= ´K´	# Identifies the *next* file on the tape as having a long linkname.
+  GNUTYPE_LONGNAME	= ´L´	# Identifies the *next* file on the tape as having a long name.
+  GNUTYPE_MULTIVOL	= ´M´	# This is the continuation of a file that began on another volume.
+  GNUTYPE_NAMES		= ´N´	# For storing filenames that do not fit into the main header.
+  GNUTYPE_SPARSE	= ´S´	# This is for sparse files.
+  GNUTYPE_VOLHDR	= ´V´	# This file is a tape/volume header.  Ignore it on extraction.
 end
 
 class Dir
@@ -78,9 +87,17 @@
         end
       Dir.chdir(pdir)
 
-      Dir.delete(entry)
+      begin
+        Dir.delete(entry)
+      rescue => e
+        $stderr.puts e.message
+      end
     else
-      File.delete(entry)
+      begin
+        File.delete(entry)
+      rescue => e
+        $stderr.puts e.message
+      end
     end
   end
 end
@@ -129,12 +146,24 @@
   def initialize(header, fp)
     @header	= Header.new(header)
 
-    if @header.file?
-      padding	= (BLOCKSIZE - (@header.size % BLOCKSIZE)) % BLOCKSIZE
-
-      @data	= fp.read(@header.size)	if @header.size > 0
+    readdata =
+    lambda do |header|
+      padding	= (BLOCKSIZE - (header.size % BLOCKSIZE)) % BLOCKSIZE
+      @data	= fp.read(header.size)	if header.size > 0
       dummy	= fp.read(padding)	if padding > 0
     end
+
+    readdata.call(@header)
+
+    if @header.longname?
+      gnuname		= @data[0..-2]
+
+      header		= fp.read(BLOCKSIZE)
+      @header		= Header.new(header)
+      @header.name	= gnuname
+
+      readdata.call(@header)
+    end
   end
 
   def extract
@@ -143,21 +172,19 @@
         begin
           Dir.mkdir(@header.name, @header.mode)
         rescue SystemCallError => e
-          puts "Couldn´t create dir #{@header.name}: " + e.message
+          $stderr.puts "Couldn´t create dir #{@header.name}: " + e.message
         end
-      else
-        if @header.file?
-          begin
-            File.open(@header.name, "wb") do |fp|
-              fp.write(@data)
-              fp.chmod(@header.mode)
-            end
-          rescue => e
-            puts "Couldn´t create file #{@header.name}: " + e.message
+      elsif @header.file?
+        begin
+          File.open(@header.name, "wb") do |fp|
+            fp.write(@data)
+            fp.chmod(@header.mode)
           end
-        else
-          puts "Couldn´t handle entry #{@header.name}"
+        rescue => e
+          $stderr.puts "Couldn´t create file #{@header.name}: " + e.message
         end
+      else
+        $stderr.puts "Couldn´t handle entry #{@header.name} (flag=#{@header.linkflag.inspect})."
       end
 
       #File.chown(@header.uid, @header.gid, @header.name)
@@ -168,18 +195,19 @@
   def list
     if not @header.name.empty?
       if @header.dir?
-        puts "d %s" % [@header.name]
+        $stderr.puts "d %s" % [@header.name]
       elsif @header.file?
-        puts "f %s (%s)" % [@header.name, @data.length]
+        $stderr.puts "f %s (%s)" % [@header.name, @header.size]
       else
-        puts "Couldn´t handle entry #{@header.name}"
+        $stderr.puts "Couldn´t handle entry #{@header.name} (flag=#{@header.linkflag.inspect})."
       end
     end
   end
 end
 
 class Header
-  attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode)
+  attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode, :linkflag)
+  attr_writer(:name)
 
   def initialize(header)
     fields	= header.unpack(´A100 A8 A8 A8 A12 A12 A8 A1 A100 A8 A32 A32 A8 A8´)
@@ -222,6 +250,10 @@
   def dir?
     @linkflag == LF_DIR
   end
+
+  def longname?
+    @linkflag == GNUTYPE_LONGNAME
+  end
 end
 
 class Content
@@ -279,7 +311,8 @@
   end
 
   def extract
-    Dir.mkdir(@tempdir)	if not File.exists?(@tempdir)
+    Dir.rm_rf(@tempdir)	if File.exists?(@tempdir)
+    Dir.mkdir(@tempdir)
 
     newlocation do
 
@@ -354,7 +387,7 @@
           Dir.chdir(pdir)
         end
       rescue Errno::EACCES => error
-        puts error
+        $stderr.puts error
       end
     else
       File.utime(Time.now, File.mtime(entry), entry)
@@ -481,18 +514,28 @@
   $:.unshift(newlocation)
   $:.push(oldlocation)
 
+  s	= ENV["PATH"].dup
+  if Dir.pwd[1..2] == ":/"	# Hack ???
+    s << ";#{newlocation.gsub(/\//, "\\")}"
+    s << ";#{oldlocation.gsub(/\//, "\\")}"
+  else
+    s << ":#{newlocation}"
+    s << ":#{oldlocation}"
+  end
+  ENV["PATH"]	= s
+
   newlocation do
     if __FILE__ == $0
-      $0.replace("./init.rb")
+      $0.replace(File.expand_path("./init.rb"))
 
       if File.file?("./init.rb")
-        load "./init.rb"
+        load File.expand_path("./init.rb")
       else
         $stderr.puts "%s doesn´t contain an init.rb ." % __FILE__
       end
     else
       if File.file?("./init.rb")
-        load "./init.rb"
+        load File.expand_path("./init.rb")
       end
     end
   end