2 namespace TYPO3\CMS\Install\FolderStructure;
17 use TYPO3\CMS\Install\Status;
44 throw new Exception\InvalidArgumentException(
45 'File node must have parent',
52 if (strstr($structure[
'name'],
'/') !==
false) {
53 throw new Exception\InvalidArgumentException(
54 'File name must not contain forward slash',
58 $this->name = $structure[
'name'];
60 if (isset($structure[
'targetPermission'])) {
64 if (isset($structure[
'targetContent']) && isset($structure[
'targetContentFile'])) {
65 throw new Exception\InvalidArgumentException(
66 'Either targetContent or targetContentFile can be set, but not both',
71 if (isset($structure[
'targetContent'])) {
72 $this->targetContent = $structure[
'targetContent'];
74 if (isset($structure[
'targetContentFile'])) {
75 if (!is_readable($structure[
'targetContentFile'])) {
76 throw new Exception\InvalidArgumentException(
77 'targetContentFile ' . $structure[
'targetContentFile'] .
' does not exist or is not readable',
81 $this->targetContent = file_get_contents($structure[
'targetContentFile']);
98 $status->setMessage(
'By using "Try to fix errors" we can try to create it');
129 $result[] = $resultCreateFile;
130 if ($resultCreateFile instanceof Status\
OkStatus
131 && !is_null($this->targetContent)
145 ' but is of type ' . $fileType .
'. This cannot be fixed automatically. Please investigate.'
150 ' but is of unknown type, probably because an upper level directory does not exist. Please investigate.'
175 if ($result ===
true) {
182 'The target file could not be created. There is probably a' .
183 ' group or owner permission problem on the parent directory.'
225 'File content is not identical to default content. This file may have been changed manually.' .
226 ' The Install Tool will not overwrite the current version!'
233 'Is a file with the default content and configured permissions of ' . $this->
getTargetPermission()
249 if (is_link($absolutePath) || !is_file($absolutePath)) {
251 'File ' . $absolutePath .
' must exist',
256 if (is_null($this->targetContent)) {
259 $targetContentHash = md5($this->targetContent);
260 $currentContentHash = md5(file_get_contents($absolutePath));
261 if ($targetContentHash === $currentContentHash) {
277 if (is_link($absolutePath) || !is_file($absolutePath)) {
279 'File ' . $absolutePath .
' must exist',
283 if (is_null($this->targetContent)) {
285 'Target content not defined for ' . $absolutePath,
289 $result = @file_put_contents($absolutePath, $this->targetContent);
290 if ($result !==
false) {
296 $status->setMessage(
'Setting content of the file failed for unknown reasons.');
309 return (!is_link($path) && is_file($path));