return @mkdir($this->datadir.$path);
}
public function rmdir($path) {
- return @rmdir($this->datadir.$path);
+ try {
+ $it = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($this->datadir . $path),
+ \RecursiveIteratorIterator::CHILD_FIRST
+ );
+ foreach ($it as $file) {
+ /**
+ * @var \SplFileInfo $file
+ */
+ if (in_array($file->getBasename(), array('.', '..'))) {
+ continue;
+ } elseif ($file->isDir()) {
+ rmdir($file->getPathname());
+ } elseif ($file->isFile() || $file->isLink()) {
+ unlink($file->getPathname());
+ }
+ }
+ return rmdir($this->datadir . $path);
+ } catch (\UnexpectedValueException $e) {
+ return false;
+ }
}
public function opendir($path) {
return opendir($this->datadir.$path);
$this->assertEquals(file_get_contents($textFile), $content);
}
- public function testTouchCreateFile(){
+ public function testTouchCreateFile() {
$this->assertFalse($this->instance->file_exists('foo'));
$this->instance->touch('foo');
$this->assertTrue($this->instance->file_exists('foo'));