lib/zipr/sfx.rb
def create(source_folder, files_to_add: nil, info_hash: nil)
      changed_files = determine_files_to_add(source_folder, files_to_check: files_to_add)
      if changed_files.empty? && ::File.exist?(@sfx_path)
        EasyIO.logger.info 'No files in the SFX have changed. Skipping SFX creation.'
        return [@checksum_path, @checksums]
      end
      EasyIO.logger.info "Creating SFX archive: #{sfx_path}"
      add(source_folder, files_to_add: files_to_add)
      use_info_file = !(info_hash.nil? || info_hash.empty?)
      generate_info_file(info_hash) if use_info_file
      sfx_module = "#{__dir__}/#{use_info_file ? '7zsd_All.sfx' : '7zS2.sfx'}"
      sfx_components = [sfx_module] # Start with the module
      sfx_components.push("#{sfx_cache_path}/sfx_info.txt") if ::File.exist?("#{sfx_cache_path}/sfx_info.txt") # Add the info file if it exists
      sfx_components.push(@path) # Add the temporary .7z archive
      ::File.open(sfx_path, 'wb') do |sfx_archive|
        sfx_components.each do |file|
          EasyIO.logger.debug "Adding #{file} to SFX"
          sfx_archive.write(::File.open(file, 'rb').read)
        end
      end
      EasyIO.logger.info 'SFX created successfully.'
      [@checksum_path, update_checksum_file]
    ensure
      cleanup unless @skip_cleanup
    end
#
# Description:
#   Create the SFX package
# Returns:
#   Array of 2 objects: String path to the checksum file and the hash of known checksums for archive files.
# Parameters:
#   source_folder: The path from which relative archive paths will be derived.
#   files_to_add: An array of files to be added to the SFX archive. Relative or full paths accepted. Wildcards accepted. If omitted, takes all files and folders in the source_folder.
#   info_hash: (optional) A hash containing the installer config info file. See comments for method 'generate_info_file' for more information.
Create the SFX package
Returns:
Array of 2 objects: String path to the checksum file and the hash of known checksums for archive files.
Parameters:
source_folder: The path from which relative archive paths will be derived.
files_to_add: An array of files to be added to the SFX archive. Relative or full paths accepted. Wildcards accepted. If omitted, takes all files and folders in the source_folder.
info_hash: (optional) A hash containing the installer config info file. See comments for method 'generate_info_file' for more information.
Create the SFX package Returns : Array of 2 objects : String path to the checksum file and the hash of known checksums for archive files . Parameters : source_folder : The path from which relative archive paths will be derived . files_to_add : An array of files to be added to the SFX archive . Relative or full paths accepted . Wildcards accepted . If omitted takes all files and folders in the source_folder . info_hash : ( optional ) A hash containing the installer config info file . See comments for method ' generate_info_file ' for more information .
def create(source_folder, files_to_add: nil, info_hash: nil)
      changed_files = determine_files_to_add(source_folder, files_to_check: files_to_add)
      if changed_files.empty? && ::File.exist?(@sfx_path)
        EasyIO.logger.info 'No files in the SFX have changed. Skipping SFX creation.'
        return [@checksum_path, @checksums]
      end
      EasyIO.logger.info "Creating SFX archive: #{sfx_path}"
      add(source_folder, files_to_add: files_to_add)
      use_info_file = !(info_hash.nil? || info_hash.empty?)
      generate_info_file(info_hash) if use_info_file
      sfx_module = "#{__dir__}/#{use_info_file ? '7zsd_All.sfx' : '7zS2.sfx'}"
      sfx_components = [sfx_module] 
      sfx_components.push("#{sfx_cache_path}/sfx_info.txt") if ::File.exist?("#{sfx_cache_path}/sfx_info.txt") 
      sfx_components.push(@path) 
      ::File.open(sfx_path, 'wb') do |sfx_archive|
        sfx_components.each do |file|
          EasyIO.logger.debug "Adding #{file} to SFX"
          sfx_archive.write(::File.open(file, 'rb').read)
        end
      end
      EasyIO.logger.info 'SFX created successfully.'
      [@checksum_path, update_checksum_file]
    ensure
      cleanup unless @skip_cleanup
    end
def create ( source_folder , files_to_add : nil , info_hash : nil ) changed_files = determine_files_to_add ( source_folder , files_to_check : files_to_add ) if changed_files . empty? && :: File . exist? ( @sfx_path ) EasyIO . logger . info 'No files in the SFX have changed. Skipping SFX creation.' return [ @checksum_path , @checksums ] end EasyIO . logger . info "Creating SFX archive: #{sfx_path}" add ( source_folder , files_to_add : files_to_add ) use_info_file = ! ( info_hash . nil? || info_hash . empty? ) generate_info_file ( info_hash ) if use_info_file sfx_module = "#{__dir__}/#{use_info_file ? '7zsd_All.sfx' : '7zS2.sfx'}" sfx_components = [ sfx_module ] sfx_components . push ( "#{sfx_cache_path}/sfx_info.txt" ) if :: File . exist? ( "#{sfx_cache_path}/sfx_info.txt" ) sfx_components . push ( @path ) :: File . open ( sfx_path , 'wb' ) do | sfx_archive | sfx_components . each do | file | EasyIO . logger . debug "Adding #{file} to SFX" sfx_archive . write ( :: File . open ( file , 'rb' ) . read ) end end EasyIO . logger . info 'SFX created successfully.' [ @checksum_path , update_checksum_file ] ensure cleanup unless @skip_cleanup end
Description:
Create the SFX package
Returns:
Array of 2 objects: String path to the checksum file and the hash of known checksums for archive files.
Description : Create the SFX package Returns : Array of 2 objects : String path to the checksum file and the hash of known checksums for archive files .
# Start with the module # Add the info file if it exists # Add the temporary .7z archive
source_folder
files_to_add
info_hash