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
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/rubyzip-1.2.0/samples/example_filesystem.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/rubyzip-1.2.0/samples/example_filesystem.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/rubyzip-1.2.0/samples/example_filesystem.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rubyzip-1.2.0/samples/example_filesystem.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rubyzip-1.2.0/samples/example_filesystem.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rubyzip-1.2.0/samples/example_filesystem.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rubyzip-1.2.0/samples/example_filesystem.rb
tdiary-5.0.1 vendor/bundle/gems/rubyzip-1.2.0/samples/example_filesystem.rb
rubyzip-1.2.0 samples/example_filesystem.rb