Displaying 1 result from an estimated 1 matches for "unlink_direntry".
Did you mean:
unlink_directory
2004 Sep 05
1
[PATCH] simple rm command
...stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+
+#include <linux/limits.h>
+
+static char *progname;
+static int f_opt, r_opt;
+
+static int recursive_rm(const char *path);
+
+static int unlink_direntry(const char *p)
+{
+ struct stat sb;
+ int ret;
+
+ if (lstat(p, &sb) < 0) {
+ ret = 1;
+ if (!f_opt)
+ perror(p);
+ goto out;
+ }
+
+ if (S_ISDIR(sb.st_mode) && r_opt)
+ ret = recursive_rm(p);
+ else {
+ if (unlink(p) < 0) {
+ ret = 1;
+ if (!f_opt)
+ perror(p);
+ }...