Read, cache and return a directory specific local configuration

@param string $dirname Directory name

@return array Directory specific local configuration
326714
protected static function getLocalConfiguration($dirname)
    {
        if (is_dir($dirname) && empty(self::$localConfigurations[$dirname])) {
            $localConfig                         = $dirname.DIRECTORY_SEPARATOR.'local.json';
            self::$localConfigurations[$dirname] = file_exists($localConfig) ?
                (array)@\json_decode(file_get_contents($localConfig)) : [];
        }

        return self::$localConfigurations[$dirname];
    }
424769
public function createDir($dirname, array $config = [])
    {
        list($prefix, $dirname) = $this->getPrefixAndPath($dirname);

        return $this->getFilesystem($prefix)->createDir($dirname);
    }
834446
public static function load(string $filename = 'my-addresses.php'): array
    {
        $file = (new static())->getDirectoryPaths()
            ->map(function ($path) use ($filename) {
                return $path . $filename;
            })
            ->first(function ($file) {
                return file_exists($file);
            });

        if (!$file) {
            throw new PartialNotFoundException(vsprintf('%s does not exist.', [
            $filename,
          ]));
        }

        return include $file;
    }
165666
protected function readData($fileName)
    {
        $client   = new Client([ 'defaults' => [ 'timeout' => $this->getConfiguration()->getTimeout() ] ]);
        $response = $client->get($fileName);

        return $response->getBody();
    }
861726
public function dir_readdir()
  {
    $each = each($this->_dirFiles);

    if ($each === false) {
      $result = false;
    } else {
      $result = $each["value"];
    }

    return $result;
  }
1218373
private function _read($filename, $directory = null)
    {
        $cache_path = $this->config->get('cache_path');

        if (is_null($directory)) {
            $path = $cache_path.$this->config->get('object_dir').$filename.'.cache';
        } else {
            $path = $cache_path.$directory.$filename.'.cache';
        }

        // nope. not here.
        if ( ! file_exists($path)) return null;

        $fh = @fopen($path, 'rb');
        flock($fh, LOCK_SH);

        // read out the expiration date
        $use_before_date = fread($fh, 10);

        // still a valid cache object or is it stale?
        if ($use_before_date < time()) return null;

        $data = fread($fh, filesize($path));

        flock($fh, LOCK_UN);
        fclose($fh);

        return $data;
    }
671809
public function rmdir(string $dirName): bool
    {
        return unlink($this->fileInfo->getAbsoluteFilePath() . MDir::getSeparator() . $dirName);
    }
667649
public static function read(string $dir = '', ?string $pattern = null): array
    {
        $ret = ['subdirs' => [], 'files' => []];
        $dir = static::normalizePath($dir);

        if (static::exists($dir) && ($handle = @\opendir($dir))) {
            while (false !== ($item = @\readdir($handle))) {
                if (!\in_array($item, ['.', '..']) && ($pattern === null || \preg_match($pattern, $item))) {
                    $item = $dir.DIRECTORY_SEPARATOR.$item;
                    if (\is_dir($item)) {
                        $ret['subdirs'][] = $item;
                    } elseif (\is_file($item)) {
                        $ret['files'][] = $item;
                    }
                }
            }
            @\closedir($handle);
        }

        return $ret;
    }
1342627
private function getFiles($dirs, $fileName, $dist = false)
    {
        $finder = new Finder();
        $fileName .= '.{php,inc,ini,properties,yaml,yml,xml,json}';

        if (true === $dist) {
            $fileName .= '.dist';
        }

        $finder->in($dirs)->depth(0)->files()->name($fileName);
        $files = iterator_to_array($finder);

        if (count($files) > 1) {
            throw new InvalidArgumentException('Propel expects only one configuration file');
        }

        return $files;
    }
1264881
protected function getStubDirPath($dirName)
    {
        if (is_dir($path = base_path("resources/stubs/vendor/crud-generator/{$this->stubsGroup}/$dirName/"))) {
            return $path;
        }

        if (is_dir($path = __DIR__."/../resources/stubs/{$this->stubsGroup}/$dirName/")) {
            return $path;
        }

        return '';
    }
281170
public function deleteDir($dirname)
    {
        $result = $this->client->deleteObject([
            'Bucket' => $this->getBucket(),
            'Key'    => $dirname.'/',
        ]);

        return (bool) $result;
    }
1231018
public function deleteDir(string $dirname): bool
    {
        $location = $this->applyBasePath($dirname);

        if (! is_dir($location)) {
            throw new DirectoryNotExistsException($dirname);
        }

        $contents = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($location, FilesystemIterator::SKIP_DOTS),
            RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($contents as $file) {
            if ($file->isReadable()) {
                switch ($file->getType()) {
                    case 'dir':
                        rmdir($file->getRealPath());
                        break;
                    case 'link':
                        unlink($file->getPathname());
                        break;
                    default:
                        unlink($file->getRealPath());
                        break;
                }
            }
        }

        unset($contents);

        return rmdir($location);
    }
640901
public function get($cacheName)
    {
        $value = $this->redis->get($cacheName);

        if ($value) {
            $value = gzinflate($value);
        }

        $jsonData = json_decode($value, true);
        return ($jsonData === NULL) ? $value : $jsonData;
    }
540830
public static function split($fileName)
    {
        $ext = pathinfo($fileName);
        return [
            $ext['dirname'],
            $ext['filename'],
            empty($ext['extension']) ? '' : $ext['extension']
        ];
    }
247659
public function addFolder( $dirName )
	{
		if( !file_exists( $dirName ) )
			return FALSE;
		$fileInfo = stat( $dirName );													// Get folder information
		$this->numFolders++;															// Add folder to processed data
		$activeDir				= &$this->folders[];
		$activeDir['name']		= $dirName;
		$activeDir['mode']		= $fileInfo['mode'];
		$activeDir['time']		= $fileInfo['mtime'];
		$activeDir['user_id']	= $fileInfo['uid'];
		$activeDir['group_id']	= $fileInfo['gid'];
#		$activeDir['checksum']	= $checksum;
		return TRUE;
	}
288294
public function isDirectory($dirname)
    {
        $listing = $this->listDirectoryContents();

        $dirname_info = array_filter($listing, function ($item) use ($dirname) {
            return $item['type'] === 'directory' && $item['name'] === $dirname;
        });

        return count($dirname_info) !== 0;
    }
602139
public static function load($directoryName = 'filters'): array
    {
        $files = static::getFilePattern($directoryName);

        return collect(glob($files))
            ->map(function ($filename) {
                return include $filename;
            })
            ->flatten(1)
            ->toArray();
    }