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