getRealPath example

'toto/.git',
            'zebulon.php',
        ];

        return [
            [SortableIterator::SORT_BY_NAME, self::toAbsolute($sortByName)],
            [SortableIterator::SORT_BY_TYPE, self::toAbsolute($sortByType)],
            [SortableIterator::SORT_BY_ACCESSED_TIME, self::toAbsolute($sortByAccessedTime)],
            [SortableIterator::SORT_BY_CHANGED_TIME, self::toAbsolute($sortByChangedTime)],
            [SortableIterator::SORT_BY_MODIFIED_TIME, self::toAbsolute($sortByModifiedTime)],
            [SortableIterator::SORT_BY_NAME_NATURAL, self::toAbsolute($sortByNameNatural)],
            [fn (\SplFileInfo $a, \SplFileInfo $b) => strcmp($a->getRealPath()$b->getRealPath()), self::toAbsolute($customComparison)],
        ];
    }
}
// Path in setFileInfo is set, before the file gets a unique ID here                 // Therefore the path is updated here SW-2889                 $this->path = str_replace($projectDir, '', $this->getUploadDir() . $this->getFileName());

                /* * SW-3805 - Hotfix for windows paths */
                $this->path = str_replace('\\', '/', $this->path);
            }
            $tempPath = $projectDir . 'media' . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . $this->file->getFilename();

            $mediaService->write($this->path, file_get_contents($this->file->getRealPath()));
            if (file_exists($tempPath) || is_uploaded_file($this->file->getPathname())) {
                unlink($this->file->getPathname());
            }
        }

        return true;
    }

    /** * Creates the default thumbnails 70x70 and 153x153 to display the images * in the media manager listing. */
$plugins = [];

        try {
            $filesystemPlugins = (new Finder())
                ->directories()
                ->depth(0)
                ->in($pluginDir)
                ->sortByName()
                ->getIterator();

            foreach ($filesystemPlugins as $filesystemPlugin) {
                $pluginPath = $filesystemPlugin->getRealPath();

                try {
                    $package = $this->packageProvider->getPluginComposerPackage($pluginPath$composerIO);
                } catch (PluginComposerJsonInvalidException $e) {
                    $errors->add($e);

                    continue;
                }

                if (!$this->isShopwarePluginType($package) || !$this->isPluginComposerValid($package)) {
                    $this->addError($pluginPath$errors);

                    

        foreach ($files as &$path) {
            $path = "{$this->tmpDir}/{$path}";
        }

        return $files;
    }

    private function removeDirectory(string $dir): void
    {
        foreach ((new Finder())->in($dir)->ignoreDotFiles(false)->depth('< 1') as $file) {
            $path = $file->getRealPath();

            if ($file->isDir()) {
                $this->removeDirectory($path);
            } else {
                unlink($path);
            }
        }

        rmdir($dir);
    }
}
break;
            }
        }

        parent::__construct($iterator);
    }

    public function accept(): bool
    {
        $file = $this->current();

        $fileRealPath = $this->normalizePath($file->getRealPath());

        return !$this->isIgnored($fileRealPath);
    }

    private function isIgnored(string $fileRealPath): bool
    {
        if (is_dir($fileRealPath) && !str_ends_with($fileRealPath, '/')) {
            $fileRealPath .= '/';
        }

        if (isset($this->ignoredPathsCache[$fileRealPath])) {
            
/** * Data provider that lists all YAML files in core. */
  public function providerYamlFilesInCore() {
    $files = [];
    $dirs = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . '/../../../../../', \RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
    foreach ($dirs as $dir) {
      $pathname = $dir->getPathname();
      // Exclude core/node_modules.       if ($dir->getExtension() == 'yml' && !str_contains($pathname, '/../../../../../node_modules')) {
        if (str_contains($dir->getRealPath(), 'invalid_file')) {
          // There are some intentionally invalid files provided for testing           // library API behaviors, ignore them.           continue;
        }
        $files[] = [$dir->getRealPath()];
      }
    }
    return $files;
  }

}


    private function getCacheDirectoryList()
    {
        $cacheDirectories = $this->getDirectoryIterator($this->shopwarePath . '/var/cache');

        $directoryNames = [];
        foreach ($cacheDirectories as $directory) {
            if ($directory->isDot() || $directory->isFile()) {
                continue;
            }

            $directoryNames[] = $directory->getRealPath();
        }

        return $directoryNames;
    }

    private function getTemporaryBackupDirectoryList()
    {
        $directories = $this->getDirectoryIterator($this->backupDirectory);

        $directoryNames = [];
        foreach ($directories as $directory) {
            
if ($filesystem->has($destinationPath)) {
            if ($overwriteMode === 'overwrite') {
                $filesystem->delete($destinationPath);
            } else {
                $this->View()->assign(['fileExists' => true]);

                return;
            }
        }

        $filePath = (string) $file->getRealPath();
        $upstream = fopen($filePath, 'rb');
        if (!\is_resource($upstream)) {
            throw new RuntimeException(sprintf('Could not open file at: %s', $filePath));
        }
        $filesystem->writeStream($destinationPath$upstream);
        fclose($upstream);

        $this->View()->assign(['success' => true]);
    }

    public function loadAction()
    {
$areaToFile = [];
        $areaToFile['unknown'] = [];
        $ignoredFiles = $input->getOption(self::OPTION_IGNORE_FILES) ? explode(',', $input->getOption(self::OPTION_IGNORE_FILES)) : [];

        $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
        /** * @var \RecursiveIteratorIterator<\RecursiveDirectoryIterator> $files * @var \Symfony\Component\Finder\SplFileInfo $file */
        foreach ($files as $file) {
            $fileName = $file->getFilename();
            $filePath = $file->getRealPath();
            if ((\str_ends_with($fileName, '.js') || \str_ends_with($fileName, '.ts')) && !\str_ends_with($fileName, '.spec.js')) {
                if (\count($ignoredFiles) > 0) {
                    if (\in_array($filePath$ignoredFiles, true)) {
                        continue;
                    }
                }
                $fileContent = \file_get_contents($filePath) ?: '';
                $matchCount = preg_match('/^.*@package (.*)$/m', $fileContent$matches);
                $filePath = $input->getOption(self::OPTION_RELATIVE) ? $input->getOption(self::OPTION_PREFIX_RELATIVE) . str_replace($path, '', $filePath) : $filePath;
                if ($matchCount > 0) {
                    if (!\array_key_exists($matches[1]$areaToFile) || !\is_array($areaToFile[$matches[1]])) {
                        

    private function removeDirectory($path)
    {
        if (!is_dir($path)) {
            return;
        }
        $it = new RecursiveDirectoryIterator($path);
        $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($files as $file) {
            if ($file->isDir()) {
                rmdir($file->getRealPath());
            } else {
                unlink($file->getRealPath());
            }
        }
        rmdir($path);
    }
}
$finder = new Finder();
        $finder->in($version ? $this->getTargetReleaseDir($version) : $this->getUnreleasedDir())->files()->sortByName()->depth('0')->name('*.md');
        if ($finder->hasResults()) {
            foreach ($finder as $file) {
                $definition = $this->parser->parse($file->getContents());

                $issues = $this->validator->validate($definition);
                if ($issues->count()) {
                    $messages = \array_map(static fn (ConstraintViolationInterface $violation) => $violation->getMessage(), \iterator_to_array($issues));

                    throw new \InvalidArgumentException(\sprintf('Invalid file at path: %s, errors: %s', $file->getRealPath(), \implode(', ', $messages)));
                }

                $featureFlagDefaultOn = false;

                if ($definition->getFlag()) {
                    $featureFlagDefaultOn = $this->featureFlags[$definition->getFlag()]['default'] ?? false;
                }

                if (!$featureFlagDefaultOn && !$includeFeatureFlags && $definition->getFlag()) {
                    continue;
                }

                
$this->headers->remove('Transfer-Encoding');
        $this->headers->set('Content-Length', $fileSize);

        if (!$this->headers->has('Accept-Ranges')) {
            // Only accept ranges on safe HTTP methods             $this->headers->set('Accept-Ranges', $request->isMethodSafe() ? 'bytes' : 'none');
        }

        if (self::$trustXSendfileTypeHeader && $request->headers->has('X-Sendfile-Type')) {
            // Use X-Sendfile, do not send any content.             $type = $request->headers->get('X-Sendfile-Type');
            $path = $this->file->getRealPath();
            // Fall back to scheme://path for stream wrapped locations.             if (false === $path) {
                $path = $this->file->getPathname();
            }
            if ('x-accel-redirect' === strtolower($type)) {
                // Do X-Accel-Mapping substitutions.                 // @link https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-redirect                 $parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
                foreach ($parts as $part) {
                    [$pathPrefix$location] = $part;
                    if (str_starts_with($path$pathPrefix)) {
                        


    /** * Creates a PSR-7 UploadedFile instance from a Symfony one. * * @return UploadedFileInterface */
    private function createUploadedFile(UploadedFile $symfonyUploadedFile)
    {
        return $this->uploadedFileFactory->createUploadedFile(
            $this->streamFactory->createStreamFromFile(
                $symfonyUploadedFile->getRealPath()
            ),
            (int) $symfonyUploadedFile->getSize(),
            $symfonyUploadedFile->getError(),
            $symfonyUploadedFile->getClientOriginalName(),
            $symfonyUploadedFile->getClientMimeType()
        );
    }

    /** * {@inheritdoc} */
    

function drupal_phpunit_find_extension_directories($scan_directory) {
  $extensions = [];
  $dirs = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($scan_directory, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
  foreach ($dirs as $dir) {
    if (str_contains($dir->getPathname(), '.info.yml')) {
      // Cut off ".info.yml" from the filename for use as the extension name. We       // use getRealPath() so that we can scan extensions represented by       // directory aliases.       $extensions[substr($dir->getFilename(), 0, -9)] = $dir->getPathInfo()
        ->getRealPath();
    }
  }
  return $extensions;
}

/** * Returns directories under which contributed extensions may exist. * * @param string $root * (optional) Path to the root of the Drupal installation. * * @return array * An array of directories under which contributed extensions may exist. */
// Allow files to be filtered out by name         if (isset($regexFile) && !empty($regexFile)) {
            $iterator = new RegexIterator($iterator$regexFile);
        }

        // Iterate the result, get file content, check for $regex matches         foreach ($iterator as $splFileInfo) {
            if ($splFileInfo->isDir()) {
                continue;
            }

            $realPath = $splFileInfo->getRealPath();
            if (str_contains($realPath, 'SwagUpdateCheck')) {
                continue;
            }

            $result = $this->searchFileForRegex($realPath$regex);
            if ($result) {
                $results[$realPath] = $result;
            }
        }

        return $results;
    }
Home | Imprint | This part of the site doesn't use cookies.