Example #1
0
 /**
  * Truncate file
  * @param  string   $path   Path
  * @param  integer  $offset Offset
  * @param  callable $cb     Callback
  * @param  integer  $pri    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) {
             call_user_func($cb, $path, $r);
         }
         return $r;
     }
     return eio_truncate($path, $offset, $pri, $cb, $path);
 }
Example #2
0
 public static function truncate($path, $offset = 0, $cb = null, $pri = EIO_PRI_DEFAULT)
 {
     if (!FS::$supported) {
         $fp = fopen($path, 'r+');
         $r = $fp && ftruncate($fp, $offset);
         if ($cb) {
             call_user_func($cb, $path, $r);
         }
         return;
     }
     return eio_truncate($path, $offset, $pri, $cb, $path);
 }