Class: Zip::ZipFileSystem::ZipFileNameMapper
Overview
All access to ZipFile from ZipFsFile and ZipFsDir goes through a ZipFileNameMapper, which has one responsibility: ensure
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Enumerable
#deep_clone, #deep_dup, #inject, #select_map
Constructor Details
Returns a new instance of ZipFileNameMapper.
538
539
540
541
|
# File 'lib/zip/zipfilesystem.rb', line 538
def initialize(zipFile)
@zipFile = zipFile
@pwd = "/"
end
|
Instance Attribute Details
Returns the value of attribute pwd.
543
544
545
|
# File 'lib/zip/zipfilesystem.rb', line 543
def pwd
@pwd
end
|
Instance Method Details
Turns entries into strings and adds leading / and removes trailing slash on directories
580
581
582
583
584
585
|
# File 'lib/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/zip/zipfilesystem.rb', line 587
def expand_path(aPath)
expanded = aPath.starts_with("/") ? aPath : @pwd.ensure_end("/") + aPath
expanded.gsub!(/\/\.(\/|$)/, "")
expanded.gsub!(/[^\/]+\/\.\.(\/|$)/, "")
expanded.empty? ? "/" : expanded
end
|
#find_entry(fileName) ⇒ Object
545
546
547
|
# File 'lib/zip/zipfilesystem.rb', line 545
def find_entry(fileName)
@zipFile.find_entry(expand_to_entry(fileName))
end
|
#get_entry(fileName) ⇒ Object
549
550
551
|
# File 'lib/zip/zipfilesystem.rb', line 549
def get_entry(fileName)
@zipFile.get_entry(expand_to_entry(fileName))
end
|
553
554
555
|
# File 'lib/zip/zipfilesystem.rb', line 553
def get_input_stream(fileName, &aProc)
@zipFile.get_input_stream(expand_to_entry(fileName), &aProc)
end
|
#get_output_stream(fileName, &aProc) ⇒ Object
557
558
559
|
# File 'lib/zip/zipfilesystem.rb', line 557
def get_output_stream(fileName, &aProc)
@zipFile.get_output_stream(expand_to_entry(fileName), &aProc)
end
|
#mkdir(fileName, permissionInt = 0755) ⇒ Object
574
575
576
|
# File 'lib/zip/zipfilesystem.rb', line 574
def mkdir(fileName, permissionInt = 0755)
@zipFile.mkdir(expand_to_entry(fileName), permissionInt)
end
|
#read(fileName) ⇒ Object
561
562
563
|
# File 'lib/zip/zipfilesystem.rb', line 561
def read(fileName)
@zipFile.read(expand_to_entry(fileName))
end
|
#remove(fileName) ⇒ Object
565
566
567
|
# File 'lib/zip/zipfilesystem.rb', line 565
def remove(fileName)
@zipFile.remove(expand_to_entry(fileName))
end
|
#rename(fileName, newName, &continueOnExistsProc) ⇒ Object
569
570
571
572
|
# File 'lib/zip/zipfilesystem.rb', line 569
def rename(fileName, newName, &continueOnExistsProc)
@zipFile.rename(expand_to_entry(fileName), expand_to_entry(newName),
&continueOnExistsProc)
end
|