public function moveTo($destination) { Filesystem::checkWritable(dirname($destination)); if (!move_uploaded_file($this->path, $destination)) { throw new FilesystemException("Failed to move file {$this->path} to {$destination}"); } }
public function putContents($contents) { if (file_exists($this->path)) { Filesystem::checkWritable($this->path); } else { Filesystem::checkWritable(dirname($this->path)); } file_put_contents($this->path, $contents); }
public static function checkWriteSafety($path) { Filesystem::checkExists($path); Filesystem::checkWritable($path); }
/** * @expectedException \ntentan\utils\exceptions\FilesystemException */ public function testWriteableException() { $this->assertEquals(true, Filesystem::checkWritable(vfsStream::url('fs/file'))); $this->file->chmod(00); Filesystem::checkWritable(vfsStream::url('fs/file')); }