Sha256: 4ab4961a5807de80593c2c4c27dc8627a7af699559e54660ab8d8f54137c4a17

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

require "zip"

module EPUB
  class OCF
    class PhysicalContainer
      class Rubyzip < self
        def open
          orig_encoding = Zip.force_entry_names_encoding
          begin
            Zip.force_entry_names_encoding = "UTF-8"
            Zip::File.open @container_path do |archive|
              @monitor.synchronize do
                @archive = archive
                begin
                  yield self
                ensure
                  @archive = nil
                end
              end
            end
          ensure
            Zip.force_entry_names_encoding = orig_encoding
          end
        end

        def read(path_name)
          if @archive
            @archive.read(path_name)
          else
            open {|container| container.read(path_name)}
          end
        rescue Errno::ENOENT => error
          raise NoEntry.from_error(error)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
epub-parser-0.4.8 lib/epub/ocf/physical_container/rubyzip.rb