Bug 50987: Use a directory variable instead of calling repeatedly.

Storing $dir = __DIR__, then using that instead of using __DIR__
repeatedly.

Bug: 50987
Change-Id: Id81a701c22c61526cc53e5d3a91263d1b7c6824c