vendor/bundle/ruby/2.7.0/gems/rubyzip-2.3.0/lib/zip/file.rb
# Splits an archive into parts with segment size
Splits an archive into parts with segment size
Splits an archive into parts with segment size
def split(zip_file_name, segment_size = MAX_SEGMENT_SIZE, delete_zip_file = true, partial_zip_file_name = nil)
        raise Error, "File #{zip_file_name} not found" unless ::File.exist?(zip_file_name)
        raise Errno::ENOENT, zip_file_name unless ::File.readable?(zip_file_name)
        zip_file_size = ::File.size(zip_file_name)
        segment_size  = get_segment_size_for_split(segment_size)
        return if zip_file_size <= segment_size
        segment_count = get_segment_count_for_split(zip_file_size, segment_size)
        ::Zip::File.open(zip_file_name) {}
        partial_zip_file_name = get_partial_zip_file_name(zip_file_name, partial_zip_file_name)
        szip_file_index       = 0
        ::File.open(zip_file_name, 'rb') do |zip_file|
          until zip_file.eof?
            szip_file_index += 1
            save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)
          end
        end
        ::File.delete(zip_file_name) if delete_zip_file
        szip_file_index
      end
def split ( zip_file_name , segment_size = MAX_SEGMENT_SIZE , delete_zip_file = true , partial_zip_file_name = nil ) raise Error , "File #{zip_file_name} not found" unless :: File . exist? ( zip_file_name ) raise Errno :: ENOENT , zip_file_name unless :: File . readable? ( zip_file_name ) zip_file_size = :: File . size ( zip_file_name ) segment_size = get_segment_size_for_split ( segment_size ) return if zip_file_size <= segment_size segment_count = get_segment_count_for_split ( zip_file_size , segment_size ) :: Zip :: File . open ( zip_file_name ) { } partial_zip_file_name = get_partial_zip_file_name ( zip_file_name , partial_zip_file_name ) szip_file_index = 0 :: File . open ( zip_file_name , 'rb' ) do | zip_file | until zip_file . eof? szip_file_index += 1 save_splited_part ( zip_file , partial_zip_file_name , zip_file_size , szip_file_index , segment_size , segment_count ) end end :: File . delete ( zip_file_name ) if delete_zip_file szip_file_index end
Splits an archive into parts with segment size
Splits an archive into parts with segment size
# Checking for correct zip structure
zip_file_name
<not_specific>
segment_size
<not_specific>
delete_zip_file
<not_specific>
partial_zip_file_name
<not_specific>