Set file path hash.

@since 1.1.4

@param string $filePath → file path

@return string
421556
private static function setHash($filePath)
    {
        if (stristr(php_uname('s'), 'WIN')) {
            $filePath = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $filePath);
        }

        return md5($filePath);
    }
176076
protected function isAbsolutePath($filePath)
    {
        if ($filePath === null || $filePath === '') {
            return false;
        }
    
        if ($filePath[0] === DIRECTORY_SEPARATOR || preg_match('~\A[A-Z]:(?![^/\\\\])~i', $filePath) > 0) {
            return true;
        }
    
        return false;
    }
875912
final public function createFile($filePath = null)
    {
        if (isset($filePath)) {
            $this->filePath = $filePath;
        }

        if (pathinfo($this->filePath, PATHINFO_EXTENSION) === '') {
            $this->filePath .= $this->fileExtension;
        }

        return $this;
    }
305532
public function setFilePath($path) {
		$path = realpath($path);
		
		if ($path === false) {
			throw new NoPath('Invalid path: ' . $path);
		}
		
		$this->path = $path;
		
		return $this;
	}
642781
private function fileRelativePath($path)
    {
        $path = $this->fileWebpath($path);
        // @todo This wont work for files not located on the current server...
        $path = str_replace_first(env('APP_URL'), '', $path);
        $path = str_replace(' ', '%20', $path);

        return $path;
    }
757340
public static function get($filePath)
    {
        $fileName = basename($filePath);
        if (!array_key_exists($fileName, static::$files)) {
            try {
                $file = new File($filePath);
            } catch (\Exception $e) {
                $file = false;
            }

            static::$files[$fileName] = $file;
        }

        return static::$files[$fileName];
    }
1090473
def hash_file(filepath: str) -> str:
    """"""
    md5 = hashlib.md5()
    acc_hash(filepath, md5)
    return md5.hexdigest()
1201519
protected function getRootRelatedPath(string $filePath): string
    {
        return $this->getRootDirectory() . DIRECTORY_SEPARATOR . trim($filePath, DIRECTORY_SEPARATOR);
    }
756114
public function setRestorePath($filePath)
    {
        $path = realpath(dirname($filePath));
        if (!file_exists($path)) {
            throw new FilesystemException(sprintf(
                'The restore phar does not exist: %s.', $path
            ));
        }
        if (!is_readable($path)) {
            throw new FilesystemException(sprintf(
                'The restore file is not readable: %s.', $path
            ));
        }
        $this->restorePath = $filePath;
    }
884013
public function filePath($path)
    {
        $file = $this->realPath($path);
        if (!is_file($file)) {
            throw new \InvalidArgumentException(sprintf('The path is not a file: %s', $file));
        }

        return $path;
    }
389145
public function store_destfile_from_path($filepath) {
        if ($record = $this->get_file_record()) {
            $fs = get_file_storage();
            $existing = $fs->get_file(
                $record['contextid'],
                $record['component'],
                $record['filearea'],
                $record['itemid'],
                $record['filepath'],
                $record['filename']
            );
            if ($existing) {
                $existing->delete();
            }
            $file = $fs->create_file_from_pathname($record, $filepath);

            $this->raw_set('destfileid', $file->get_id());
        }

        return $this;
    }
109035
public function setPath(string $path)
    {
        $path = '/' . ltrim($path, '/');
        $this->query = null;
        $this->fragment = null;
        if (preg_match('/^(.*?)(\\?([^#]*))?(#(.*))?$/u', $path, $matches))
        {
            $path = $matches[1];
            $this->query = !empty($matches[3]) ? $matches[3] : null;
            $this->fragment = !empty($matches[5]) ? $matches[5] : null;
        }

        $this->path = $path;
        return $this;
    }
1200729
public function setPath($path)
    {
        static $search  = [' ',   '?'];
        static $replace = ['%20', '%3F'];
        $this->path = str_replace($search, $replace, $path);

        return $this;
    }
1315587
protected function initHandle($filePath)
    {
        if ($this->hasHandle()) {
            rewind($this->handle);

            return $this->handle;
        }

        $this->handle = $this->createHandle($filePath);

        return $this->handle;
    }
1000410
protected function getNestedDirectoryDots(string $path, string $filePath) : string
    {
      if (substr($filePath, -1) !== DIRECTORY_SEPARATOR) {
        $filePath = $filePath . DIRECTORY_SEPARATOR;
      }

      // Generate dots if it's a nested file
      if ($nested = trim(str_replace($path, '', $filePath), DIRECTORY_SEPARATOR)) {
          $nested = str_replace(DIRECTORY_SEPARATOR, '.', $nested).'.';
      }

      return $nested;
    }
357617
public function getProjectPath(string $filePath): string
    {
        $rootPath = $this->getRootApplicationDirectoryPathByFilePath($filePath);

        $path = rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        $path .= implode(DIRECTORY_SEPARATOR, [
            'src',
            'Pyz',
            'Zed',
        ]);

        return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
    }
791385
public function setLogFile($filePath)
    {
        if ($this->logFile != $filePath && $this->fp) {
            @fclose($this->fp);
            $this->fp = null;
        }
        $logDir = dirname($filePath);
        if (!file_exists($logDir)) {
            @mkdir($logDir, 0755, true);
        }

        if (!file_exists($logDir)) {
            throw new Exception(sprintf('Can\'t create log directory "%s".', $logDir), 'logger');
        }

        if (!$this->fp = @fopen($filePath, 'a+')) {
            throw new Exception(sprintf('Can\'t create log file "%s".', $filePath), 'logger');
        }

        $this->logFile = $filePath;
        return $this;
    }