PHPDaemon\FS\FileSystem::truncate PHP Method

truncate() public static method

Truncate file
public static truncate ( string $path, integer $offset, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | boolean
$path string Path
$offset integer Offset
$cb callable Callback
$pri integer Priority
return resource | boolean
    public static function truncate($path, $offset = 0, $cb = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!FileSystem::$supported) {
            $fp = fopen($path, 'r+');
            $r = $fp && ftruncate($fp, $offset);
            if ($cb) {
                $cb($path, $r);
            }
            return $r;
        }
        return eio_truncate($path, $offset, $pri, $cb, $path);
    }