/**
  * Publishes the specified directory to this target, with the given relative path.
  *
  * @param string $sourcePath Absolute path to the source directory
  * @param string $relativeTargetPathAndFilename relative path and filename in the target directory
  * @throws TargetException
  * @return void
  */
 protected function publishDirectory($sourcePath, $relativeTargetPathAndFilename)
 {
     $targetPathAndFilename = $this->path . $relativeTargetPathAndFilename;
     if (@stat($sourcePath) === false) {
         throw new TargetException(sprintf('Could not publish directory "%s" into resource publishing target "%s" because the source is not accessible (file stat failed).', $sourcePath, $this->name), 1416244512);
     }
     if (!file_exists(dirname($targetPathAndFilename))) {
         Files::createDirectoryRecursively(dirname($targetPathAndFilename));
     }
     try {
         if (Files::is_link($targetPathAndFilename)) {
             Files::unlink($targetPathAndFilename);
         }
         if ($this->relativeSymlinks) {
             $result = Files::createRelativeSymlink($sourcePath, $targetPathAndFilename);
         } else {
             $temporaryTargetPathAndFilename = uniqid($targetPathAndFilename . '.') . '.tmp';
             symlink($sourcePath, $temporaryTargetPathAndFilename);
             $result = rename($temporaryTargetPathAndFilename, $targetPathAndFilename);
         }
     } catch (\Exception $exception) {
         $result = false;
     }
     if ($result === false) {
         throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source directory could not be symlinked at target location.', $sourcePath, $this->name), 1416244515, isset($exception) ? $exception : null);
     }
     $this->systemLogger->log(sprintf('FileSystemSymlinkTarget: Published directory. (target: %s, file: %s)', $this->name, $relativeTargetPathAndFilename), LOG_DEBUG);
 }
Exemple #2
0
 /**
  * Check write permissions for folders used for writing files
  *
  * @return mixed
  */
 protected function checkFilePermissions()
 {
     foreach ($this->requiredWritableFolders as $folder) {
         $folderPath = FLOW_PATH_ROOT . $folder;
         if (!is_dir($folderPath) && !\Neos\Utility\Files::is_link($folderPath)) {
             try {
                 \Neos\Utility\Files::createDirectoryRecursively($folderPath);
             } catch (\Neos\Flow\Utility\Exception $exception) {
                 return new Error('Unable to create folder "%s". Check your file permissions (did you use flow:core:setfilepermissions?).', 1330363887, [$folderPath]);
             }
         }
         if (!is_writable($folderPath)) {
             return new Error('The folder "%s" is not writable. Check your file permissions (did you use flow:core:setfilepermissions?)', 1330372964, [$folderPath]);
         }
     }
     return null;
 }
Exemple #3
0
 /**
  * @test
  */
 public function is_linkReturnsFalseForStreamWrapperPaths()
 {
     $targetPath = 'vfs://Foo/Bar';
     if (!is_dir($targetPath)) {
         Files::createDirectoryRecursively($targetPath);
     }
     $this->assertFalse(Files::is_link($targetPath));
 }