Skip to content

Instantly share code, notes, and snippets.

@stek29
Created February 25, 2018 14:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stek29/5bfa87fb57f028de2720cac71728a203 to your computer and use it in GitHub Desktop.
Save stek29/5bfa87fb57f028de2720cac71728a203 to your computer and use it in GitHub Desktop.
  • remove all packages except core ones which are dangerous to remove
  • iterate over .list files, build list of all files to be removed
  • filter out some critical from those
  • remove all files and empty directories which are in that list from disk, pop them from that list on removal
  • keep doing previous step until list is empty, or there are no empty directories left in it
  • print out list leftovers and ask user to handle them manually
const char* FILE_BLACKLIST[] = {
// These most likely won't be empty anyway
"Applications",
"Library",
"Library/Frameworks",
"Library/Ringtones",
"Library/Wallpaper",
"System",
"System/Library",
"System/Library/Extensions",
"System/Library/Fonts",
"System/Library/Frameworks",
"System/Library/LaunchDaemons",
"System/Library/PreferenceBundles",
"System/Library/PrivateFrameworks",
"System/Library/SystemConfiguration",
"bin",
"dev",
"sbin",
"usr",
"usr/bin",
"usr/lib",
"usr/libexec",
"usr/local",
"usr/sbin",
"usr/share",
"usr/share/misc",
"var/db",
"var/log",
"var/logs",
"var/mobile",
"var/mobile/Library",
"var/mobile/Library/Preferences",
"var/mobile/Media",
"var/msgs",
"var/preferences",
"var/root",
"var/run",
"var/tmp",
// These are empty dirs
"var/empty",
"var/vm",
"System/Library/VideoDecoders",
"Library/LaunchAgents",
// And symlinks
"Library/Preferences",
"etc",
"tmp",
"var",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment