|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the LGPL. For more information please see |
|
17
|
|
|
* <http://phing.info>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Task to create a directory. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Andreas Aderhold, [email protected] |
|
24
|
|
|
* @package phing.tasks.system |
|
25
|
|
|
*/ |
|
26
|
|
|
class MkdirTask extends Task |
|
27
|
|
|
{ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Directory to create. |
|
31
|
|
|
* |
|
32
|
|
|
* @var PhingFile $dir |
|
33
|
|
|
*/ |
|
34
|
|
|
private $dir; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Mode to create directory with |
|
38
|
|
|
* |
|
39
|
|
|
* @var integer|null |
|
40
|
|
|
*/ |
|
41
|
|
|
private $mode = null; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* create the directory and all parents |
|
45
|
|
|
* |
|
46
|
|
|
* @throws BuildException if dir is somehow invalid, or creation failed. |
|
47
|
|
|
*/ |
|
48
|
142 |
|
public function main() |
|
49
|
|
|
{ |
|
50
|
142 |
|
if ($this->dir === null) { |
|
51
|
|
|
throw new BuildException("dir attribute is required", $this->getLocation()); |
|
52
|
|
|
} |
|
53
|
142 |
|
if ($this->dir->isFile()) { |
|
54
|
|
|
throw new BuildException( |
|
55
|
|
|
"Unable to create directory as a file already exists with that name: " . $this->dir->getAbsolutePath() |
|
56
|
|
|
); |
|
57
|
|
|
} |
|
58
|
142 |
|
if (!$this->dir->exists()) { |
|
59
|
136 |
|
$result = $this->dir->mkdirs($this->mode); |
|
60
|
136 |
|
if (!$result) { |
|
61
|
|
|
if ($this->dir->exists()) { |
|
62
|
|
|
$this->log("A different process or task has already created " . $this->dir->getAbsolutePath()); |
|
63
|
|
|
|
|
64
|
|
|
return; |
|
65
|
|
|
} |
|
66
|
|
|
$msg = "Directory " . $this->dir->getAbsolutePath() . " creation was not successful for an unknown reason"; |
|
67
|
|
|
throw new BuildException($msg, $this->getLocation()); |
|
68
|
|
|
} |
|
69
|
136 |
|
$this->log("Created dir: " . $this->dir->getAbsolutePath()); |
|
70
|
|
|
} else { |
|
71
|
12 |
|
$this->log( |
|
72
|
12 |
|
'Skipping ' . $this->dir->getAbsolutePath() . ' because it already exists.', |
|
73
|
12 |
|
Project::MSG_VERBOSE |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
142 |
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* The directory to create; required. |
|
80
|
|
|
* |
|
81
|
|
|
* @param PhingFile $dir |
|
82
|
|
|
* @return void |
|
83
|
|
|
*/ |
|
84
|
142 |
|
public function setDir(PhingFile $dir) |
|
85
|
|
|
{ |
|
86
|
142 |
|
$this->dir = $dir; |
|
87
|
142 |
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Sets mode to create directory with |
|
91
|
|
|
* |
|
92
|
|
|
* @param mixed $mode |
|
93
|
|
|
* @return void |
|
94
|
|
|
*/ |
|
95
|
5 |
|
public function setMode($mode) |
|
96
|
|
|
{ |
|
97
|
5 |
|
$this->mode = base_convert((int) $mode, 8, 10); |
|
|
|
|
|
|
98
|
5 |
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..