/**
  * @covers Corgi\File\ContentManagers\DirectoryContents::addSubDirectory
  */
 public function testAddSubDirectory()
 {
     $subDirectory = new Directory($this->directory . '/test/test/');
     $this->directory->contents()->addSubDirectory($subDirectory);
     $this->assertTrue(FileSystemHelper::isDirectory($subDirectory));
     $subDirectory->delete();
 }
Exemple #2
0
 /**
  * Deletes an empty directory
  * @return bool
  * @throws DeleteException
  */
 public function safeDelete()
 {
     if (!FileSystemHelper::isDirectory($this) || !rmdir($this)) {
         throw new DeleteException($this);
     }
     return true;
 }
Exemple #3
0
 /**
  * Updates access date and time on a file
  * If the file does not exist, it gets created
  * @return File
  * @throws CreateDirectoryException
  * @throws NotWritableException
  */
 public function touch()
 {
     $baseDir = new Directory(dirname($this));
     if (!FileSystemHelper::isDirectory($baseDir)) {
         try {
             $baseDir->create(false);
         } catch (CreateDirectoryException $e) {
             throw $e;
         }
     }
     if (!FileSystemHelper::isWritable($baseDir)) {
         throw new NotWritableException($this);
     }
     touch($this);
     return $this;
 }
 /**
  * @covers Corgi\File\Helpers\FileSystemHelper::isDirectory
  */
 public function testIsDirectory()
 {
     $this->assertBool(FileSystemHelper::isDirectory());
 }