Find files

@return void
166704
public function findFiles()
    {
        $files = $this->getFilesystemDisk()->listContents($this->getFilesPath());
        foreach ($files as $fileData) {
            $this->addNewFileFromArray($fileData);
        }
    }
1208120
public function deleteFiles()
    {
        $files = [];
        foreach ([
            DIR_CONFIG_SITE . '/site_install.php',
            DIR_CONFIG_SITE . '/site_install_user.php',
        ] as $file) {
            if ($this->filesystem->isFile($file)) {
                OpCache::clear($file);
                $files[] = $file;
            }
        }
        if (!empty($files)) {
            $this->filesystem->delete($files);
        }
    }
402989
function find( array $filters = array(), $max = 20, $offset = 0 ) {
		// Sort by modified time, newest first
		$sort = function (\SplFileInfo $a, \SplFileInfo $b) {
			return strcmp($b->getMTime(), $a->getMTime());
		};

		// Loop through .json files, filter the metadata and stop when max is found.
		$i = 0;
		$results = array();
		
		$Finder = new \FilesystemIterator($this->dirname,
			\FilesystemIterator::KEY_AS_FILENAME
			| \FilesystemIterator::CURRENT_AS_FILEINFO
			| \FilesystemIterator::SKIP_DOTS);

		$files = array();
		foreach ( $Finder as $key=>$value ) {
			if ( pathinfo($key,PATHINFO_EXTENSION)=='json' ){
				$files[]= $value;
			}
		}
		usort($files,$sort);

		foreach ($files as $file) {
			if ($i++ < $offset && empty($filters)) {
				$results[] = null;
				continue;
			}
			$data = json_decode( file_get_contents($file->getRealPath()), true);
			$meta = $data['__meta'];
			unset($data);
			if ($this->filter($meta, $filters)) {
				$results[] = $meta;
			}
			if (count($results) >= ($max + $offset)) {
				break;
			}
		}

			$array = array_slice($results, $offset, $max);
		return $array;
	}
1362292
public function findFiles(FileNodeCollectionInterface $files)
    {
        return $files->filter(function (FileNode $file) {
            $metadata = $file->getMetadata();
            if ($metadata) {
                return ($this->filter->matches($file->getMetadata()));
            } else {
                return false;
            }
        });
    }
1261707
protected function _find()
    {
        if ($this->isInited()) {
            return;
        }
        $this->reset();
        foreach ($this->directories as $dir) {
            $this->_findByDirectory(
                UrlHelper::resolvePath($dir)
            );
        }
        $this->setInited(true);
    }
209992
public function getFileList()
	{
		$list	= array();
		foreach( $this->files as $file )
			$list[$file['name']]	= $file['size'];
		return $list;
	}
52507
public function findAllFiles(DirectoryPath $path = null)
    {
        if (null === $path) {
            $path = new DirectoryPath();
        }

        $finder = new Finder();
        $searchPath = $path->prepend($this->gitService->getRepositoryPath());

        $finder->in($searchPath->toAbsoluteString(DIRECTORY_SEPARATOR));

        $filePaths = [];

        foreach ($finder->files() as $file) {
            /** @var SplFileInfo $file */
            $filePaths[] = FilePath::parse('/' . $file->getRelativePathname())->prepend($path);
        }

        return $filePaths;
    }
898628
public function searchAndReplaceInFiles()
    {
        $directory = base_path('Modules/'.$this->module);

        $manager = new MountManager([
            'directory' => new Flysystem(new LocalAdapter($directory)),
        ]);

        $search = [
            'objects',
            'object',
            'Objects',
            'Object',
        ];
        $replace = [
            strtolower($this->module),
            strtolower(Str::singular($this->module)),
            $this->module,
            Str::singular($this->module),
        ];

        foreach ($manager->listContents('directory://', true) as $file) {
            if ($file['type'] === 'file') {
                $content = str_replace($search, $replace, $manager->read('directory://'.$file['path']));
                $manager->put('directory://'.$file['path'], $content);
            }
        }
    }
123229
public function findRequiredFiles(array $files)
    {
        foreach ($files as $file) {
            if (file_exists($this->plugin->directory.'/'.$file)) {
                $this->addSuccess(sprintf('Found required file: %s', $file));
            } else {
                $this->addError(sprintf('Failed to find required file: %s', $file));
            }
        }
    }
491720
protected function findFileAt($path)
    {
        try {
            $files = $this->fromDirectory('')
                ->withPrefix($path)
                ->withDelimiter('')
                ->limit(1)
                ->get();
        } catch (ApiRequestFailedException $e) {
            return;
        }

        return $files->get(0);
    }
705245
protected function findFiles()
    {
        $ds = new DirectoryScanner();
        $ds->setBasedir($this->dir);
        $ds->setIncludes(array('**/composer.json'));
        $ds->scan();
        return $ds->getIncludedFiles();
    }
741328
public function find(): self
    {
        $preparedPaths = \array_unique(
            \array_merge(
                $this->getPreparedPaths((array) $this->paths['psr0']),
                $this->getPreparedPaths((array) $this->paths['psr4']),
                $this->getPreparedPaths((array) $this->paths['classmap'])
            ),
            \SORT_STRING
        );

        $finder = Finder::create()
            ->files()
            ->in($preparedPaths)
            ->exclude($this->excludes)
            ->name('*.php')
            ->sortByName();

        if ($this->filter !== null) {
            $finder->filter($this->filter);
        }

        /** @var \SplFileInfo $file */
        foreach ($finder as $file) {
            $realPath  = (string) $file->getRealPath();

            $namespace = null;
            $tokens    = \token_get_all((string) \file_get_contents($realPath));

            foreach ($tokens as $key => $token) {
                if (\is_array($token)) {
                    if ($token[0] === \T_NAMESPACE) {
                        $namespace = self::getNamespace($key + 2, $tokens);
                    } elseif ($token[0] === \T_INTERFACE) {
                        $name = self::getName($key + 2, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->interfaces[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;
                    } elseif ($token[0] === \T_TRAIT) {
                        $name = self::getName($key + 2, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->traits[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;
                    } elseif ($token[0] === \T_ABSTRACT) {
                        $name = self::getName($key + 4, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->abstractClasses[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;

                        continue 2;
                    } elseif ($token[0] === \T_CLASS) {
                        $name = self::getName($key + 2, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->classes[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;
                    }
                }
            }

            unset($tokens);
            // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
            \gc_mem_caches();
        }

        return $this;
    }
914396
protected function determineInputFiles()
    {
        if (empty($this->route->getParameters()->files))
        {
            $this->setNotReady("No input files found.", null, 404);
            return;
        }

        if (is_array($this->route->getParameters()->files))
        {
            foreach ($this->route->getParameters()->files as $file)
            {
                $this->addFileObject((string) $file);
            }
        }
        else
        {
            $this->addFileObject((string) $this->route->getParameters()->files);
        }
    }
1195526
public function getFiles()
    {
        $finders = [
            MainConfigurationFinder::class,
            ContextualConfigurationFinder::class,
            PluginsConfigurationFinder::class,
        ];

        // Filter out non-existing folders
        $folders = $this->getFolders();
        if (!$folders) {
            return [];
        }

        $files = [];
        foreach ($folders as $folder) {
            foreach ($finders as $finder) {
                /** @var AbstractConfigurationFinder $finder */
                $finder = new $finder($this->files, $folder);
                $files = array_merge($files, $finder->getFiles());
            }
        }

        // Load consolidated configuration
        $folder = $this->paths->getRocketeerPath();
        if ($this->files->has($folder)) {
            $consolidated = new ConsolidatedConfigurationFinder($this->files, $folder);
            $files = array_merge($files, $consolidated->getFiles());
        }

        return $files;
    }
962477
public function actionFiles() {
		$sources = [];

		$currentSource = $this->getSource();

		foreach ($this->config->sources as $key => $source) {
			if ($this->request->source && $this->request->source !== 'default' && $currentSource !== $source && $this->request->path !== './') {
				continue;
			}

			if ($this->accessControl->isAllow($this->getUserRole(), $this->action, $source->getPath())) {
				$sources[$key] = $this->read($source);
			}


		}

		return [
			'sources' => $sources
		];
	}
1174559
protected function findFilePath()
    {
        $filename = static::FILE_NAME;

        foreach ($this->defaultLocations() as $location) {
            if (file_exists("{$location}/$filename")) {
                return $location;
            }
        }

        return $this->defaultFilePath();
    }
610617
public function find($view)
    {
        $view = str_replace('.', DIRECTORY_SEPARATOR, $view) . '.php';

        foreach ($this->locations as $location)
        {
            if (is_file($path = $location.'/'.$view)) {
                return $path;
            }
        }

        return false;
    }