Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
838 B

  1. #!/usr/bin/perl
  2. # $RCSfile: empty,v $$Revision: 4.1 $$Date: 92/08/07 17:20:50 $
  3. # This script empties a trashcan.
  4. $recursive = shift if $ARGV[0] eq '-r';
  5. @ARGV = '.' if $#ARGV < 0;
  6. chop($pwd = `pwd`);
  7. dir: foreach $dir (@ARGV) {
  8. unless (chdir $dir) {
  9. print stderr "Can't find directory $dir: $!\n";
  10. next dir;
  11. }
  12. if ($recursive) {
  13. do cmd('find . -name .deleted -exec /bin/rm -rf {} ;');
  14. }
  15. else {
  16. if (-d '.deleted') {
  17. do cmd('rm -rf .deleted');
  18. }
  19. else {
  20. if ($dir eq '.' && $pwd =~ m|/\.deleted$|) {
  21. chdir '..';
  22. do cmd('rm -rf .deleted');
  23. }
  24. else {
  25. print stderr "No trashcan found in directory $dir\n";
  26. }
  27. }
  28. }
  29. }
  30. continue {
  31. chdir $pwd;
  32. }
  33. # force direct execution with no shell
  34. sub cmd {
  35. system split(' ',join(' ',@_));
  36. }