fixed directory check to use POSIX macros