Skip to content

Commit

Permalink
Merge pull request #507 from dogiedog/master
Browse files Browse the repository at this point in the history
Added config for file_put_contents flags
  • Loading branch information
frankdejonge committed Jun 13, 2015
2 parents 8b81992 + c732c13 commit 30539a6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Adapter/Local.php
Expand Up @@ -25,12 +25,18 @@ class Local extends AbstractAdapter
*/
protected $pathSeparator = DIRECTORY_SEPARATOR;

/**
* @var int
*/
protected $writeFlags;

/**
* Constructor.
*
* @param string $root
* @param int $writeFlags
*/
public function __construct($root)
public function __construct($root, $writeFlags = LOCK_EX)
{
$realRoot = $this->ensureDirectory($root);

Expand All @@ -39,6 +45,7 @@ public function __construct($root)
}

$this->setPathPrefix($realRoot);
$this->writeFlags = $writeFlags;
}

/**
Expand Down Expand Up @@ -77,7 +84,7 @@ public function write($path, $contents, Config $config)
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));

if (($size = file_put_contents($location, $contents, LOCK_EX)) === false) {
if (($size = file_put_contents($location, $contents, $this->writeFlags)) === false) {
return false;
}

Expand Down Expand Up @@ -144,7 +151,7 @@ public function update($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
$mimetype = Util::guessMimeType($path, $contents);
$size = file_put_contents($location, $contents, LOCK_EX);
$size = file_put_contents($location, $contents, $this->writeFlags);

if ($size === false) {
return false;
Expand Down

0 comments on commit 30539a6

Please sign in to comment.