Detect file type if none given.