Esempio n. 1
0
File: File.php Progetto: phpj/phpj
 public function getParent()
 {
     $path = explode(System::getProperty('file.separator'), $this->path);
     array_pop($path);
     if (empty($path)) {
         return null;
     }
     $path = implode(System::getProperty('file.separator'), $path);
     return new String($path);
 }
Esempio n. 2
0
 public function testCanonicalize()
 {
     $this->assertEquals(System::getProperty("user.dir") . "/composer.json", (string) $this->fs->canonicalize(new String("composer.json")));
 }
Esempio n. 3
0
 public function testGetAbsolutePath()
 {
     $this->assertContains("/", (string) $this->file->getAbsolutePath());
     $this->assertContains("/", (string) $this->file->getCanonicalPath());
     $this->assertContains("/", (string) $this->fileAbs->getAbsolutePath());
     $this->assertContains("/", (string) $this->dir->getAbsolutePath());
     $this->assertContains("/", (string) $this->dirAbs->getAbsolutePath());
     $this->assertContains("/", (string) $this->fileRoot->getAbsolutePath());
     $this->assertContains((string) System::getProperty('user.home'), (string) $this->file->getAbsolutePath());
     $this->assertContains((string) System::getProperty('user.home'), (string) $this->fileAbs->getAbsolutePath());
     $this->assertContains((string) System::getProperty('user.home'), (string) $this->dir->getAbsolutePath());
     $this->assertContains((string) System::getProperty('user.home'), (string) $this->dirAbs->getAbsolutePath());
     $this->assertContains((string) System::getProperty('user.home'), (string) $this->fileRoot->getAbsolutePath());
     $this->assertContains((string) $this->file->getPath(), (string) $this->file->getAbsolutePath());
     $this->assertContains((string) $this->fileAbs->getPath(), (string) $this->fileAbs->getAbsolutePath());
     $this->assertContains((string) $this->dir->getPath(), (string) $this->dir->getAbsolutePath());
     $this->assertContains((string) $this->dirAbs->getPath(), (string) $this->dirAbs->getAbsolutePath());
     $this->assertContains((string) $this->fileRoot->getPath(), (string) $this->fileRoot->getAbsolutePath());
 }
Esempio n. 4
0
 /**
  * @param \PHPJ\Lang\String $prop
  * @param boolean $defaultVal
  * @return bool
  */
 private static function getBooleanProperty(string $prop, $defaultVal = null)
 {
     $val = System::getProperty($prop);
     if ($val === null) {
         return $defaultVal;
     }
     if ($val->equalsIgnoreCase(new String("true"))) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 5
0
 /**
  * Resolve the given pathname into absolute form.  Invoked by the
  * getAbsolutePath and getCanonicalPath methods in the File class.
  * @param File $f
  * @return \PHPJ\Lang\String
  */
 public function resolveFile(File $f)
 {
     if ($this->isAbsolute($f)) {
         return $f->getPath();
     }
     return $this->resolve(System::getProperty("user.dir"), $f->getPath());
 }