Checks if the passed directory is the contrib module we are looking for.

@param \SplFileInfo $dir
The info object about the directory.
@return bool
TRUE if the contrib is detected. FALSE otherwise.
327181
protected function isWantedContrib(\SplFileInfo $dir) {
    $info_file = $this->cleanDirPath($dir->getPathName()) . DIRECTORY_SEPARATOR . $this->moduleName . '.info';
    return file_exists($info_file);
  }
541670
private function isDir($directory)
    {
        if ('/' === $directory) {
            return true;
        }

        if (!@ftp_chdir($this->getConnection(), $directory)) {
            return false;
        }

        // change directory again to return in the base directory
        ftp_chdir($this->getConnection(), $this->directory);

        return true;
    }
59005
public static function isEmptyDir($dir)
    {
        $handle = opendir($dir);
        if($handle){
            $item = readdir($handle);
            while($item){
                if ($item != "." && $item != ".."){
                    @closedir($handle);
                    return false;
                }
                $item = readdir($handle);
            }
        }
        return true;
    }
829739
private function inPath($dir)
    {
        $PATH = getenv('PATH');
        $realpath = realpath($dir);
        if (!$PATH || !$realpath) {
            return false;
        }

        return in_array($realpath, explode(':', $PATH));
    }
864272
private boolean isSipServletDirectory(File dir) {
		 if(dir.isDirectory()) {
			 //Fix provided by Thomas Leseney for exploded directory deployments
			File sipXmlFile = new File(dir.getAbsoluteFile(), SipContext.APPLICATION_SIP_XML);
			if(sipXmlFile.exists()) {
				return true;
			}
			if(SipApplicationAnnotationUtils.findPackageInfoinDirectory(dir)) return true;
		}		
		return false;
	}
409955
public function clearDirectory($dir)
    {
        if (empty($dir) || !@is_dir($dir)) {
            return false;
        }

        $iterator = new \RecursiveDirectoryIterator($dir);
        $filter = new \RecursiveCallbackFilterIterator($iterator, function ($current) {
            /** @var \SplFileInfo $current */
            $filename = $current->getBasename();
            // Check for files and dirs starting with "dot" (.gitignore, etc)
            return !($filename && $filename[0] === '.');
        });

        /** @var \SplFileInfo[] $listing */
        $listing = new \RecursiveIteratorIterator($filter, \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($listing as $item) {
            $path = $item->getPathname();
            $item->isDir() ? rmdir($path) : unlink($path);
        }
        return true;
    }
396558
public function hasDirectory($id)
    {
        $fsConfig = $this->getOption(self::OPTION_ADAPTERS);
        return isset($fsConfig[$id]);
    }
294212
private function createDirIfNotExists(string $dir): bool
    {
        if (!is_dir($dir)) {
            try {
                set_error_handler(function($errno, $errstr, $errfile, $errline) {
                    restore_error_handler();
                    throw new \IvoPetkov\ObjectStorage\ErrorException($errstr, 0, $errno, $errfile, $errline);
                });
                $result = mkdir($dir, 0777, true);
                restore_error_handler();
                return (bool) $result;
            } catch (\IvoPetkov\ObjectStorage\ErrorException $e) {
                if ($e->getMessage() !== 'mkdir(): File exists') { // The directory may be just created in other process.
                    throw $e;
                }
            }
        }
        return true;
    }
465996
public function built($dir)
    {
        $file = $dir . '/index.php';
        if ($this->fs->exists($file)) {
            $f = fopen($file, 'r');
            $beginning = fread($f, 3178);
            fclose($f);
            if (strpos($beginning, 'Drupal') !== false) {
                return true;
            }
        }
        return false;
    }
82817
public static function rmDir($dir)
    {
        if (!file_exists($dir)) {
            return true;
        }
        if (!is_dir($dir)) {
            return unlink($dir);
        }
        foreach (scandir($dir) as $item) {
            if ($item == '.' || $item == '..') {
                continue;
            }
            if (!Paths::rmDir($dir . DIRECTORY_SEPARATOR . $item)) {
                return false;
            }

        }
        return rmdir($dir);
    }
850404
protected function removeDir(\SplFileInfo $dir, $alsoRemoveFiles = true)
    {

        // clean up the directory
        $this->getService()->cleanUpDir($dir, $alsoRemoveFiles);

        // check if the directory exists, if not return immediately
        if ($dir->isDir() === false) {
            return;
        }

        // delete the directory itself if empty
        @rmdir($dir->getPathname());
    }
1322679
public static function isEmpty($dir)
    {
        $handle = opendir($dir);
        $i      = 0;
        while (false !== ($file = readdir($handle))) {
            $i++;
        }

        closedir($handle);

        if ($i >= 2) {
            return false;
        } else {
            return true;
        }
    }
757298
public function isExtension($directory)
    {
        $returnValue = (bool) false;

        
        $hasStructure = $this->findStructureManifest($directory) !== false;
        $hasPHPManifest = false;
        
        $files = scandir($this->options['input']);
        if ($files !== false) {
        	foreach ($files as $f) {
				if (is_file($this->options['input'] . '/' .$f) && is_readable($this->options['input'] . '/' . $f)) {
					if ($f == 'manifest.php') {
						$hasPHPManifest = true;
					}
				}
        	}
        }
        
        $returnValue = $hasStructure || $hasPHPManifest;
        

        return (bool) $returnValue;
    }
44861
static function isFileInDir($file,$dir) {
		if (!Strings::endsWith($dir, "/")) $dir.="/";
		return Strings::startsWith($file, $dir);
	}
1342275
public function checkWritableI18nDirectory($dir)
    {
        if (file_exists($dir)) {
            return is_writable($dir);
        }

        $parentDir = dirname($dir);

        return file_exists($parentDir) && is_writable($parentDir);
    }
692538
function mkdir($dir)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        if ($dir[0] != '/') {
            $dir = $this->_realpath(rtrim($dir, '/'));
            if ($dir === false) {
                return false;
            }
            if (!$this->_mkdir_helper($dir)) {
                return false;
            }
        } else {
            $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $dir));
            $temp = '';
            foreach ($dirs as $dir) {
                $temp.= '/' . $dir;
                $result = $this->_mkdir_helper($temp);
            }
            if (!$result) {
                return false;
            }
        }

        return true;
    }
200016
protected function clearDir($dir)
    {
        $iterator = new \DirectoryIterator($dir);
        foreach ($iterator as $file) {

            if ($file->isDir() && !$file->isDot() && !preg_match("~\.~", $file)) {
                $this->clearDir($file->getPathname());
                if (!\rmdir($file->getPathname())) {
                    return false;
                }
            } elseif ($file->isFile()) {
                if (!\unlink($file->getPathname())) {
                    return false;
                }
            }
        }

        return true;
    }