Class: Archive::Zip::Entry::Directory
- Inherits:
-
Object
- Object
- Archive::Zip::Entry::Directory
- Includes:
- Archive::Zip::Entry
- Defined in:
- lib/archive/zip/entry.rb
Overview
Archive::Zip::Entry::Directory represents a directory entry within a Zip archive.
Constant Summary
Constant Summary
Constants included from Archive::Zip::Entry
FLAG_DATA_DESCRIPTOR_FOLLOWS, FLAG_ENCRYPTED
Instance Attribute Summary
Attributes included from Archive::Zip::Entry
#atime, #comment, #compression_codec, #encryption_codec, #expected_data_descriptor, #gid, #mode, #mtime, #password, #raw_data, #uid, #zip_path
Instance Method Summary (collapse)
-
- (Boolean) directory?
Returns true.
-
- (Object) extract(options = {})
Extracts this entry.
-
- (Object) ftype
Returns the file type of this entry as the symbol :directory.
-
- (Object) mode=(mode)
Overridden in order to ensure that the proper mode bits are set for a directory.
-
- (Object) zip_path=(zip_path)
Inherits the behavior of Archive::Zip::Entry#zip_path= but ensures that there is a trailing slash (/) on the end of the path.
Methods included from Archive::Zip::Entry
#add_extra_field, #dump_central_file_record, #dump_local_file_record, expand_path, #file?, from_file, #initialize, parse, #symlink?
Instance Method Details
- (Boolean) directory?
Returns true.
825 826 827 |
# File 'lib/archive/zip/entry.rb', line 825 def directory? true end |
- (Object) extract(options = {})
Extracts this entry.
options is a Hash optionally containing the following:
:file_path |
Specifies the path to which this entry will be extracted. Defaults to the zip path of this entry. |
:permissions |
When set to false (the default), POSIX mode/permission bits will be ignored. Otherwise, they will be restored if possible. |
:ownerships |
When set to false (the default), user and group ownerships will be ignored. On most systems, only a superuser is able to change ownerships, so setting this option to true as a regular user may have no effect. |
:times |
When set to false (the default), last accessed and last modified times will be ignored. Otherwise, they will be restored if possible. |
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 |
# File 'lib/archive/zip/entry.rb', line 852 def extract( = {}) # Ensure that unspecified options have default values. file_path = .has_key?(:file_path) ? [:file_path].to_s : @zip_path = .has_key?(:permissions) ? [:permissions] : false restore_ownerships = .has_key?(:ownerships) ? [:ownerships] : false restore_times = .has_key?(:times) ? [:times] : false # Make the directory. FileUtils.mkdir_p(file_path) # Restore the metadata. ::File.chmod(mode, file_path) if ::File.chown(uid, gid, file_path) if restore_ownerships ::File.utime(atime, mtime, file_path) if restore_times nil end |
- (Object) ftype
Returns the file type of this entry as the symbol :directory.
820 821 822 |
# File 'lib/archive/zip/entry.rb', line 820 def ftype :directory end |
- (Object) mode=(mode)
Overridden in order to ensure that the proper mode bits are set for a directory.
831 832 833 |
# File 'lib/archive/zip/entry.rb', line 831 def mode=(mode) super(040000 | (mode & 07777)) end |
- (Object) zip_path=(zip_path)
Inherits the behavior of Archive::Zip::Entry#zip_path= but ensures that there is a trailing slash (/) on the end of the path.
814 815 816 817 |
# File 'lib/archive/zip/entry.rb', line 814 def zip_path=(zip_path) super(zip_path) @zip_path += '/' end |