Example #1
0
 /**
  * @depends     testExist
  * @return      void
  */
 public function testListAll()
 {
     $examplePath = __DIR__ . '/ExampleDir';
     $filesObject = new File($examplePath);
     $expectedFiles = array($examplePath . '/ExampleChildDir', $examplePath . '/testFile1.txt', $examplePath . '/testFile2.txt');
     $i = 0;
     foreach ($filesObject->listAll() as $fileObject) {
         $this->assertInstanceOf('Naucon\\File\\File', $fileObject);
         $this->assertContains($fileObject->getPathname(), $expectedFiles);
         $i++;
     }
     $this->assertEquals(3, $i);
 }
Example #2
0
echo '<br/>';
echo '<br/>';
echo 'Remove file';
echo '<br/>';
$deletePath = __DIR__ . '/tmp/example.txt';
$fileObject = new File($deletePath);
$fileObject->delete();
echo 'Remove directories';
echo '<br/>';
$deletePath = __DIR__ . '/tmp/target/';
$fileObject = new File($deletePath);
$fileObject->deleteAll();
$examplePath = __DIR__ . '/ExampleDir';
$fileObject = new File($examplePath);
echo '<br/>';
$iteratorObject = $fileObject->listAll();
echo 'Iterate * <strong>' . $fileObject->getBasename() . '</strong>';
echo '<br/>';
echo '<ul>';
echo '<li>' . $fileObject->getBasename();
echo '<ul>';
foreach ($iteratorObject as $subFileObject) {
    echo '<li>' . $subFileObject->getBasename() . '</li>';
    if ($subFileObject->isDir()) {
        echo '<ul>';
        foreach ($subFileObject->listAll() as $subChildFileObject) {
            echo '<li>' . $subChildFileObject->getBasename() . '</li>';
        }
        echo '</ul>';
    }
}
Example #3
0
 /**
  * @param string $configurationFilepath
  * @param File $repositoryFileObject
  * @throws \Exception if configuration file does not exists
  * @throws \Exception if configuration file is not readable
  */
 public function setup($configurationFilepath, $repositoryFileObject)
 {
     if (false === file_exists($configurationFilepath)) {
         throw new \Exception('Given configuration file does not exists: ' . $configurationFilepath);
     }
     if (false === is_readable($configurationFilepath)) {
         throw new \Exception('Given configuration file is not readable: ' . $configurationFilepath);
     }
     $this->configurationFilepath = $configurationFilepath;
     // include known vocabulary and ontology meta data
     $iteratorObject = $repositoryFileObject->listAll();
     foreach ($iteratorObject as $vendorFolder) {
         $vendorFolder->getBasename() . '<br/>';
         if ($vendorFolder->isDir()) {
             foreach ($vendorFolder->listFiles() as $jsonFile) {
                 $infoArray = json_decode(file_get_contents($jsonFile->getPathname()), true);
                 $this->repository[$infoArray['name']] = $infoArray;
             }
         }
     }
 }