Check the content of the PID file created by the worker
to retrieve its process PID

@param  string $path Path to the PID file

@codeCoverageIgnore
@since  1.2.0
@return false|int The worker process ID, or false if error
548421
protected function checkStartedWorker($pidFile)
    {
        $pid = false;
        if (file_exists($pidFile) && false !== $pid = file_get_contents($pidFile)) {
            unlink($pidFile);
            return (int)$pid;
        }
        return false;
    }
86652
public function checkPath($path = null)
    {
        if (is_null($path)) {
            $path = $this->getDir();
        }

        $real_path = realpath($path);
        if (!$real_path) {
            $real_path = realpath(dirname($path));
        }
        $upload_path = realpath($this->getUploadPath());

        if (strcasecmp($real_path, $upload_path) > 0) {
            return true;
        } else {
            throw new \Exception("Directory is not in the upload path", 403);
        }
    }
155122
public function checkPath($path = null)
  {
    if($path === null)
    {
      $path = $this->path;
    }

    if(strlen($path) == 0)
    {
      return TRUE;
    }

    $pattern = "/^" . $this->regex["path"] . "$/";
    $status = @preg_match($pattern, $path);

    if($status === FALSE)
    {
      throw new Exception("URI path validation failed");
    }

    return ($status == 1);
  }
1050780
protected function verifyPath($path){
		if (file_exists($path)) return true;
			
		if (mkdir($path, 0777, true)) return true;
				
		return false;
	}
342377
public function isFile($path)
    {
        $parentDir = $this->dirname($path);
        return in_array($path, $this->files($parentDir));
    }
343100
public function fileperms($path)
    {
        $node = $this->at($path);
        if (null === $node) {
            return false;
        }
        return $node->perms;
    }
636402
protected function getPidByPath(string $path) : int
    {
        $procInfo = [];
        $cliOutput = [];
        exec('ps x | grep ' . $path, $cliOutput);
        foreach ($cliOutput as $line) {
            $line = trim($line);
            if (empty($line)) {
                continue;
            }
            if (strpos($line, 'grep') !== false) {
                continue;
            }
            $procInfo = preg_split('#\s+#', $line);
            break;
        }
        if (empty($procInfo)) {
            return 0;
        }
        return (int)$procInfo[0];
    }
299539
final public static function checkFileLogExist(string $path):bool
    {
        if (!file_exists($path)) {
            return ((file_put_contents($path, "") != false)? true : false);
        }

        if (!is_readable($path)) {
            return (false);
        }

        if (!is_writable($path)) {
            return (false);
        }
        return (true);
    }
231709
public function createDir( $path )
    {
        if ( empty( $path ) )
        {
            return false;
        }

        $path = $this->validPath( $path );
        $base = $this->baseUrl . '/' . $path;
        $full = $this->baseDir . '/' . $base;

        if ( ! is_dir( $full ) && ! is_file( $full ) )
        {
            $rights = $this->rights( $path );

            if ( $rights->write && @ mkdir( $full, 0777, true ) )
            {
                return $path;
            }
        }

        return false;
    }
317728
private function checkPath($path)
    {
        return file_exists($path) && is_readable($path) && ($resources = scandir($path)) && (count($resources) > 2);
    }
473599
public function isFile($path)
    {
        $node = $this->at($path);
        return null !== $node && 'file' === $node->type;
    }
832293
protected function isTempFile($path)
    {
        // We're only interested in the basename.
        list(, $tempPath) = Uri\split($path);

        foreach ($this->temporaryFilePatterns as $tempFile) {
            if (preg_match($tempFile, $tempPath)) {
                return $this->getDataDir().'/sabredav_'.md5($path).'.tempfile';
            }
        }

        return false;
    }
388935
public function detectCommand($path)
    {
        if (!$path) {
            $this->install();
            $path = $this->getPath();
        }
        if (!$path || !file_exists($path)) {
            throw new InvalidConfigException('Failed to find how to run ' . $this->name);
        }

        return $path;
    }
1271773
public function getCreateFilePermissions($path = null)
    {
        try {
            if (!isset($path)) {
                $path = DIR_FILES_UPLOADED_STANDARD;
            }

            if (!is_dir($path)) {
                $path = @dirname($path);
            }
            $perms = @fileperms($path);

            if (!$perms) {
                throw new Exception(t('An error occurred while attempting to determine file permissions.'));
            }
            clearstatcache();
            $dir_perms = substr(decoct($perms), 1);

            $file_perms = "0";
            $parts[] = substr($dir_perms, 1, 1);
            $parts[] = substr($dir_perms, 2, 1);
            $parts[] = substr($dir_perms, 3, 1);
            foreach ($parts as $p) {
                if (intval($p) % 2 == 0) {
                    $file_perms .= $p;
                    continue;
                }
                $file_perms .= intval($p) - 1;
            }
        } catch (Exception $e) {
            return false;
        }
        $res = new \stdClass();
        $res->file = intval($file_perms, 8);
        $res->dir = intval($dir_perms, 8);

        return $res;
    }
1341672
private static function dirReady($path) {
    if (!file_exists($path)) {
      $parent = preg_replace("/\/[^\/]+\/?$/", '', $path);
      if (!self::dirReady($parent)) {
        return FALSE;
      }

      mkdir($path, 0777, true);
    }

    if (!is_dir($path)) {
      trigger_error('Path is not a directory ' . $path, E_USER_WARNING);
      return FALSE;
    }

    if (!is_writable($path)) {
      trigger_error('Unable to write to ' . $path . ' – check directory permissions –', E_USER_WARNING);
      return FALSE;
    }

    return TRUE;
  }
387671
public function checksumByPath(string $path)
    {
        return file_exists($path) ? $this->checksum((string) file_get_contents($path)) : null;
    }
729560
protected static function tryDelete($path)
    {
        $success = true;

        try
        {
            if ( ! @unlink($path))
            {
                $success = false;
            }
        } catch (ErrorException $e)
        {
            $success = false;
        }

        return $success;
    }