mkvtoolnix/packaging/windows/file_list_to_nsi_uninstaller_instructions.rb
Moritz Bunkus ab6455f68c
build system: fix compatibility with Ruby 3.2.0
Several deprecated functions were removed: `Dir.exists?`,
`File.exists?` & `FileTest.exists?`.  Instead of those
`FileTest.exist?` must be used (without the `s`). See the release
notes for Ruby 3.2.0 as well as the issue for removing the functions:

https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/
https://bugs.ruby-lang.org/issues/17391
2023-01-02 22:57:21 +01:00

33 lines
708 B
Ruby
Executable File

#!/usr/bin/env ruby
require "pp"
require_relative "conf"
fail "Missing file list name" if ARGV.empty?
config = read_config
file_name = ARGV[0]
file_name = "#{config['file_list_dir']}/#{file_name}.txt" if !FileTest.exist?(file_name)
files = IO.readlines(file_name).map { |file| file.chomp.gsub(%r{^\.}, '').gsub(%r{^/}, '').gsub(%r{/}, '\\') }
dirs = {}
files.each do |file|
puts %Q( Delete "$INSTDIR\\#{file}")
dir = file
while true
break unless %r{\\}.match(file)
dir.gsub!(%r{\\[^\\]+$}, '')
dirs[dir] = true
end
end
puts
dirs.
keys.
sort_by { |dir| [ dir.gsub(%r{[^\\]+}, '').length, dir ] }.
reverse.
each { |dir| puts %Q( RMDir "$INSTDIR\\#{dir}") }