Minor native code cleanup

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
Prevent crash on null directory

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>