def prepare

      # if output_dir is not specified, output in the same directory
      # as the imput file
      if !@output_dir && @input_file
        @output_dir = File.dirname(@input_file)
      end

      # if input file is bz2 compressed, use bz2-ruby if available,
      # use command line bzip2 program otherwise.
      if /.bz2$/ =~ @input_file
        unless NO_BZ2
          file = Bzip2::Reader.new File.open(@input_file, "r:UTF-8")
          @parent.msg("WP2TXT is spawming #{@num_threads} threads to process data \n", 0)         
          @parent.msg("Preparing ... This may take several minutes or more ", 0)         
          @infile_size = file_size(file)
          @parent.msg("... Done.", 1)
          file.close
          file = Bzip2::Reader.new File.open(@input_file, "r:UTF-8")
        else
          if RUBY_PLATFORM.index("win32")
            file = IO.popen("bunzip2.exe -c #{@input_file}")
          else
            file = IO.popen("bzip2 -c -d #{@input_file}") 
          end
          @parent.msg("WP2TXT is spawming #{@num_threads} threads to process data \n", 0)         
          @parent.msg("Preparing ... This may take several minutes or more ", 0)         
          @infile_size = file_size(file)
          @parent.msg("... Done.", 1)
          file.close  # try to reopen since rewind method is unavailable
          if RUBY_PLATFORM.index("win32")
            file = IO.popen("bunzip2.exe -c #{@input_file}")
          else
            file = IO.popen("bzip2 -c -d #{@input_file}") 
          end
        end 
      else # meaning that it is a text file
        @infile_size = File.stat(@input_file).size
        file = open(@input_file)
      end

      #create basename of output file
      @outfile_base = File.basename(@input_file, ".*") + "-"            
      @total_size = 0
      @file_index = 1
      outfilename = File.join(@output_dir, @outfile_base + @file_index.to_s)
      @outfiles = []
      @outfiles << outfilename
      @fp = File.open(outfilename, "w")    
      @parent.before
      @parent.data_set(@input_file, 100 * 100)
      @file_pointer = file
      return true
    end
def prepare

      # if output_dir is not specified, output in the same directory
      # as the imput file
      if !@output_dir && @input_file
        @output_dir = File.dirname(@input_file)
      end

      # if input file is bz2 compressed, use bz2-ruby if available,
      # use command line bzip2 program otherwise.
      if /.bz2$/ =~ @input_file
        unless NO_BZ2
          file = Bzip2::Reader.new File.open(@input_file, "r:UTF-8")
          @parent.msg("WP2TXT is spawming #{@num_threads} threads to process data \n", 0)         
          @parent.msg("Preparing ... This may take several minutes or more ", 0)         
          @infile_size = file_size(file)
          @parent.msg("... Done.", 1)
          file.close
          file = Bzip2::Reader.new File.open(@input_file, "r:UTF-8")
        else
          if RUBY_PLATFORM.index("win32")
            file = IO.popen("bunzip2.exe -c #{@input_file}")
          else
            file = IO.popen("bzip2 -c -d #{@input_file}") 
          end
          @parent.msg("WP2TXT is spawming #{@num_threads} threads to process data \n", 0)         
          @parent.msg("Preparing ... This may take several minutes or more ", 0)         
          @infile_size = file_size(file)
          @parent.msg("... Done.", 1)
          file.close  # try to reopen since rewind method is unavailable
          if RUBY_PLATFORM.index("win32")
            file = IO.popen("bunzip2.exe -c #{@input_file}")
          else
            file = IO.popen("bzip2 -c -d #{@input_file}") 
          end
        end 
      else # meaning that it is a text file
        @infile_size = File.stat(@input_file).size
        file = open(@input_file)
      end

      #create basename of output file
      @outfile_base = File.basename(@input_file, ".*") + "-"            
      @total_size = 0
      @file_index = 1
      outfilename = File.join(@output_dir, @outfile_base + @file_index.to_s)
      @outfiles = []
      @outfiles << outfilename
      @fp = File.open(outfilename, "w")    
      @parent.before
      @parent.data_set(@input_file, 100 * 100)
      @file_pointer = file
      return true
    end
check the size of input file (bz2 or plain xml) when uncompressed