Skip to content

Commit

Permalink
fixed chmod when chmoding link
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Donat committed May 10, 2014
1 parent 7114cff commit 33b3bdb
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 62 deletions.
4 changes: 2 additions & 2 deletions build/pear/package.php
Expand Up @@ -74,7 +74,7 @@ public function run()
protected function getInstallListing($directory, $cut, $parentNode)
{
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS));
foreach($objects as $name => $object){
foreach ($objects as $name => $object) {
$file = ltrim(str_replace($cut, '', $name), '/');
$as = ltrim(str_replace($directory, '', $name), '/');
$parentNode->appendChild($node = new DOMElement('install'));
Expand Down Expand Up @@ -123,4 +123,4 @@ public function usage()
if (realpath($argv[0]) == realpath(__FILE__)) {
$pxml = new PackageXML();
$pxml->run();
}
}
8 changes: 4 additions & 4 deletions docs/examples/permissions/Checker.php
@@ -1,8 +1,7 @@
<?php


class Checker {

class Checker
{
protected $root;

public function __construct($root)
Expand All @@ -25,6 +24,7 @@ public function checkCache()
{
$a = is_dir($this->root.'/cache');
$b = is_writable($this->root.'/cache');

return is_dir($this->root.'/cache') && is_writable($this->root.'/cache');
}

Expand All @@ -43,4 +43,4 @@ public function checkInstaller()
return !file_exists($this->root.'/lib');
}

}
}
11 changes: 5 additions & 6 deletions docs/examples/permissions/CheckerTest.php
Expand Up @@ -2,8 +2,8 @@

require_once 'Checker.php';

class CheckerWithMockTest extends PHPUnit_Framework_TestCase {

class CheckerWithMockTest extends PHPUnit_Framework_TestCase
{
public function testCheckingForCacheReturnsWritableState()
{
$fs = new \VirtualFileSystem\FileSystem();
Expand All @@ -22,9 +22,8 @@ public function testCheckingForCacheReturnsWritableState()
}
}


class CheckerTest extends PHPUnit_Framework_TestCase {

class CheckerTest extends PHPUnit_Framework_TestCase
{
public function testCheckingForCacheReturnsWritableState()
{
mkdir($root = '/tmp/'.uniqid());
Expand All @@ -45,4 +44,4 @@ public function testCheckingForCacheReturnsWritableState()
rmdir($cache);
rmdir($root);
}
}
}
2 changes: 1 addition & 1 deletion phpunit.xml
Expand Up @@ -32,4 +32,4 @@
<!-- <listener class="\Mockery\Adapter\Phpunit\TestListener"></listener> -->
</listeners>

</phpunit>
</phpunit>
23 changes: 12 additions & 11 deletions src/VirtualFileSystem/Container.php
Expand Up @@ -10,7 +10,6 @@

namespace VirtualFileSystem;

use Symfony\Component\Config\Definition\Exception\Exception;
use VirtualFileSystem\Structure\Directory;
use VirtualFileSystem\Structure\File;
use VirtualFileSystem\Structure\Root;
Expand Down Expand Up @@ -90,7 +89,7 @@ public function root()
* @param string $path
*
* @return Structure\Node
*
*
* @throws NotFoundException
*/
public function fileAt($path)
Expand All @@ -117,6 +116,7 @@ public function hasFileAt($path)
{
try {
$this->fileAt($path);

return true;
} catch (NotFoundException $e) {
return false;
Expand All @@ -127,8 +127,8 @@ public function hasFileAt($path)
* Creates Directory at given path.
*
* @param string $path
* @param bool $recursive
* @param null $mode
* @param bool $recursive
* @param null $mode
*
* @return Structure\Directory
*
Expand Down Expand Up @@ -189,7 +189,7 @@ public function createLink($path, $destination)
* Creates file at given path
*
* @param string $path
* @param null $data
* @param null $data
*
* @return Structure\File
*
Expand Down Expand Up @@ -219,9 +219,10 @@ public function createFile($path, $data = null)
*
* @param array $structure
*/
public function createStructure(array $structure, $parent = '/') {
foreach($structure as $key => $value) {
if(is_array($value)) {
public function createStructure(array $structure, $parent = '/')
{
foreach ($structure as $key => $value) {
if (is_array($value)) {
$this->createDir($parent.$key);
$this->createStructure($value, $parent.$key.'/');
} else {
Expand All @@ -233,8 +234,8 @@ public function createStructure(array $structure, $parent = '/') {
/**
* Moves Node from source to destination
*
* @param string $from
* @param string $to
* @param string $from
* @param string $to
* @return bool
* @throws \RuntimeException
*/
Expand Down Expand Up @@ -278,7 +279,7 @@ public function move($from, $to)
* Removes node at $path
*
* @param string $path
* @param bool $recursive
* @param bool $recursive
*
* @throws \RuntimeException
*/
Expand Down
5 changes: 3 additions & 2 deletions src/VirtualFileSystem/Factory.php
Expand Up @@ -60,13 +60,14 @@ public function updateMetadata(Node $node)
{
$this->updateFileTimes($node);
$this->updateOwnership($node);

return $node;
}

/**
* Update file a/c/m times
*
* @param Node $node
* @param Node $node
* @return Node
*/
public function updateFileTimes(Node $node)
Expand Down Expand Up @@ -121,7 +122,7 @@ public function getFile($basename)
/**
* Creates Link object.
*
* @param string $basename
* @param string $basename
* @param Structure\Node $destination
*
* @return Link
Expand Down
5 changes: 3 additions & 2 deletions src/VirtualFileSystem/FileSystem.php
Expand Up @@ -13,6 +13,7 @@
use VirtualFileSystem\Structure\Directory;
use VirtualFileSystem\Structure\File;
use VirtualFileSystem\Structure\Root;
use VirtualFileSystem\Structure\Link;

/**
* Main 'access' class to vfs implementation. It will register new stream wrapper on instantiation.
Expand Down Expand Up @@ -129,8 +130,8 @@ public function path($path)
* Creates and returns a directory
*
* @param string $path
* @param bool $recursive
* @param null $mode
* @param bool $recursive
* @param null $mode
*
* @return Directory
*/
Expand Down
6 changes: 3 additions & 3 deletions src/VirtualFileSystem/Loader.php
Expand Up @@ -119,7 +119,7 @@ public function unregister()
/**
* Loads the given class or interface.
*
* @param string $className The name of the class to load.
* @param string $className The name of the class to load.
* @return void
*/
public function loadClass($className)
Expand All @@ -141,11 +141,11 @@ public function loadClass($className)
/**
* Returns full path for $fileName if _includePath is set, or leaves as-is for PHP's internal search in 'require'.
*
* @param string $fileName relative to include path.
* @param string $fileName relative to include path.
* @return string
*/
private function getFullPath($fileName)
{
return ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
}
}
}
1 change: 0 additions & 1 deletion src/VirtualFileSystem/Structure/Node.php
Expand Up @@ -30,7 +30,6 @@ abstract class Node
protected $mtime;
protected $ctime;


/**
* Class constructor.
*
Expand Down
1 change: 1 addition & 0 deletions src/VirtualFileSystem/Structure/Root.php
Expand Up @@ -70,6 +70,7 @@ public function url()
if (!$this->scheme) {
throw new \RuntimeException('No scheme set');
}

return $this->scheme;
}
}

0 comments on commit 33b3bdb

Please sign in to comment.