| @@ 106-128 (lines=23) @@ | ||
| 103 | * |
|
| 104 | * @return SplFileInfo |
|
| 105 | */ |
|
| 106 | public function writeFile($relativePath, $content) |
|
| 107 | { |
|
| 108 | $outputFolder = $this->fs->getFolderPath($relativePath); |
|
| 109 | $targetFileName = $this->fs->getFileName($outputFolder); |
|
| 110 | ||
| 111 | $absoluteFolderPath = $this->buildPath($this->getCwd(), $outputFolder); |
|
| 112 | ||
| 113 | if (!file_exists($absoluteFolderPath)) |
|
| 114 | { |
|
| 115 | mkdir($absoluteFolderPath, 0755, true); |
|
| 116 | } |
|
| 117 | ||
| 118 | file_put_contents( |
|
| 119 | $this->buildPath($this->getCwd(), $relativePath), |
|
| 120 | $content |
|
| 121 | ); |
|
| 122 | ||
| 123 | return (new SplFileInfo( |
|
| 124 | $targetFileName, |
|
| 125 | $absoluteFolderPath, |
|
| 126 | $this->buildPath($absoluteFolderPath, $targetFileName) |
|
| 127 | )); |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * @param string $pathFragments |
|
| @@ 239-256 (lines=18) @@ | ||
| 236 | * |
|
| 237 | * @return SplFileInfo A reference to the newly created file |
|
| 238 | */ |
|
| 239 | public function writeFile($targetDir, $fileName, $content) |
|
| 240 | { |
|
| 241 | $outputFolder = $this->getFolderPath($this->absolutePath($targetDir, $fileName)); |
|
| 242 | $targetFile = $this->getFileName($fileName); |
|
| 243 | ||
| 244 | if (!file_exists($outputFolder)) |
|
| 245 | { |
|
| 246 | mkdir($outputFolder, 0755, true); |
|
| 247 | } |
|
| 248 | ||
| 249 | file_put_contents($this->appendPath($outputFolder, $targetFile), $content, LOCK_EX); |
|
| 250 | ||
| 251 | return (new SplFileInfo( |
|
| 252 | $fileName, |
|
| 253 | $this->absolutePath($targetDir), |
|
| 254 | $this->absolutePath($targetDir, $fileName) |
|
| 255 | )); |
|
| 256 | } |
|
| 257 | } |
|
| 258 | ||