Generates ID from directory/file name.

@param string $dirOrFile
@return string
775434
static public function createPathID($dirOrFile)
    {
        $absPath = realpath($dirOrFile);
        if(is_dir($absPath)){
            $id = md5('d'.$absPath);
        }elseif(is_file($absPath)){
            $id = md5('f'.$absPath);
        }else{
            // if not dir or file, returns original $dirOrFile value
            $id = md5($dirOrFile);
        }
        return $id;
    }
5072
private function deleteDir($dirPath)
	{
		if (!is_dir($dirPath)) {
			$success = unlink($dirPath);
		} else {
			$success = true;
			foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) {
				$path = $dirPath . DIRECTORY_SEPARATOR . $path;
				if(is_link($path)) {
					unlink($path);
				} else if (is_dir($path)) {
					$success = rmdir($path);
				} else {
					$success = unlink($path);
				}
				if (!$success) {
					break;
				}
			}
			if($success) {
				$success = rmdir($dirPath);
			}
		}
		if(!$success) {
			$this->setError(elFinder::ERROR_RM, $dirPath);
			return false;
		}
		return $success;
	}
1286966
public function url_to_id($url){
    if ( $file = $this->url_to_real($url) ){
      return $this->real_to_id($file);
    }
    return false;
  }
410575
protected function getDirectoryRelativeToFile(string $configFile, ?string $directory = null): ?string
    {
        if (!$directory) {
            return null;
        }

        $path = realpath(dirname($configFile) . '/' . $directory);

        if (false !== $path) {
            return $path;
        }

        return $directory;
    }
1123276
private function getPhonePrefixLanguagePairFromFilename($outputFile)
    {
        $parts = explode(DIRECTORY_SEPARATOR, $outputFile);

        $returnObj = new \stdClass();
        $returnObj->language = $parts[0];

        $returnObj->prefix = $this->getCountryCodeFromTextFileName($parts[1]);

        return $returnObj;
    }
595
public function getId()
    {
        if ($output = $this->execute('fsutil file queryfileid', $this->path)) {
                if ((bool) preg_match('/(\d{1}[x].*)/', $output[0], $matches)) {
                return $matches[0];
            }
        }
    }
1059167
public static function createDir($dirPath, $mode = 0711)
    {
        if (false === file_exists($dirPath)) {
            if (false === mkdir($dirPath, $mode, true)) {
                throw new RuntimeException(sprintf('unable to create directory "%s"', $dirPath));
            }
        }
    }
1184355
static function  rebasedFilename($file,$from,$to) {
		if (!Strings::startsWith($file, $from)) {
			throw new \InvalidArgumentException("File $file is not in directory $from");
		}
		$secondPart=Strings::substring($file, Strings::length($from));
		if ($secondPart[0]=="/") $secondPart=substr($secondPart,1);
		$newPath=$to."/".$secondPart;
		return $newPath;
	}
1013026
public static function enumAll($dirPath)
    {
        if (!is_dir($dirPath)) {
            return new \ArrayIterator();
        }
        $iterator = new \RecursiveDirectoryIterator($dirPath, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
        $files = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);
        return $files;
    }
154433
public function generateId()
    {
        return sprintf(
            '%08X-%04X-%04X-%02X%02X-%012X',
            mt_rand(),
            mt_rand(0, 65535),
            bindec(substr_replace(
                sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4)
            ),
            bindec(substr_replace(sprintf('%08b', mt_rand(0, 255)), '01', 5, 2)),
            mt_rand(0, 255),
            mt_rand()
        );
    }
263805
static function delete($dirOrFile) {
        if (is_file($dirOrFile)) {
            @unlink($dirOrFile);
            return true;
        }
        if (!$handle = @opendir($dirOrFile)) {
            return false;
        }
        while (false !== ($file = readdir($handle))) {
            if ($file !== "." && $file !== "..") {       //排除当前目录与父级目录
                $file = $dirOrFile . '/' . $file;
                if (is_dir($file)) {
                    self::delete($file);
                } else {
                    @unlink($file);
                }
            }

        }
        @rmdir($dirOrFile);
        return true;
    }
913185
protected function getModuleId($filePath)
    {
        preg_match(
            '/.*(protected|public|private)\s\$id\s=\s(\'|\")(?P<id>.*)(\'|\")\;.*/',
            file_get_contents($filePath),
            $matches
        );

        if (array_key_exists('id', $matches) && isset($matches['id']{0})) {
            return $matches['id'];
        } else {
            return false;
        }
    }
98431
protected function generateFilename(UploadedFile $uploadedFile)
    {
        // Retrieve original file name
        $filePath = $uploadedFile->getClientOriginalName();

        // Parse URL
        $filePath = pathinfo($filePath);

        // Sanitize filename
        $filename = preg_replace('/[^a-z0-9_-]/ui', '', $filePath['filename']);

        // Append random sting and extension to filename
        $filename .= '_'.Str::random(10);

        return $filename;
    }
321333
public static function rmdir( $dirPath, $force = false )
    {
        $_path = rtrim( $dirPath ) . DIRECTORY_SEPARATOR;

        if ( !$force )
        {
            return rmdir( $_path );
        }

        if ( !is_dir( $_path ) )
        {
            throw new \InvalidArgumentException( '"' . $_path . '" is not a directory or bogus in some other way.' );
        }

        $_files = glob( $_path . '*', GLOB_MARK );

        foreach ( $_files as $_file )
        {
            if ( is_dir( $_file ) )
            {
                static::rmdir( $_file, true );
            }
            else
            {
                unlink( $_file );
            }
        }

        return rmdir( $_path );
    }
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 ];
    }
272465
public function generateId()
    {
        $data = openssl_random_pseudo_bytes(16);
        $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
        $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10

        return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
    }
515251
public function store($dirId)
    {

        $parentDir = $this->getDirOrFail($dirId);

        if (!$dirName = Input::get('folderName')) {
            $this->flashMessage('dirname-missing');
            return $this->redirectTo('index', $dirId);
        }

        $dir = $this->fileDB->create();
        $dir->setMimeType('inode/directory');

        $dir->setDir($parentDir);
        $dir->setName($dirName);
        $this->fileDB->save($dir);

        return $this->redirectTo('index', [$dir->getId()]);

    }