Added #include <libgen.h>