5 require 'zip/zipfilesystem'
8 EXAMPLE_ZIP = "filesystem.zip"
10 File.delete(EXAMPLE_ZIP) if File.exists?(EXAMPLE_ZIP)
12 Zip::ZipFile.open(EXAMPLE_ZIP, Zip::ZipFile::CREATE) {
14 zf.file.open("file1.txt", "w") { |os| os.write "first file1.txt" }
17 zf.file.open("file1.txt", "w") { |os| os.write "second file1.txt" }
18 puts zf.file.read("file1.txt")
19 puts zf.file.read("../file1.txt")
21 zf.file.open("file2.txt", "w") { |os| os.write "first file2.txt" }
22 puts "Entries: #{zf.entries.join(', ')}"
25 Zip::ZipFile.open(EXAMPLE_ZIP) {
27 puts "Entries from reloaded zip: #{zf.entries.join(', ')}"
30 # For other examples, look at zip.rb and ziptest.rb
32 # Copyright (C) 2003 Thomas Sondergaard
33 # rubyzip is free software; you can redistribute it and/or
34 # modify it under the terms of the ruby license.