Allow toPath to be null in copyObject()