Пример #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());
 }
Пример #2
0
Файл: File.php Проект: 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;
 }