Detect (and set) file type.