2024-06-07 18:16:15 +09:00
|
|
|
# typed: true
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Utils
|
|
|
|
module Cp
|
|
|
|
class << self
|
|
|
|
module MacOSOverride
|
|
|
|
private
|
|
|
|
|
|
|
|
# Use the lightweight `clonefile(2)` syscall if applicable.
|
|
|
|
SONOMA_FLAGS = ["-c"].freeze
|
|
|
|
|
2024-06-09 05:54:36 +09:00
|
|
|
sig { returns(T.nilable(T::Array[String])) }
|
2024-06-07 18:16:15 +09:00
|
|
|
def extra_flags
|
|
|
|
# The `cp` command on older macOS versions also had the `-c` option, but before Sonoma,
|
|
|
|
# the command would fail if the `clonefile` syscall isn't applicable (the underlying
|
|
|
|
# filesystem doesn't support the feature or the source and the target are on different
|
|
|
|
# filesystems).
|
2024-06-09 05:54:36 +09:00
|
|
|
return if MacOS.version < :sonoma
|
|
|
|
|
|
|
|
SONOMA_FLAGS
|
2024-06-07 18:16:15 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
prepend MacOSOverride
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|