I think this looks fine to determine if this is a file page.  I don't think you need to check if NS_FILE is defined though.  I see a lot of places in core that determine if its a file page with just the second condition of this "if"