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 24if ( $#ARGV <= 0 ) 25{ 26 print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n"; 27 exit 1; 28} 29 30use File::Copy; 31while(@ARGV) { 32 my $cmd = shift @ARGV; 33 my $arg = shift @ARGV; 34 if ($cmd eq "mkdir") { 35 mkdir $arg || die "$!"; 36 } 37 elsif ($cmd eq "rmdir") { 38 rmdir $arg || die "$!"; 39 } 40 elsif ($cmd eq "rm") { 41 unlink $arg || die "$!"; 42 } 43 elsif ($cmd eq "move") { 44 my $arg2 = shift @ARGV; 45 move($arg,$arg2) || die "$!"; 46 } 47 elsif ($cmd eq "gone") { 48 ! -e $arg || die "Path $arg exists"; 49 } else { 50 print "Unsupported command $cmd\n"; 51 exit 1; 52 } 53} 54exit 0; 55