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.

66 lines
1.4 KiB

  1. #!/usr/bin/perl
  2. # $RCSfile: unvanish,v $$Revision: 4.1 $$Date: 92/08/07 17:20:52 $
  3. sub it {
  4. if ($olddir ne '.') {
  5. chop($pwd = `pwd`) if $pwd eq '';
  6. (chdir $olddir) || die "Directory $olddir is not accesible";
  7. }
  8. unless ($olddir eq '.deleted') {
  9. if (-d '.deleted') {
  10. chdir '.deleted' || die "Directory .deleted is not accesible";
  11. }
  12. else {
  13. chop($pwd = `pwd`) if $pwd eq '';
  14. die "Directory .deleted does not exist" unless $pwd =~ /\.deleted$/;
  15. }
  16. }
  17. print `mv $startfiles$filelist..$force`;
  18. if ($olddir ne '.') {
  19. (chdir $pwd) || die "Can't get back to original directory $pwd: $!\n";
  20. }
  21. }
  22. if ($#ARGV < 0) {
  23. open(lastcmd,'.deleted/.lastcmd') ||
  24. open(lastcmd,'.lastcmd') ||
  25. die "No previous vanish in this dir";
  26. $ARGV = <lastcmd>;
  27. close(lastcmd);
  28. @ARGV = split(/[\n ]+/,$ARGV);
  29. }
  30. while ($ARGV[0] =~ /^-/) {
  31. $_ = shift;
  32. /^-f/ && ($force = ' >/dev/null 2>&1');
  33. /^-i/ && ($interactive = 1);
  34. if (/^-+$/) {
  35. $startfiles = '- ';
  36. last;
  37. }
  38. }
  39. while ($file = shift) {
  40. if ($file =~ s|^(.*)/||) {
  41. $dir = $1;
  42. }
  43. else {
  44. $dir = '.';
  45. }
  46. if ($dir ne $olddir) {
  47. do it() if $olddir;
  48. $olddir = $dir;
  49. }
  50. if ($interactive) {
  51. print "unvanish: restore $dir/$file? ";
  52. next unless <stdin> =~ /^y/i;
  53. }
  54. $filelist .= $file; $filelist .= ' ';
  55. }
  56. do it() if $olddir;