| @@ 147-162 (lines=16) @@ | ||
| 144 | /** |
|
| 145 | * {@inheritDoc} |
|
| 146 | */ |
|
| 147 | protected function writeStream( |
|
| 148 | /*# string */ $realPath, |
|
| 149 | $resource |
|
| 150 | )/*# : bool */ { |
|
| 151 | $tmpfname = tempnam(dirname($realPath), 'FOO'); |
|
| 152 | if (false !== $tmpfname) { |
|
| 153 | $stream = fopen($tmpfname, 'w+b'); |
|
| 154 | if (is_resource($stream)) { |
|
| 155 | stream_copy_to_stream($resource, $stream); |
|
| 156 | fclose($stream); |
|
| 157 | return rename($tmpfname, $realPath) && |
|
| 158 | chmod($realPath, PermissionAwareInterface::PERM_ALL); |
|
| 159 | } |
|
| 160 | } |
|
| 161 | return false; |
|
| 162 | } |
|
| 163 | ||
| 164 | /** |
|
| 165 | * {@inheritDoc} |
|
| @@ 167-183 (lines=17) @@ | ||
| 164 | /** |
|
| 165 | * {@inheritDoc} |
|
| 166 | */ |
|
| 167 | protected function writeFile( |
|
| 168 | /*# string */ $realPath, |
|
| 169 | /*# string */ $content |
|
| 170 | )/*# : bool */ { |
|
| 171 | // write to a temp file |
|
| 172 | $tmpfname = tempnam(dirname($realPath), 'FOO'); |
|
| 173 | if (false !== $tmpfname) { |
|
| 174 | $handle = fopen($tmpfname, 'w'); |
|
| 175 | fwrite($handle, $content); |
|
| 176 | fclose($handle); |
|
| 177 | ||
| 178 | // rename to $realPath |
|
| 179 | return rename($tmpfname, $realPath) && |
|
| 180 | chmod($realPath, PermissionAwareInterface::PERM_ALL); |
|
| 181 | } |
|
| 182 | return false; |
|
| 183 | } |
|
| 184 | ||
| 185 | /** |
|
| 186 | * {@inheritDoc} |
|