Added realpath to dirname usages

Same as #766, but for the v1.1 branch