Use stat to check for a path rather than ls

This is more consistent and less error prone.
Merge pull request #28 from nickjj/inventory

Use stat to check for a path rather than ls