In my line of work, I'm constantly asked to remove malware. I've come up with an concept for program that would check file attributes, sort the files into necessary and unnecessary and then remove unnecessary files.
My basic algorithm is as follows:
1-(Im in the process of writing master lists of the standard windows files after a fresh install of windows)
2- Sort files, (system32, Windows directories) (probably end up being selection sort)
2a- Compare all files in directory to master lists
3a-If file not equal to (any file from the master list)
then delete file
Bare in mind this is a rough outline and im constantly thinking of ways to change it and improve it...
You don't really need to sort files files. Just put them into a set or unordered_set.
But the real problem is step #1: creating the master list of files. What about new files that appear with updates? What about drivers for all the different hardware devices? What about files in other directories? So the real question is "how do you know if a file is supposed to be there?" Also, even if it's supposed to be there, how do you know it's the right file vs. a modified one that contains a virus?
I think you're basically reinventing the virus scanner. Better to use a commercially available version.