]>
Commit | Line | Data |
---|---|---|
e0a65194 RS |
1 | #! /usr/bin/env perl |
2 | # Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. | |
3 | # | |
9059ab42 | 4 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
e0a65194 RS |
5 | # this file except in compliance with the License. You can obtain a copy |
6 | # in the file LICENSE in the source distribution or at | |
7 | # https://www.openssl.org/source/license.html | |
6576774b BM |
8 | |
9 | # On some systems, the -p option to mkdir (= also create any missing parent | |
10 | # directories) is not available. | |
11 | ||
12 | my $arg; | |
13 | ||
14 | foreach $arg (@ARGV) { | |
fbf002bb | 15 | $arg =~ tr|\\|/|; |
6576774b BM |
16 | &do_mkdir_p($arg); |
17 | } | |
18 | ||
19 | ||
20 | sub do_mkdir_p { | |
21 | local($dir) = @_; | |
22 | ||
eabea024 | 23 | $dir =~ s|/*\Z(?!\n)||s; |
6576774b BM |
24 | |
25 | if (-d $dir) { | |
26 | return; | |
27 | } | |
28 | ||
eabea024 | 29 | if ($dir =~ m|[^/]/|s) { |
6576774b | 30 | local($parent) = $dir; |
eabea024 | 31 | $parent =~ s|[^/]*\Z(?!\n)||s; |
6576774b BM |
32 | |
33 | do_mkdir_p($parent); | |
34 | } | |
35 | ||
70a56b91 SAS |
36 | unless (mkdir($dir, 0777)) { |
37 | if (-d $dir) { | |
38 | # We raced against another instance doing the same thing. | |
39 | return; | |
40 | } | |
41 | die "Cannot create directory $dir: $!\n"; | |
42 | } | |
eabea024 | 43 | print "created directory `$dir'\n"; |
6576774b | 44 | } |