test610.pl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2022, 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.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. # SPDX-License-Identifier: curl
  23. #
  24. ###########################################################################
  25. # Perform simple file and directory manipulation in a portable way
  26. if ( $#ARGV <= 0 )
  27. {
  28. print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n";
  29. exit 1;
  30. }
  31. use File::Copy;
  32. while(@ARGV) {
  33. my $cmd = shift @ARGV;
  34. my $arg = shift @ARGV;
  35. if ($cmd eq "mkdir") {
  36. mkdir $arg || die "$!";
  37. }
  38. elsif ($cmd eq "rmdir") {
  39. rmdir $arg || die "$!";
  40. }
  41. elsif ($cmd eq "rm") {
  42. unlink $arg || die "$!";
  43. }
  44. elsif ($cmd eq "move") {
  45. my $arg2 = shift @ARGV;
  46. move($arg,$arg2) || die "$!";
  47. }
  48. elsif ($cmd eq "gone") {
  49. ! -e $arg || die "Path $arg exists";
  50. } else {
  51. print "Unsupported command $cmd\n";
  52. exit 1;
  53. }
  54. }
  55. exit 0;