Determines if current source data is binary data

@return boolean
339903
public function isBinary()
    {
        if (is_string($this->data)) {
            $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $this->data);
            return (substr($mime, 0, 4) != 'text' && $mime != 'application/x-empty');
        }

        return false;
    }
1331387
public static function hasStty() : bool
    {
        // Return the cached result if it's already available.
        if (static::$hasStty !== null) {
            return static::$hasStty;
        }

        // Definitely no Stty on Windows.
        if (static::isWindows()) {
            return static::$hasStty = false;
        }

        // Run a simple exec() call and check whether it returned with an error code.
        exec('/usr/bin/env stty', $output, $exitCode);

        return static::$hasStty = $exitCode === 0;
    }
183215
public function isVersioned()
    {
        if (!$this->ObjectClass || !class_exists($this->ObjectClass)) {
            return false;
        }
        /** @var Versioned|DataObject $singleton */
        $singleton = DataObject::singleton($this->ObjectClass);
        return $singleton->hasExtension(Versioned::class) && $singleton->hasStages();
    }
935209
def is_binary(filename):
    
    logger.debug('is_binary: %(filename)r', locals())

    # Check if the file extension is in a list of known binary types
    binary_extensions = ['pyc', 'iso', 'zip', 'pdf']
    for ext in binary_extensions:
        if filename.endswith(ext):
            return True

    # Check if the starting chunk is a binary string
    chunk = get_starting_chunk(filename)
    return is_binary_string(chunk)
210510
protected function binaryOutput()
    {
        $data = file_get_contents($this->src);
        $im = getimagesize($this->src);
        header('Content-Length: ' . strlen($data));
        header("Content-type: " . $im['mime']);
        echo $data;
        flush();
        die;
    }
1005856
private static boolean isBinary(InputStream in) {
        try {
            int size = in.available();
            if (size > 1024) size = 1024;
            byte[] data = new byte[size];
            in.read(data);
            in.close();

            int ascii = 0;
            int other = 0;

            for (int i = 0; i < data.length; i++) {
                byte b = data[i];
                if (b < 0x09) return true;

                if (b == 0x09 || b == 0x0A || b == 0x0C || b == 0x0D) ascii++;
                else if (b >= 0x20 && b <= 0x7E) ascii++;
                else other++;
            }

            return other != 0 && 100 * other / (ascii + other) > 95;

        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
298630
protected function isVersioned()
    {
        if (!class_exists(Versioned::class)) {
            return false;
        }
        /** @var Versioned|DataObject $singleton */
        $singleton = DataObject::singleton($this->getBaseClass());
        return $singleton->hasExtension(Versioned::class) && $singleton->hasStages();
    }
662342
protected function isFilename($source): bool
    {
        if (!is_string($source)) {
            return false;
        }

        if (!preg_match('/[^A-Za-z0-9.#\\-$]/', $source)) {
            return false;
        }

        //To filter out binary strings
        $source = strval(str_replace("\0", "", $source));

        return file_exists($source);
    }
1311913
public function hasValidSourceFile()
    {
        $sourcefile = $this->getSourceFile();

        return (true === is_readable($sourcefile) && false === is_dir($sourcefile));
    }
77514
protected function checkCacheVersion()
    {
        $fileName = $this->getVersionFileName();

        if (!file_exists($fileName)) {
            return false;
        }

        $version = md5($this->boltVersion);
        $cached = file_get_contents($fileName);

        if ($version === $cached) {
            return true;
        }
        $this->versionChange = true;

        return false;
    }
719402
public function isBirthSourced(){
		if($this->is_birth_sourced !== null) return $this->is_birth_sourced;
		$this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT);
		return $this->is_birth_sourced;
	}
892756
function getData()
	{
		$buffer = 4096;

		// Return data stored in memory
		if (isset($this->_data)) {
			$tmp   = $this->_data;
			unset($this->_data);
			return $tmp;
		}
		// No data to return
		return false;
	}
896330
public function isDirectory(): bool {
		if ($this->isRoot()) {
			return true;
		}

		$content = $this->manager->listContents(
			$this->getParent()->getUrl(),
			false
		);

		return count(
				array_filter(
					$content,
					function ($item) {
						if ($item["basename"] == $this->getName()) {
							return $item["type"] == "dir";
						}

						return false;
					}
				)
			) === 1;
	}
1087488
public function isSuccess()
	{
		$data = $this->getData();

		if (!$data) {
			return false;
		}

		if (isset($data['error'])) {
			return false;
		}

		return true;
	}
1024124
private function guessBinaryPath()
    {
        $p = new Process(sprintf('which %s', $this->binaryName));
        $p->run();
        $output = trim($p->getOutput());
        if ('' === $output) {
            throw new \RuntimeException('binary path not found. Is Pygments installed?');
        }

        return $output;
    }
798580
private function saveData(): bool
    {
        if ($cacheTime = $this->getMeta()->getCache()) {
            return Cache::set(
                $this->key,
                $this->getData(),
                $cacheTime,
                ['system', 'data']
            );
        }
        return false;
    }
613707
protected function readByte()
    {
        if (feof($this->fileHandler)) {
            return false;
        }

        $data = unpack('C1byte', fread($this->fileHandler, 1));
        $this->currentByte = $data['byte'];
        $this->currentBitPosition = 0;

        return true;
    }