Add .localized to undeletable macOS paths.

This commit is contained in:
Markus Reiter 2018-04-14 07:33:34 +02:00
parent cb5684831e
commit 68eef4c74e

View File

@ -238,26 +238,35 @@ module OS
# TODO: There should be a way to specify a containing # TODO: There should be a way to specify a containing
# directory under which nothing can be deleted. # directory under which nothing can be deleted.
UNDELETABLE_DIRS = [ UNDELETABLE_PATHS = [
"~/", "~/",
"~/Applications", "~/Applications",
"~/Applications/.localized",
"~/Desktop", "~/Desktop",
"~/Desktop/.localized",
"~/Documents", "~/Documents",
"~/Documents/.localized",
"~/Downloads", "~/Downloads",
"~/Downloads/.localized",
"~/Mail", "~/Mail",
"~/Movies", "~/Movies",
"~/Movies/.localized",
"~/Music", "~/Music",
"~/Music/.localized",
"~/Music/iTunes", "~/Music/iTunes",
"~/Music/iTunes/iTunes Music", "~/Music/iTunes/iTunes Music",
"~/Music/iTunes/Album Artwork", "~/Music/iTunes/Album Artwork",
"~/News", "~/News",
"~/Pictures", "~/Pictures",
"~/Pictures/.localized",
"~/Pictures/Desktops", "~/Pictures/Desktops",
"~/Pictures/Photo Booth", "~/Pictures/Photo Booth",
"~/Pictures/iChat Icons", "~/Pictures/iChat Icons",
"~/Pictures/iPhoto Library", "~/Pictures/iPhoto Library",
"~/Public", "~/Public",
"~/Public/.localized",
"~/Sites", "~/Sites",
"~/Sites/.localized",
"~/Library", "~/Library",
"~/Library/.localized", "~/Library/.localized",
"~/Library/Accessibility", "~/Library/Accessibility",
@ -364,7 +373,7 @@ module OS
"~/Library/Widgets", "~/Library/Widgets",
"~/Library/Workflows", "~/Library/Workflows",
] ]
.map { |x| Pathname(x.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path } .map { |path| Pathname(path.sub(%r{^~(?=(/|$))}, Dir.home)).expand_path }
.to_set .to_set
.union(SYSTEM_DIRS) .union(SYSTEM_DIRS)
.freeze .freeze
@ -373,8 +382,8 @@ module OS
SYSTEM_DIRS.include?(Pathname.new(dir).expand_path) SYSTEM_DIRS.include?(Pathname.new(dir).expand_path)
end end
def undeletable?(dir) def undeletable?(path)
UNDELETABLE_DIRS.include?(Pathname.new(dir).expand_path) UNDELETABLE_PATHS.include?(Pathname.new(path).expand_path)
end end
end end
end end