Sha256: 959ce0cc3cf1d0aa145012b32b5a7581af47937e25f672709036cbafedf0db90

Contents?: true

Size: 917 Bytes

Versions: 69

Compression:

Stored size: 917 Bytes

Contents

#!/usr/bin/env ruby

$: << '../lib'

require 'zip/filesystem'

EXAMPLE_ZIP = 'filesystem.zip'

File.delete(EXAMPLE_ZIP) if File.exist?(EXAMPLE_ZIP)

Zip::File.open(EXAMPLE_ZIP, Zip::File::CREATE) do |zf|
  zf.file.open('file1.txt', 'w') { |os| os.write 'first file1.txt' }
  zf.dir.mkdir('dir1')
  zf.dir.chdir('dir1')
  zf.file.open('file1.txt', 'w') { |os| os.write 'second file1.txt' }
  puts zf.file.read('file1.txt')
  puts zf.file.read('../file1.txt')
  zf.dir.chdir('..')
  zf.file.open('file2.txt', 'w') { |os| os.write 'first file2.txt' }
  puts "Entries:                   #{zf.entries.join(', ')}"
end

Zip::File.open(EXAMPLE_ZIP) do |zf|
  puts "Entries from reloaded zip: #{zf.entries.join(', ')}"
end

# For other examples, look at zip.rb and ziptest.rb

# Copyright (C) 2003 Thomas Sondergaard
# rubyzip is free software; you can redistribute it and/or
# modify it under the terms of the ruby license.

Version data entries

69 entries across 55 versions & 6 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example_filesystem.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/rubyzip-2.2.0/samples/example_filesystem.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example_filesystem.rb
rubyzip-2.2.0 samples/example_filesystem.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.3/samples/example_filesystem.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rubyzip-1.2.1/samples/example_filesystem.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rubyzip-1.3.0/samples/example_filesystem.rb
rubyzip-2.1.0 samples/example_filesystem.rb
tdiary-5.1.0 vendor/bundle/gems/rubyzip-2.0.0/samples/example_filesystem.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example_filesystem.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/samples/example_filesystem.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rubyzip-2.0.0/samples/example_filesystem.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rubyzip-2.0.0/samples/example_filesystem.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/samples/example_filesystem.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/samples/example_filesystem.rb
rubyzip-2.0.0 samples/example_filesystem.rb
rubyzip-1.3.0 samples/example_filesystem.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/samples/example_filesystem.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.2/samples/example_filesystem.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/samples/example_filesystem.rb