2022-10-11 00:52:32 +01:00
|
|
|
# typed: true
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-05-26 08:46:38 +09:00
|
|
|
require "utils/cp"
|
|
|
|
|
2018-07-23 20:59:21 +02:00
|
|
|
module UnpackStrategy
|
2020-08-09 06:09:05 +02:00
|
|
|
# Strategy for unpacking uncompressed files.
|
2018-07-23 20:59:21 +02:00
|
|
|
class Uncompressed
|
|
|
|
include UnpackStrategy
|
|
|
|
|
2023-02-22 22:15:26 +01:00
|
|
|
sig {
|
|
|
|
params(
|
|
|
|
to: T.nilable(Pathname),
|
|
|
|
basename: T.nilable(T.any(String, Pathname)),
|
|
|
|
verbose: T::Boolean,
|
|
|
|
prioritize_extension: T::Boolean,
|
|
|
|
).returns(T.untyped)
|
|
|
|
}
|
|
|
|
def extract_nestedly(to: nil, basename: nil, verbose: false, prioritize_extension: false)
|
2024-03-07 16:20:20 +00:00
|
|
|
extract(to:, basename:, verbose:)
|
2018-07-30 22:23:26 +02:00
|
|
|
end
|
2018-07-23 20:59:21 +02:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
|
2023-02-22 22:15:26 +01:00
|
|
|
def extract_to_dir(unpack_dir, basename:, verbose: false)
|
2024-06-08 06:21:13 +09:00
|
|
|
Utils::Cp.with_attributes path, unpack_dir/basename.sub(/^[\da-f]{64}--/, ""), verbose:
|
2018-07-23 20:59:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|