Enter description here ...

@param  PhingFile|string $path
@param  boolean $isDirectory
@return string
431936
public function _slashify($path, $isDirectory)
    {
        $p = (string) $path;

        if (self::$separator !== '/') {
            $p = str_replace(self::$separator, '/', $p);
        }

        if (!StringHelper::startsWith('/', $p)) {
            $p = '/' . $p;
        }

        if (!StringHelper::endsWith('/', $p) && $isDirectory) {
            $p .= '/';
        }

        return $p;
    }
1245871
public function getRealDir($path, $rootDir)
    {
        if (!is_string($path)) {
            return false;
        }

        if ($this->isRelativePath($path)) {
            return realpath($rootDir . DIRECTORY_SEPARATOR . dirname($path));
        }

        return realpath(dirname($path));
    }
288456
public function dir_opendir($path, $options)
    {
        $dirName = $this->_getNamePart($path).'/';
        if (preg_match('@^([a-z0-9+.]|-)+://$@', $path) || $dirName == '/') {
            $list = $this->_getOssClient($path)->listObjects(AliyunOSS::getBucket());
        } else {
            $list = $this
                ->_getOssClient($path)
                ->listObjects(AliyunOSS::getBucket(), [
                    OssClient::OSS_PREFIX => $dirName,
                ]);
        }

        foreach ((array) $list->getPrefixList() as $l) {
            array_push($this->_bucketList, basename($l->getPrefix()));
        }

        foreach ((array) $list->getObjectList() as $l) {
            if ($l->getKey() == $dirName) {
                continue;
            }

            array_push($this->_bucketList, basename($l->getKey()));
        }

        return $this->_bucketList !== false;
    }
125721
protected function find($paths, $file, $isGlob = false)
    {
        $paths = (array)$paths;
        $file = ltrim($file, "\\/");

        foreach ($paths as $path) {
            $fullPath = $this->clean($path . '/' . $file);

            if ($isGlob) {
                $paths = glob($fullPath, GLOB_BRACE);
                $paths = array_filter((array)$paths);
                return $paths ?: [];
            }

            if (file_exists($fullPath) || is_dir($fullPath)) {
                return $fullPath;
            }
        }

        return null;
    }
1340924
public static function findFile($filename, $dirs, $isInclude = false)
    {
        if (empty($filename)) {
            return false;
        }
        foreach (array_reverse((array) $dirs) as $ns => $dir) {
            if ($dir === false) {
                continue;
            }
            if($isInclude && is_numeric($ns)) {
                $ns = '';
            }
            if ($pathname = self::path($filename, $dir)) {
                return $isInclude ? array($pathname, $ns) : $pathname;
            }
        }
        return false;
    }
1041524
function isDirectory(filePath, callback) {
  try {
    fs.stat(filePath, function (err, data) {
      if (err) {
        callback(null, false);
      } else {
        callback(null, data.isDirectory());
      }
    });
  } catch (e) {
    callback(null, false);
  }
}
676250
public static function getNamespaceByPath($path, $is_dir = true)
    {
        // when relational path.
        if ($path[0] !== '/')
            return null;
        
        $root_ns = '';
        $filepath = $path;
        foreach (self::$namespaces as $p => $ns) {
            if (strpos($path, $p) !== false) {
                $root_ns = $ns;
                $filepath = substr($path, strlen($p) + 1);
                break;
            }
        }

        $ns = $filepath ? explode(DS, $filepath) : [];
        if (! $is_dir)
            array_pop($ns);
        array_unshift($ns, $root_ns);

        return join('\\', $ns);
    }
598257
public static function isOwner($path)
	{
		$tmp = md5(mt_rand());
		$ssp = ini_get('session.save_path');
		$jtp = JPATH_ROOT . '/tmp';

		// Try to find a writable directory
		$dir = is_writable('/tmp') ? '/tmp' : false;
		$dir = (!$dir && is_writable($ssp)) ? $ssp : false;
		$dir = (!$dir && is_writable($jtp)) ? $jtp : false;

		if ($dir)
		{
			$test = $dir . '/' . $tmp;

			// Create the test file
			$blank = '';
			File::write($test, $blank, false);

			// Test ownership
			$return = (fileowner($test) == fileowner($path));

			// Delete the test file
			File::delete($test);

			return $return;
		}

		return false;
	}
718992
public function cd($path)
    {
        $path = $this->realpath($path);
        if ($path !== false && is_dir($path)) {
            return $this->path = $path;
        }

        return false;
    }
14582
public static function isDir($path)
    {
        return (self::isPhar($path) === true) ? file_exists($path) : is_dir($path);
    }
481208
private function getPhpFilesFromPath(string $path)
    {
        $directoryIterator = new RecursiveDirectoryIterator($path);
        foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
            if (! in_array($file->getExtension(), $this->fileExtensions)) {
                continue;
            }

            if ($this->fileShouldBeIgnored($file)) {
                continue;
            }

            $this->files->push(new File(['displayPath' => $file->getPathName(), 'fullPath' => $file->getRealPath()]));
        }
    }
414058
public function getDirectories(string $path, bool $isRecursive = false) : array
    {
        if (!$this->isDirectory($path)) {
            return [];
        }

        $directories = [];
        $iter = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::SELF_FIRST,
            RecursiveIteratorIterator::CATCH_GET_CHILD
        );

        if (!$isRecursive) {
            $iter->setMaxDepth(0);
        }

        foreach ($iter as $path => $item) {
            if ($item->isDir()) {
                $directories[] = $path;
            }
        }

        return $directories;
    }
217266
static function scanDirectory($dirPath)
    {
        if (!is_dir($dirPath)) return false;
        $dirPath = realpath($dirPath) . '/';
        $dirs = array( $dirPath );

        $fileContainer = array();
        $dirContainer = array();

        try {
            do {
                $workDir = array_pop($dirs);
                $scanResult = scandir($workDir);
                foreach ($scanResult as $files) {
                    if ($files == '.' || $files == '..') continue;
                    $realPath = $workDir . $files;
                    if (is_dir($realPath)) {
                        array_push($dirs, $realPath . '/');
                        $dirContainer[] = $realPath;
                    } elseif (is_file($realPath)) {
                        $fileContainer[] = $realPath;
                    }
                }
            } while ($dirs);
        } catch (\Throwable $throwable) {
            return false;
        }

        return [ 'files' => $fileContainer, 'dirs' => $dirContainer ];
    }
771691
public function isdir(string $path): Promise
    {
        if (!@\file_exists($path)) {
            return new Success(false);
        }

        $isDir = @\is_dir($path);
        \clearstatcache(true, $path);

        return new Success($isDir);
    }
1023401
public static function files($path, $recursive = false, $toArray = false)
    {
        /**
         * Files callback
         *
         * @param \SplFileInfo                $current  Current item's value
         * @param string                      $key      Current item's key
         * @param \RecursiveDirectoryIterator $iterator Iterator being filtered
         *
         * @return boolean   TRUE to accept the current item, FALSE otherwise
         */
        $callback = function ($current, $key, $iterator) {
            return $current->isFile();
        };

        return static::findByCallback($path, $callback, $recursive, $toArray);
    }
1114421
private static function normalizerPath($path, $isfolder = False) {

		if (preg_match('/^\//', $path) == 0) {
            $path = '/' . $path;
        }
		
		if ($isfolder == True)
		{
			if (preg_match('/\/$/', $path) == 0) {
				$path = $path . '/';
			}
		}

		return $path;
	}
164121
function is_file($path)
    {
        $result = $this->_get_stat_cache_prop($path, 'type');
        if ($result === false) {
            return false;
        }
        return $result === NET_SFTP_TYPE_REGULAR;
    }