test610.pl 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.haxx.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. ###########################################################################
  23. # Perform simple file and directory manipulation in a portable way
  24. if ( $#ARGV <= 0 )
  25. {
  26. print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n";
  27. exit 1;
  28. }
  29. use File::Copy;
  30. while(@ARGV) {
  31. my $cmd = shift @ARGV;
  32. my $arg = shift @ARGV;
  33. if ($cmd eq "mkdir") {
  34. mkdir $arg || die "$!";
  35. }
  36. elsif ($cmd eq "rmdir") {
  37. rmdir $arg || die "$!";
  38. }
  39. elsif ($cmd eq "rm") {
  40. unlink $arg || die "$!";
  41. }
  42. elsif ($cmd eq "move") {
  43. my $arg2 = shift @ARGV;
  44. move($arg,$arg2) || die "$!";
  45. }
  46. elsif ($cmd eq "gone") {
  47. ! -e $arg || die "Path $arg exists";
  48. } else {
  49. print "Unsupported command $cmd\n";
  50. exit 1;
  51. }
  52. }
  53. exit 0;