#include #include #include int main(int argc, char* argv[]) { char* file = argv[1]; FILE* fp = fopen(file, "wb+"); if (!fp) { printf("fopen(%s) failed with errno = %d\n", file, errno); return 1; } int status = remove(file); if (status < 0) { printf("remove(%s) failed with errno = %d\n", file, errno); return 2; } struct stat buf; status = fstat(fileno(fp), &buf); if (status < 0) printf("fstat() failed with errno = %d\n", errno); if (S_ISDIR(buf.st_mode)) printf("dir\n"); else printf("not dir\n"); return 0; }