@param Folder $folder

@return string
436399
public function addChildren(Folder $folder)
    {
        $ids = '';
        foreach ($folder->getChildren() as $child) {
            $ids .= ' and folder.id != '.$child->getId();
            $ids .= $this->addChildren($child);
        }

        return $ids;
    }
1172257
protected function getPluginPaths(Folder $Folder, $plugin) {
		$res = $Folder->find('Queue.+Task\.php');
		foreach ($res as $key => $r) {
			$name = basename($r, 'Task.php');
			if (in_array($name, $this->tasks)) {
				unset($res[$key]);
				continue;
			}
			$res[$key] = $plugin . '.' . $name;
		}

		return $res;
	}
973385
public function getStatusInfo( $folder = NULL )
	{
		$address	= $this->connection->getAddress( $folder );
		$info		= imap_status( $this->connection->getStream(), $address, SA_ALL );
		if( !$info )
			throw new Exception( "imap_status() failed: ". imap_lasterror() );
		return array(
			"messages"	=> $info->messages,
			"recent"	=> $info->recent,
			"unseen"	=> $info->unseen,
		);
	}
168030
protected function getIterator($folder)
    {
        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($folder,
                \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST,
            \RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
        );
        $files = new RegexIterator($iterator, '/^.+Exception\.php$/i', RecursiveRegexIterator::GET_MATCH);

        return $files;
    }
593962
public function createFolderJson(Folder $folder)
    {
        $size = self::ICON_SIZE;
        $file = Injector::inst()->get('File');

        return array(
            'id' => $folder->ID,
            'parentID' => $folder->ParentID,
            'title' => $folder->Title,
            'filename' => $folder->Filename,
            'type' => 'folder',
            'extension' => self::FOLDER_EXTENSION,
            'created' => $folder->Created,
            'iconURL' => $folder->getPreviewThumbnail($size, $size)->URL,
            'canEdit' => $folder->canEdit(),
            'canCreate' => $folder->canCreate(),
            'canDelete' => $folder->canDelete(),
            'canUpload' => $folder->canEdit() && $file->canCreate()
        );
    }
43009
private function _subfolder(): string
    {
        if ($this->subfolder && ($subfolder = rtrim(Craft::parseEnv($this->subfolder), '/')) !== '') {
            return $subfolder . '/';
        }
        return '';
    }
1200269
private function getBundleClassnameFromFolder($folderName)
    {
        if (substr($folderName, -6) == 'Bundle') {
            $folderName = substr($folderName, 0, -6);
        }

        return sprintf(self::BUNDLE_NAME_MASK, $folderName);
    }
1187513
public static function delFolder($bucket, $folder) {
        if (empty($bucket) || empty($folder)) {
            return array(
                    'code' => COSAPI_PARAMS_ERROR,
                    'message' => 'bucket or path is empty');
        }

        $folder = self::normalizerPath($folder, True);

        return self::delBase($bucket, $folder);
    }
948118
public function folder_info($folder)
    {
        if ($this->icache['options'] && $this->icache['options']['name'] == $folder) {
            return $this->icache['options'];
        }

        // get cached metadata
        $cache_key = 'mailboxes.folder-info.' . $folder;
        $cached = $this->get_cache($cache_key);

        if (is_array($cached)) {
            return $cached;
        }

        $acl       = $this->get_capability('ACL');
        $namespace = $this->get_namespace();
        $options   = array();

        // check if the folder is a namespace prefix
        if (!empty($namespace)) {
            $mbox = $folder . $this->delimiter;
            foreach ($namespace as $ns) {
                if (!empty($ns)) {
                    foreach ($ns as $item) {
                        if ($item[0] === $mbox) {
                            $options['is_root'] = true;
                            break 2;
                        }
                    }
                }
            }
        }
        // check if the folder is other user virtual-root
        if (!$options['is_root'] && !empty($namespace) && !empty($namespace['other'])) {
            $parts = explode($this->delimiter, $folder);
            if (count($parts) == 2) {
                $mbox = $parts[0] . $this->delimiter;
                foreach ($namespace['other'] as $item) {
                    if ($item[0] === $mbox) {
                        $options['is_root'] = true;
                        break;
                    }
                }
            }
        }

        $options['name']       = $folder;
        $options['attributes'] = $this->folder_attributes($folder, true);
        $options['namespace']  = $this->folder_namespace($folder);
        $options['special']    = $this->is_special_folder($folder);

        // Set 'noselect' flag
        if (is_array($options['attributes'])) {
            foreach ($options['attributes'] as $attrib) {
                $attrib = strtolower($attrib);
                if ($attrib == '\noselect' || $attrib == '\nonexistent') {
                    $options['noselect'] = true;
                }
            }
        }
        else {
            $options['noselect'] = true;
        }

        // Get folder rights (MYRIGHTS)
        if ($acl && ($rights = $this->my_rights($folder))) {
            $options['rights'] = $rights;
        }

        // Set 'norename' flag
        if (!empty($options['rights'])) {
            $options['norename'] = !in_array('x', $options['rights']) && !in_array('d', $options['rights']);

            if (!$options['noselect']) {
                $options['noselect'] = !in_array('r', $options['rights']);
            }
        }
        else {
            $options['norename'] = $options['is_root'] || $options['namespace'] != 'personal';
        }

        // update caches
        $this->icache['options'] = $options;
        $this->update_cache($cache_key, $options);

        return $options;
    }
1298510
public static function GetFirstExisting( string $folder ) : string
   {

      // Remove directory separator from $folder end
      $folder = \rtrim( $folder, '\\/' );

      if ( \Niirrty\strContains( $folder, '/' ) && \Niirrty\strContains( $folder, '\\' ) )
      {
         // Uses mixed directory separators, normalize it
         if ( \DIRECTORY_SEPARATOR == '\\' )
         {
            $folder = \str_replace( '/', '\\', $folder );
         }
         else
         {
            $folder = \str_replace( '\\', '/', $folder );
         }
      }

      // Get the current sub folder level
      $level =
         \count(
            \explode(
               \DIRECTORY_SEPARATOR,
               \ltrim( $folder, '\\/' )
            )
         );

      for ( $i = 0; $i < $level && ! \is_dir( $folder ); ++$i )
      {
          $f = \dirname( $folder );
          if ( empty( $f ) || $f == $folder )
          {
             return '/';
          }
          $folder = $f;
      }

      \clearstatcache();

      return $folder;

   }
590262
protected function normalizeFolderInfo(array & $folder, $localizer)
    {
        if(empty(array_get($folder, 'type')) && !empty(array_get($folder, 'path'))){
            $folder['type'] = 'dir';
        }
        parent::normalizeFolderInfo($folder, $localizer);
        $folder['last_modified'] = gmdate('D, d M Y H:i:s \G\M\T', array_get($folder, 'timestamp', 0));
        unset($folder['timestamp']);
    }
1140416
public function get_set($folder)
    {
        foreach ($this->sets as $set) {
            if ($set->get_parameters('MAILBOX') == $folder) {
                return $set;
            }
        }

        return false;
    }
489231
public function folder(Folder $folder = null)
    {
        if (is_null($folder)) {
            return $this->folder;
        }

        $this->folder = $folder;

        return $this;
    }
1044975
public function folder_attributes($folder, $force=false)
    {
        // get attributes directly from LIST command
        if (!empty($this->conn->data['LIST']) && is_array($this->conn->data['LIST'][$folder])) {
            $opts = $this->conn->data['LIST'][$folder];
        }
        // get cached folder attributes
        else if (!$force) {
            $opts = $this->get_cache('mailboxes.attributes');
            $opts = $opts[$folder];
        }

        if (!is_array($opts)) {
            if (!$this->check_connection()) {
                return array();
            }

            $this->conn->listMailboxes('', $folder);
            $opts = $this->conn->data['LIST'][$folder];
        }

        return is_array($opts) ? $opts : array();
    }
22337
private function getUniqueFileName(string $folder, string $fileName, int $counter = 0): string
    {
        $newFileName = $fileName;

        if ($counter > 0) {
            $fileNameParts = explode('.', $fileName, 2);
            $newFileName = $fileNameParts[0] . '-' . $counter;

            if (isset($fileNameParts[1])) {
                $newFileName .= '.' . $fileNameParts[1];
            }
        }

        $filePath = $this->getPathByFolderAndFileName($folder, $newFileName);

        $this->logger->debug('Check FilePath: ' . $filePath);

        if (!$this->filesystem->exists($filePath)) {
            return $newFileName;
        }

        ++$counter;

        return $this->getUniqueFileName($folder, $fileName, $counter);
    }
608513
public function filesFrom($folder, $extension)
    {

        $all_files  = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($folder));
        $files = new \RegexIterator($all_files, '/\.'.$extension.'$/');
        $fileList = array();
        foreach ($files as $file) {
            $fileList[$file->getPathName()]['path'] = $file->getPathName();
            $fileList[$file->getPathName()]['name'] = $file->getFileName();
        }
        return $fileList;
    }
645915
public static function statFolder($bucket, $folder) {
        $folder = self::normalizerPath($folder, True);

        return self::statBase($bucket, $folder);
    }