public function countFiles($dirName, $foldersOnly = false, $nonEmptyCheckOnly = false)
 {
     if ($foldersOnly) {
         return 0;
     }
     // WILL USE IMAP FUNCTIONS TO COUNT;
     $tmpHandle = opendir($dirName);
     $this->logDebug("COUNT : " . imapAccessWrapper::getCurrentDirCount());
     return imapAccessWrapper::getCurrentDirCount();
 }
 public function dir_readdir()
 {
     if ($this->mailboxes) {
         if ($this->pos < 0) {
             return false;
         } else {
             $obj = $this->mailboxes[$this->pos];
             $this->pos--;
             $x = $obj->name;
             $x = mb_convert_encoding($x, "UTF-8", "UTF7-IMAP");
             $x = str_replace(self::$currentRef, "", $x);
             $mainCacheDir = defined('AJXP_SHARED_CACHE_DIR') ? AJXP_SHARED_CACHE_DIR : AJXP_CACHE_DIR;
             if (!isset(self::$delimiter) && !file_exists($mainCacheDir . "/access.imap/mailbox_delim_" . $this->repositoryId)) {
                 if (!is_dir($mainCacheDir . "/access.imap")) {
                     mkdir($mainCacheDir . "/access.imap");
                 }
                 file_put_contents($mainCacheDir . "/access.imap/mailbox_delim_" . $this->repositoryId, $obj->delimiter);
                 self::$delimiter = $obj->delimiter;
             }
             $x = str_replace($obj->delimiter, "__delim__", $x);
         }
     } else {
         if (self::$attachmentsMetadata != null) {
             if ($this->pos < 0) {
                 return false;
             }
             $x = self::$attachmentsMetadata[$this->pos]["x-attachment-id"];
             $this->pos--;
         } else {
             if ($this->pos < 1) {
                 return false;
             } else {
                 $x = $this->pos;
                 $this->pos--;
                 //$x .= "#header";
             }
         }
     }
     return $x;
 }