Skip to content

Commit

Permalink
Merge pull request #94 from alchemy-fr/issue-93
Browse files Browse the repository at this point in the history
Explicitely create parent directory of target files
  • Loading branch information
aztech-dev committed Jan 12, 2016
2 parents b73ba0c + a788a55 commit 8cb5d70
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Resource/Teleporter/AbstractTeleporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ abstract class AbstractTeleporter implements TeleporterInterface
/**
* Writes the target
*
* @param String $data
* @param Resource $resource
* @param String $context
* @param string $data
* @param \Alchemy\Zippy\Resource\Resource $resource
* @param string $context
*
* @return TeleporterInterface
*
Expand All @@ -31,6 +31,10 @@ protected function writeTarget($data, Resource $resource, $context)
{
$target = $this->getTarget($context, $resource);

if (! file_exists(dirname($target)) && false === mkdir(dirname($target))) {
throw new IOException(sprintf('Could not create parent directory %s', dirname($target)));
}

if (false === file_put_contents($target, $data)) {
throw new IOException(sprintf('Could not write to %s', $target));
}
Expand Down

0 comments on commit 8cb5d70

Please sign in to comment.