Method to write the process id file out to disk.

@return  boolean

@since   2.0
17056
protected function writeProcessIdFile()
    {
        // Verify the process id is valid.
        if ($this->processId < 1) {
            $this->getLogger()->emergency('The process id is invalid.');

            return false;
        }

        // Get the application process id file path.
        $file = $this->config->get('application_pid_file');

        if (empty($file)) {
            $this->getLogger()->error('The process id file path is empty.');

            return false;
        }

        // Make sure that the folder where we are writing the process id file exists.
        $folder = dirname($file);

        if (!is_dir($folder) && !@ mkdir($folder, $this->get('folder_permission', 0755))) {
            $this->getLogger()->error('Unable to create directory: ' . $folder);

            return false;
        }

        // Write the process id file out to disk.
        if (!file_put_contents($file, $this->processId)) {
            $this->getLogger()->error('Unable to write proccess id file: ' . $file);

            return false;
        }

        // Make sure the permissions for the proccess id file are accurate.
        if (!chmod($file, $this->get('file_permission', 0644))) {
            $this->getLogger()->error('Unable to adjust permissions for the proccess id file: ' . $file);

            return false;
        }

        return true;
    }
129006
public function writeManifest() {
        $written = false;
        if (!empty ($this->vehicles)) {
            if (!empty($this->attributes['setup-options']) && is_array($this->attributes['setup-options'])) {
                $cacheManager = $this->xpdo->getCacheManager();
                $cacheManager->copyFile($this->attributes['setup-options']['source'],$this->path . $this->signature . '/setup-options.php');

                $this->attributes['setup-options'] = $this->signature . '/setup-options.php';
            }
            $manifest = array(
                xPDOTransport::MANIFEST_VERSION => $this->manifestVersion,
                xPDOTransport::MANIFEST_ATTRIBUTES => $this->attributes,
                xPDOTransport::MANIFEST_VEHICLES => $this->vehicles
            );
            $content = var_export($manifest, true);
            $cacheManager = $this->xpdo->getCacheManager();
            if ($content && $cacheManager) {
                $fileName = $this->path . $this->signature . '/manifest.php';
                $content = "<?php return {$content};";
                if (!($written = $cacheManager->writeFile($fileName, $content))) {
                    $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Error writing manifest to ' . $fileName);
                }
            }
        }
        return $written;
    }
988664
public function write()
    {
        // Crete the file if it does not exist
        $this->makeFile($this->formatter->getFileName());

        // Contents of the original file
        $fileContent = file_get_contents($this->formatter->getFileName());

        // Final log
        $log = join("\n", (array) $this->formatter->generate())."\n";

        // Include the breakpoint
        if (false === empty($this->break) && 1 === preg_match("/^{$this->break}/m", $fileContent)) {
            $splitFileContent = preg_split("/^{$this->break}/m", $fileContent);

            file_put_contents($this->formatter->getFileName(), $splitFileContent[0].$this->break."\n".$log.$splitFileContent[1]);

            return true;
        }

        file_put_contents($this->formatter->getFileName(), $log.$fileContent);

        return true;
    }
378112
public function close()
    {
        $id = session_id();
        // Make sure the session is unlocked and the expiration time is updated,
        // even if the write did not occur
        if ($this->openSessionId !== $id || !$this->sessionWritten) {
            $result = $this->connection->write($this->formatId($id), '', false);
            $this->sessionWritten = (bool) $result;
        }

        return $this->sessionWritten;
    }
1334791
protected function generateId(): int
    {
        if ($this->getId() !== null) {
            return $this->getId();
        }

        $maxIdLength = \mb_strlen((string) PHP_INT_MAX) - 1;

        // try generate unique id for file
        $id = mb_substr(crc32($this->getModelId()), $maxIdLength - self::ID_PATH_HASH_LENGTH)
            . mb_substr(crc32($this->getActualPath()), self::ID_PATH_HASH_LENGTH);

        return (int) $id;
    }
1222798
public function write()
	{
		// do we have something to write?
		if ( ! empty($this->keys) or ! empty($this->data) or ! empty($this->flash))
		{
			parent::write();

			// rotate the session id if needed
			$this->rotate(false);

			// record the last update time of the session
			$this->keys['updated'] = $this->time->get_timestamp();

			// session payload
			$payload = $this->_serialize(array($this->keys, $this->data, $this->flash));

			// create the session file
			$this->_write_memcached($this->keys['session_id'], $payload);

			// was the session id rotated?
			if ( isset($this->keys['previous_id']) and $this->keys['previous_id'] != $this->keys['session_id'])
			{
				// point the old session file to the new one, we don't want to lose the session
				$payload = $this->_serialize(array('rotated_session_id' => $this->keys['session_id']));
				$this->_write_memcached($this->keys['previous_id'], $payload);
			}

			$this->_set_cookie(array($this->keys['session_id']));
		}

		return $this;
	}
525302
public function processar()
    {
        if ($this->isProcessado()) {
            return $this;
        }

        if (method_exists($this, 'init')) {
            call_user_func([$this, 'init']);
        }

        foreach ($this->file as $linha) {
            $recordType = $this->rem(8, 8, $linha);

            if ($recordType == '0') {
                $this->processarHeader($linha);
            } elseif ($recordType == '1') {
                $this->processarHeaderLote($linha);
            } elseif ($recordType == '3') {
                if ($this->getSegmentType($linha) == 'T') {
                    $this->incrementDetalhe();
                }

                if ($this->processarDetalhe($linha) === false) {
                    unset($this->detalhe[$this->increment]);
                    $this->increment--;
                }
            } elseif ($recordType == '5') {
                $this->processarTrailerLote($linha);
            } elseif ($recordType == '9') {
                $this->processarTrailer($linha);
            }
        }

        if (method_exists($this, 'finalize')) {
            call_user_func([$this, 'finalize']);
        }

        return $this->setProcessado();
    }
1052649
public function canWrite()
    {
        $ht = $this->getHTaccessFilename();
        $fs = $this->getFilesystem();

        return (bool) (@$fs->isFile($ht) ? @$fs->isWritable($ht) : @$fs->isWritable(@dirname($ht)));
    }
595
public function getId()
    {
        if ($output = $this->execute('fsutil file queryfileid', $this->path)) {
                if ((bool) preg_match('/(\d{1}[x].*)/', $output[0], $matches)) {
                return $matches[0];
            }
        }
    }
914196
public function lock()
    {
        if (!$this->isLocked()) {
            $file = fopen($this->getFilePath(), 'w');
            if ($file) {
                fwrite($file, getmypid());
                fclose($file);
                return true;
            }
        }
        return false;
    }
1168058
public function save()
    {
        $dir = dirname($this->path);

        if (!is_dir($dir)) {
            $mask = @umask(0);
            $result = @mkdir($dir, $this->dirMode, true);
            @umask($mask);

            if (!$result) {
                throw new Exception("Unable to create the directory '$dir'.");
            }
        }

        if (@file_put_contents($this->path, $this->content) === false) {
            throw new Exception("Unable to write the file '{$this->path}'.");
        }

        $mask = @umask(0);
        @chmod($this->path, $this->mode);
        @umask($mask);

        return true;
    }
209043
def write_pidfile
      return unless pidfile
      pid = $PID
      File.open(pidfile, 'w') { |f| f.puts(pid) }

      # Remove pidfile on exit
      at_exit do
        File.delete(pidfile) if pid == $PID
      end
    end
756770
public function send() {
    if (!isset($this->files[$this->sent])) {
      return FALSE;
    }

    $file = $this->files[$this->sent];

    // Local header
    $local = $file->genLocal(self::ZIP_VERSION, $this->dosStamp);
    $this->output($local);

    // Body
    $file->hasDeflation() ? $this->outputDeflated($file) : $this->outputRaw($file);

    // Data descriptor
    $dataDescriptor = $file->isSmooth() ? $file->genDataDescriptor() : '';
    $this->output($dataDescriptor);

    $file->setLocalOffset($this->localOffset);
    $this->localOffset += strlen($local) + $file->getDeflatedSize() + strlen($dataDescriptor);

    // Central header (not output, see flush)
    $file->genCentral(self::ZIP_VERSION, $this->dosStamp);
    $this->centralLength += strlen($file->getCentral());

    $this->sent++;
    return TRUE;
  }
15746
public function getRunningPID() {
        if (!file_exists($this->pidFile)) {
            return false;
        }

        $runPid = trim(file_get_contents($this->pidFile));
        if (!$runPid) {
            return false;
        }

        return $runPid;
    }
572131
public function write()
    {
        $current = $this->getUserAgent() + ['agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'), 'ip' => $this->getClientIp()];
        $last = $this->getFileArray()->exists(0) ? $this->getFileArray()->get(0) : [];

        //Removes the first record (last in order of time), if it has been saved
        //  less than an hour ago and if the user agent data are the same
        if ($last && (new Time($last->get('time')))->modify('+1 hour')->isFuture()
            && $last->extract(['agent', 'browser', 'ip', 'platform', 'version']) == $current
        ) {
            $this->getFileArray()->delete(0);
        }

        //Adds the current request, takes only a specified number of records and writes
        return $this->getFileArray()->prepend(new Entity($current + ['time' => new Time]))
            ->take(getConfig('users.login_log'))
            ->write();
    }
877900
protected function _getPid()
    {
        if (!file_exists($this->_pidFile)) {
            return false;
        }
        return (($this->_pid = file_get_contents($this->_pidFile)) && posix_kill($this->_pid, 0)) ? $this->_pid : false;
    }
98130
def write_pid(pidfile):
    
    pid = str(os.getpid())
    try:
        with open(pidfile, mode='w') as _file:
            print("writing processID {p} to pidfile".format(p=pid))
            _file.write(pid)
    except OSError as exc:
        sys.exit("failed to write pidfile:{e}".format(e=exc))