Guest User

Untitled

a guest
Aug 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. reverse rmdir in c [closed]
  2. rm -rf <path-to-directory>/*
  3.  
  4. #define _XOPEN_SOURCE 500
  5. #include <stdio.h>
  6. #include <ftw.h>
  7. #include <unistd.h>
  8.  
  9. int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
  10. {
  11. int rv = remove(fpath);
  12.  
  13. if (rv)
  14. perror(fpath);
  15.  
  16. return rv;
  17. }
  18.  
  19. int rmrf(char *path)
  20. {
  21. return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS);
  22. }
  23.  
  24. system ("rm -rf <path-to-directory>");
Add Comment
Please, Sign In to add comment