Class: Zip::ZipFileSystem::ZipFileNameMapper
- Includes:
- Enumerable
- Defined in:
- lib/pik/contrib/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.
538 539 540 541 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 538 def initialize(zipFile) @zipFile = zipFile @pwd = "/" end |
Instance Attribute Details
#pwd ⇒ Object
Returns the value of attribute pwd.
543 544 545 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 543 def pwd @pwd end |
Instance Method Details
#each ⇒ Object
Turns entries into strings and adds leading / and removes trailing slash on directories
580 581 582 583 584 585 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 580 def each @zipFile.each { |e| yield("/"+e.to_s.chomp("/")) } end |
#expand_path(aPath) ⇒ Object
587 588 589 590 591 592 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 587 def (aPath) = aPath.starts_with("/") ? aPath : @pwd.ensure_end("/") + aPath .gsub!(/\/\.(\/|$)/, "") .gsub!(/[^\/]+\/\.\.(\/|$)/, "") .empty? ? "/" : end |
#find_entry(fileName) ⇒ Object
545 546 547 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 545 def find_entry(fileName) @zipFile.find_entry((fileName)) end |
#get_entry(fileName) ⇒ Object
549 550 551 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 549 def get_entry(fileName) @zipFile.get_entry((fileName)) end |
#get_input_stream(fileName, &aProc) ⇒ Object
553 554 555 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 553 def get_input_stream(fileName, &aProc) @zipFile.get_input_stream((fileName), &aProc) end |
#get_output_stream(fileName, &aProc) ⇒ Object
557 558 559 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 557 def get_output_stream(fileName, &aProc) @zipFile.get_output_stream((fileName), &aProc) end |
#mkdir(fileName, permissionInt = 0755) ⇒ Object
574 575 576 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 574 def mkdir(fileName, = 0755) @zipFile.mkdir((fileName), ) end |
#read(fileName) ⇒ Object
561 562 563 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 561 def read(fileName) @zipFile.read((fileName)) end |
#remove(fileName) ⇒ Object
565 566 567 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 565 def remove(fileName) @zipFile.remove((fileName)) end |
#rename(fileName, newName, &continueOnExistsProc) ⇒ Object
569 570 571 572 |
# File 'lib/pik/contrib/zip/zipfilesystem.rb', line 569 def rename(fileName, newName, &continueOnExistsProc) @zipFile.rename((fileName), (newName), &continueOnExistsProc) end |