Example #1
0
 public function testSet()
 {
     $file = new File(uniqid('.test_'));
     $this->assertFalse($file->exists());
     $file->createNewFile();
     $this->assertTrue($file->exists());
     $this->assertTrue($file->isReadable());
     $this->assertTrue($file->isWritable());
     $this->assertFalse($file->isExecutable());
     $file->setReadable(true);
     $file->setWritable(true);
     $file->setExecutable(true);
     //    var_dump($file->isReadable());
     //    var_dump($file->isWritable());
     //    var_dump($file->isExecutable());
 }
Example #2
0
File: File.php Project: phpj/phpj
 public static function createFmpFile(string $prefix = null, string $suffix = null, File $directory = null)
 {
     $directory = $directory ?: new File(sys_get_temp_dir());
     $directory = $directory->getPath();
     $suffix = (string) ($suffix ?: 'tmp');
     $prefix = (string) ($prefix ?: uniqid('tmp_file'));
     $name = tempnam($directory, $prefix);
     $name = sprintf("%s.%s", $name, $suffix);
     $file = new File($name);
     $file->createNewFile();
     return $file;
 }
Example #3
0
 /**
  * Compute the hash code of an abstract pathname.
  * @param File $f
  * @return int
  */
 public function hashCodeFile(File $f)
 {
     return (new String($f->getPath()))->hashCode() ^ 1234321;
 }
Example #4
0
 /**
  * Compare two pathnames lexicographically.
  * @param File $f1
  * @param File $f2
  * @return int
  */
 public function compare(File $f1, File $f2)
 {
     return $f1->getAbsolutePath()->compareTo($f2->getAbsolutePath());
 }