Class: Zip::ZipFileSystem::ZipFileNameMapper
- Includes:
- Enumerable
- Defined in:
- lib/zip/zipfilesystem.rb
Overview
All access to ZipFile from ZipFsFile and ZipFsDir goes through a ZipFileNameMapper, which has one responsibility: ensure
Instance Attribute Summary collapse
-
#pwd ⇒ Object
Returns the value of attribute pwd.
Instance Method Summary collapse
-
#each ⇒ Object
Turns entries into strings and adds leading / and removes trailing slash on directories.
- #expand_path(aPath) ⇒ Object
- #find_entry(fileName) ⇒ Object
- #get_entry(fileName) ⇒ Object
- #get_input_stream(fileName, &aProc) ⇒ Object
- #get_output_stream(fileName, &aProc) ⇒ Object
-
#initialize(zipFile) ⇒ ZipFileNameMapper
constructor
A new instance of ZipFileNameMapper.
- #mkdir(fileName, permissionInt = 0755) ⇒ Object
- #read(fileName) ⇒ Object
- #remove(fileName) ⇒ Object
- #rename(fileName, newName, &continueOnExistsProc) ⇒ Object
Methods included from Enumerable
Constructor Details
#initialize(zipFile) ⇒ ZipFileNameMapper
Returns a new instance of ZipFileNameMapper.
539 540 541 542 |
# File 'lib/zip/zipfilesystem.rb', line 539 def initialize(zipFile) @zipFile = zipFile @pwd = "/" end |
Instance Attribute Details
#pwd ⇒ Object
Returns the value of attribute pwd.
544 545 546 |
# File 'lib/zip/zipfilesystem.rb', line 544 def pwd @pwd end |
Instance Method Details
#each ⇒ Object
Turns entries into strings and adds leading / and removes trailing slash on directories
581 582 583 584 585 586 |
# File 'lib/zip/zipfilesystem.rb', line 581 def each @zipFile.each { |e| yield("/"+e.to_s.chomp("/")) } end |
#expand_path(aPath) ⇒ Object
588 589 590 591 592 593 |
# File 'lib/zip/zipfilesystem.rb', line 588 def (aPath) = aPath.starts_with("/") ? aPath : @pwd.ensure_end("/") + aPath .gsub!(/\/\.(\/|$)/, "") .gsub!(/[^\/]+\/\.\.(\/|$)/, "") .empty? ? "/" : end |
#find_entry(fileName) ⇒ Object
546 547 548 |
# File 'lib/zip/zipfilesystem.rb', line 546 def find_entry(fileName) @zipFile.find_entry((fileName)) end |
#get_entry(fileName) ⇒ Object
550 551 552 |
# File 'lib/zip/zipfilesystem.rb', line 550 def get_entry(fileName) @zipFile.get_entry((fileName)) end |
#get_input_stream(fileName, &aProc) ⇒ Object
554 555 556 |
# File 'lib/zip/zipfilesystem.rb', line 554 def get_input_stream(fileName, &aProc) @zipFile.get_input_stream((fileName), &aProc) end |
#get_output_stream(fileName, &aProc) ⇒ Object
558 559 560 |
# File 'lib/zip/zipfilesystem.rb', line 558 def get_output_stream(fileName, &aProc) @zipFile.get_output_stream((fileName), &aProc) end |
#mkdir(fileName, permissionInt = 0755) ⇒ Object
575 576 577 |
# File 'lib/zip/zipfilesystem.rb', line 575 def mkdir(fileName, = 0755) @zipFile.mkdir((fileName), ) end |
#read(fileName) ⇒ Object
562 563 564 |
# File 'lib/zip/zipfilesystem.rb', line 562 def read(fileName) @zipFile.read((fileName)) end |
#remove(fileName) ⇒ Object
566 567 568 |
# File 'lib/zip/zipfilesystem.rb', line 566 def remove(fileName) @zipFile.remove((fileName)) end |
#rename(fileName, newName, &continueOnExistsProc) ⇒ Object
570 571 572 573 |
# File 'lib/zip/zipfilesystem.rb', line 570 def rename(fileName, newName, &continueOnExistsProc) @zipFile.rename((fileName), (newName), &continueOnExistsProc) end |