Pop\File\File::copy PHP 메소드

copy() 공개 메소드

Copy the file object directly to another file on disk.
public copy ( string $new, boolean $overwrite = false ) : File
$new string
$overwrite boolean
리턴 File
    public function copy($new, $overwrite = false)
    {
        // Check to see if the new file already exists.
        if (file_exists($new) && !$overwrite) {
            throw new Exception('Error: The file already exists.');
        }
        if (file_exists($this->fullpath)) {
            copy($this->fullpath, $new);
        } else {
            file_put_contents($new, $this->output);
        }
        $this->setFile($new);
        return $this;
    }

Usage Example

예제 #1
0
 public function testCopyException()
 {
     $this->setExpectedException('Pop\\File\\Exception');
     $f = new File('access.txt');
     $f->copy(__DIR__ . '/../tmp/access.txt');
 }