Update ooo320-m1
[ooovba.git] / solenv / bin / mkdir.pl
blob0e48d92ad26fb5041104b8fb3dab60963cff3eec
1 : # -*- perl -*-
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
5 # mkdir - a perl script to substitute mkdir -p
6 # accepts "/", ":", and "\" as delimiters of subdirectories
7 # options -p (for compatibility)
8 # -mode mode
10 # Copyright (c) 2000 Sun Microsystems, Inc.
12 use Cwd;
14 $currdir = cwd;
16 $MODE = 00777 ;
18 while ( $#ARGV >= 0 ) {
19 if ( $ARGV[0] eq "-mode" ) {
20 $MODE = oct $ARGV[1] ;
21 shift @ARGV ;
22 shift @ARGV ;
24 elsif ( $ARGV[0] eq "-p" ) {
25 shift @ARGV ;
26 # -p does not do anything, it's supported just for compatibility
28 else {
30 $ARGV[0] =~ s?\\|:?/?g ;
31 @SUBDIRS = split "/", $ARGV[0] ;
33 # absolute path UNIX
34 if ( $SUBDIRS[0] eq "" ) {
35 chdir '/' ;
36 shift @SUBDIRS ;
38 # absolute path WINDOWS
39 if ( $#SUBDIRS > 1 ) {
40 if ( $SUBDIRS[1] eq "" ) {
41 if ( $SUBDIRS[0] =~ /\w/ ) {
42 chdir "$SUBDIRS[0]:\\" ;
43 shift @SUBDIRS ;
44 shift @SUBDIRS ;
45 } ;
46 } ;
49 while (@SUBDIRS) {
50 if ( -e $SUBDIRS[0] ) {
51 if ( ! -d $SUBDIRS[0] ) {
52 die "file exists\n"
55 else {
56 mkdir $SUBDIRS[0], $MODE or die "Can't create directory $SUBDIRS[0]"
58 chdir $SUBDIRS[0] or die "Can't cd to $SUBDIRS[0]" ;
59 shift @SUBDIRS ;
60 } ;
62 shift @ARGV ;
63 } ;
64 chdir $currdir;