Search for the locale directory for different installations methods (eg: PEAR, Composer).

@var boolean|string The directory if found, or false when no valid directory is found
164517
protected static function _searchLocaleDirectory()
    {
        if (static::$_pearDirectory !== '@data_dir@') {
            $directory = static::$_pearDirectory . '/' . static::$_domain . '/locale';
            if (file_exists($directory)) {
                return $directory;
            }
        }

        $directories = static::_getSearchDirectories();
        foreach ($directories as $directory) {
            if (file_exists($directory)) {
                return $directory;
            }
        }

        return false;
    }
101826
function (directory, callback) {
        var that = this;
        fs.readdir(directory, function (err, files) {
            async.map(files, function langdir_iterator(file, next) {
                file = path.join(directory, file);
                fs.stat(file, function (err, stats) {
                    if (err || !stats.isDirectory()) return next(err);
                    var l = path.basename(file);
                    fs.readdir(file, function (err, files) {
                        if (err) return next(err);
                        async.map(files, function podir_iterator(file, next) {
                            file = path.join(directory, l, file);
                            fs.stat(file, function (err, stats) {
                                if (err || !stats.isFile()) return next(err);
                                that.loadLanguageFile(file, l, next);
                            });
                        }, next);
                    });
                });
            }, function langdir_done(err, results) {
                callback && callback(err);
            });
        });
    }
1051494
private function locateLanguageFile($localeID)
    {
        $localeIDAlternatives = $this->getLocaleIDAlternatives($localeID);
        $result = null;
        foreach ($localeIDAlternatives as $localeIDAlternative) {
            $languageFile = $this->getAppLanguageFilePath($localeIDAlternative);
            if (!is_file($languageFile)) {
                $languageFile = $this->getCoreLanguageFilePath($localeIDAlternative);
                if (!is_file($languageFile)) {
                    $languageFile = null;
                }
            }
            if ($languageFile !== null) {
                $result = $languageFile;
                break;
            }
        }

        return $result;
    }
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;
	}
530929
public static function find($name)
    {
        if (!is_dir(DOCROOT.PLUGIN_DIR.DIRECTORY_SEPARATOR.$name)) return false;
        if (!file_exists(DOCROOT.PLUGIN_DIR.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.PLUGIN_INFO)) return false;
        return new self($name);
    }
1099070
static function cacheDirectory()
    {
        $cacheDirectory =& $GLOBALS['eZTranslationCacheDirectory'];
        if ( !isset( $cacheDirectory ) )
        {
            $ini = eZINI::instance();
            $locale = $ini->variable( 'RegionalSettings', 'Locale' );

            $rootCacheDirectory = eZTranslationCache::rootCacheDirectory();
            $cacheDirectory = eZDir::path( array( $rootCacheDirectory, $locale ) );

        }
        return $cacheDirectory;
    }
1008454
String getJsDirectory(Map<String, String> options) {
		if (null != options) {
			if (options.containsKey(ProcessorConstants.DIRECTORY)) {
				return options.get(ProcessorConstants.DIRECTORY);
			}
		}
		return null;
	}
975331
def _get_translation_for_locale(self, locale):
        """"""
        translations = None

        for dirname in self.paths:
            # Load a single catalog.
            catalog = Translations.load(dirname, [locale], domain=self.domain)
            if translations is None:
                if isinstance(catalog, Translations):
                    translations = catalog
                continue

            try:
                # Merge catalog into global catalog
                translations.merge(catalog)
            except AttributeError:
                # Translations is probably NullTranslations
                if isinstance(catalog, NullTranslations):
                    current_app.logger.debug(
                        'Compiled translations seems to be missing'
                        ' in {0}.'.format(dirname))
                    continue
                raise

        return translations or NullTranslations()
593299
public boolean hasResource(String name, Locale locale) {
        name = UrlUtils.cleanName(name);
        locale = cleanLocale(locale);
        return stringLoader.exists(name, locale) || loader.exists(name, locale);
    }
540324
static function compilationDirectory()
    {
        if ( isset( $GLOBALS['eZTemplateCompilerSettings']['compilation-directory'] ) and
             $GLOBALS['eZTemplateCompilerSettings']['compilation-directory'] !== null )
        {
            return $GLOBALS['eZTemplateCompilerSettings']['compilation-directory'];
        }

        $compilationDirectory =& $GLOBALS['eZTemplateCompilerDirectory'];
        if ( !isset( $compilationDirectory ) )
        {
            $ini = eZINI::instance();
            $shareTemplates = $ini->hasVariable( 'TemplateSettings', 'ShareCompiledTemplates' ) ?
                                $ini->variable( 'TemplateSettings', 'ShareCompiledTemplates' ) == 'enabled' :
                                false;
            if ( $shareTemplates &&
                 $ini->hasVariable( 'TemplateSettings', 'SharedCompiledTemplatesDir' ) &&
                 trim( $ini->variable( 'TemplateSettings', 'SharedCompiledTemplatesDir' ) ) != '' )
            {
                $compilationDirectory = eZDir::path( array( $ini->variable( 'TemplateSettings', 'SharedCompiledTemplatesDir' ) ) );
            }
            else
            {
                $compilationDirectory = eZDir::path( array( eZSys::cacheDirectory(), 'template/compiled' ) );
            }
        }
        return $compilationDirectory;
    }
473147
static function getDir($dir = '.', $ext = NULL) {

		if($dir != '') {
			$dir = rtrim($dir, '/').'/';
		}
		try {
			$i = new \DirectoryIterator($dir);
		} catch (\Exception $e) {
			return false;
		}

		$files = array();

		foreach($i as $file) {
			$fn = $file->getFileName();
			if(!$file->isDot() && $file->isFile() && substr($fn, 0, 1) !== '.') {
				if(!isset($ext) || preg_match("~$ext\$~", $fn)) {
					$files[] = $fn;
				}
			}
		}

		return $files;
	}
79367
static function localeList( $asObject = false, $withVariations = true )
    {
        $locales =& $GLOBALS['eZLocaleLocaleStringList'];
        if ( !is_array( $locales ) )
        {
            $localeRegexp = eZLocale::localeRegexp( $withVariations, false );
            $locales = array();
            $dir = opendir( 'share/locale' );
            while( ( $file = readdir( $dir ) ) !== false )
            {
                if ( preg_match( "/^($localeRegexp)\.ini$/", $file, $regs ) )
                {
                    $locales[] = $regs[1];
                }
            }
            closedir( $dir );
            $locales = array_unique( $locales );
            sort( $locales );
            if ( $asObject )
            {
                $localeObjects = array();
                foreach ( $locales as $locale )
                {
                    $localeInstance = eZLocale::instance( $locale );
                    if ( $localeInstance )
                        $localeObjects[] = $localeInstance;
                }
                $locales = $localeObjects;
            }
        }
        return $locales;
    }
1204606
protected static function _getSearchDirectories()
    {
        $className = get_called_class();
        $class = new ReflectionClass($className);
        $basedir = dirname($class->getFilename());
        $depth = substr_count($className, '\\')
            ?: substr_count($className, '_');

        return array(
            /* Composer */
            $basedir . str_repeat('/..', $depth) . '/data/locale',
            /* Source */
            $basedir . str_repeat('/..', $depth + 1) . '/locale'
        );
    }
1005514
function chdir($dir)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        if ($dir[strlen($dir) - 1] != '/') {
            $dir.= '/';
        }

        // confirm that $dir is, in fact, a valid directory
        if ($this->_is_dir($dir)) {
            $this->pwd = $dir;
            return true;
        }

        $dir = $this->_realpath($dir, false);

        if ($this->_is_dir($dir)) {
            $this->pwd = $dir;
            return true;
        }

        if (!$this->_send_sftp_packet(NET_SFTP_OPENDIR, pack('Na*', strlen($dir), $dir))) {
            return false;
        }

        // see Net_SFTP::nlist() for a more thorough explanation of the following
        $response = $this->_get_sftp_packet();
        switch ($this->packet_type) {
            case NET_SFTP_HANDLE:
                $handle = substr($response, 4);
                break;
            case NET_SFTP_STATUS:
                $this->_logError($response);
                return false;
            default:
                user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS', E_USER_NOTICE);
                return false;
        }

        if (!$this->_send_sftp_packet(NET_SFTP_CLOSE, pack('Na*', strlen($handle), $handle))) {
            return false;
        }

        $response = $this->_get_sftp_packet();
        if ($this->packet_type != NET_SFTP_STATUS) {
            user_error('Expected SSH_FXP_STATUS', E_USER_NOTICE);
            return false;
        }

        extract(unpack('Nstatus', $this->_string_shift($response, 4)));
        if ($status != NET_SFTP_STATUS_OK) {
            $this->_logError($response, $status);
            return false;
        }

        $this->_save_dir($dir);

        $this->pwd = $dir;
        return true;
    }
691664
private function recursiveSearch($directory)
    {
        
		if (is_dir($directory)) {
	    	// We get the list of files and directories.
	    	if (($files = scandir($directory)) !== false) {
	    		
	    		foreach($files as $fd) {
	
	   		 		if (!preg_match("/^\./", $fd) &&  $fd != "ext") {
	   		 			// If it is a directory ...
	   		 			if (is_dir($directory . $fd. "/")) {
	   		 				$this->recursiveSearch($directory . $fd . "/");
		    			// If it is a file ...
	    				} else {
	    					// Retrieve from the file ...
	    					$this->getTranslationsInFile($directory . $fd);
	    				}
	   		 		}
	    			
	    		}
	    	}   	
		}
		
        
    }
1275001
private function locateLocal($key)
    {
        $composerConfig = $this->composer->getConfig();

        // Sorry for this, I couldn't find any way to get the path of the current root package
        $reflection = new \ReflectionClass($composerConfig);
        $property = $reflection->getProperty('baseDir');
        $property->setAccessible(true);

        $path = $property->getValue($composerConfig);

        $localComposerExtra = $this->composer->getPackage()->getExtra();

        if (array_key_exists($key, $localComposerExtra)) {
            $this->cache[$key] = [
                'found' => true,
                'config' => $localComposerExtra[$key],
                'path' => $path,
            ];

            return true;
        }

        return false;
    }
656030
private function hasLocale(string $locale): bool
    {
        assert(empty($locale) === false);

        $result = in_array($locale, $this->getLocales());

        return $result;
    }