
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <stdio.h>
#else
#include <unistd.h>
#endif

int     main(int argc, char *argv[]){
    struct stat stbuf;

    if(argc < 2){
	printf("usage: %s directory\n");
        return 1;
    }

    if(stat(argv[1], &stbuf)){
        printf("\"%s\" doesn't exist or no permission.\n", argv[1]);
	return 1;
    }

    if(((stbuf.st_mode & S_IFMT) == S_IFDIR) ? 1 : 0){
	printf("\"%s\" is a directory\n", argv[1]);
    }
    else {
	printf("\"%s\" is not a directory\n", argv[1]);
    }

    return 0;
}

