The answer in http://stackoverflow.com/questions/2281531/how-can-i-compare-directory-paths-in-c has pretty good code.