PHPDaemon\FS\FileSystem::tempnam PHP Method

tempnam() public static method

Obtain exclusive temporary file
public static tempnam ( string $dir, string $prefix, callable $cb ) : resource
$dir string Directory
$prefix string Prefix
$cb callable Callback (File)
return resource
    public static function tempnam($dir, $prefix, $cb)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!FileSystem::$supported) {
            FileSystem::open(tempnam($dir, $prefix), 'w!', $cb);
        }
        $tries = 0;
        static::tempnamHandler($dir, $prefix, $cb, $tries);
    }

Usage Example

Esempio n. 1
0
 /**
  * Process HTTP headers
  * @return boolean Success
  */
 protected function httpProcessHeaders()
 {
     $this->req->attrs->paramsDone = true;
     if (isset($this->req->attrs->server['HTTP_CONNECTION']) && preg_match('~(?:^|\\W)Upgrade(?:\\W|$)~i', $this->req->attrs->server['HTTP_CONNECTION']) && isset($this->req->attrs->server['HTTP_UPGRADE']) && strtolower($this->req->attrs->server['HTTP_UPGRADE']) === 'websocket') {
         if ($this->pool->WS) {
             $this->pool->WS->inheritFromRequest($this->req, $this);
         }
         return false;
     }
     $this->req = Daemon::$appResolver->getRequest($this->req, $this, isset($this->pool->config->responder->value) ? $this->pool->config->responder->value : null);
     if ($this->req instanceof \stdClass) {
         $this->endRequest($this->req, 0, 0);
         return false;
     } else {
         if ($this->pool->config->sendfile->value && (!$this->pool->config->sendfileonlybycommand->value || isset($this->req->attrs->server['USE_SENDFILE'])) && !isset($this->req->attrs->server['DONT_USE_SENDFILE'])) {
             $req = $this->req;
             FileSystem::tempnam($this->pool->config->sendfiledir->value, $this->pool->config->sendfileprefix->value, function ($fn) use($req) {
                 FileSystem::open($fn, 'wb', function ($file) use($req) {
                     $req->sendfp = $file;
                 });
                 $req->header('X-Sendfile: ' . $fn);
             });
         }
         $this->req->callInit();
     }
     return true;
 }
All Usage Examples Of PHPDaemon\FS\FileSystem::tempnam