Sha256: a18d9ef351efb0c209aaff7ef031e0d39daae706416a28dc4cb6c6759678f4d4

Contents?: true

Size: 945 Bytes

Versions: 9

Compression:

Stored size: 945 Bytes

Contents

#!/usr/bin/env ruby

$: << "../lib"

require 'zip/zipfilesystem'
require 'ftools'

EXAMPLE_ZIP = "filesystem.zip"

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

Zip::ZipFile.open(EXAMPLE_ZIP, Zip::ZipFile::CREATE) {
  |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(', ')}"
}

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

# 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

9 entries across 9 versions & 4 rubygems

Version Path
IronDigital-rubyzip-0.9.2 samples/example_filesystem.rb
agraham-rubyzip-0.9.1 samples/example_filesystem.rb
expectedbehavior-rubyzip-0.9.1.2 samples/example_filesystem.rb
rubyzip-0.5.11 samples/example_filesystem.rb
rubyzip-0.5.9 samples/example_filesystem.rb
rubyzip-0.5.7 samples/example_filesystem.rb
rubyzip-0.5.12 samples/example_filesystem.rb
rubyzip-0.5.8 samples/example_filesystem.rb
rubyzip-0.9.1 samples/example_filesystem.rb