public function opendir($path)
 {
     if ($path == "" || $path == "/") {
         $path = $this->datadir . $path;
         $sharedItems = OC_Share::getItemsInFolder($path);
         if (empty($sharedItems)) {
             return false;
         } else {
             global $FAKEDIRS;
             $files = array();
             foreach ($sharedItems as $item) {
                 // If item is in the root of the shared storage provider and the item exists add it to the fakedirs
                 if (dirname($item['target']) . "/" == $path && $this->file_exists(basename($item['target']))) {
                     $files[] = basename($item['target']);
                 }
             }
             $FAKEDIRS['shared'] = $files;
             return opendir('fakedir://shared');
         }
     } else {
         $source = $this->getSource($path);
         if ($source) {
             $storage = OC_Filesystem::getStorage($source);
             $dh = $storage->opendir($this->getInternalPath($source));
             $modifiedItems = OC_Share::getItemsInFolder($source);
             if ($modifiedItems && $dh) {
                 $sources = array();
                 $targets = array();
                 // Remove any duplicate or trailing '/'
                 $path = preg_replace('{(/)\\1+}', "/", $path);
                 $targetFolder = rtrim($this->datadir . $path, "/");
                 foreach ($modifiedItems as $item) {
                     // If the item is in the current directory and the item exists add it to the arrays
                     if (dirname($item['target']) == $targetFolder && $this->file_exists($path . "/" . basename($item['target']))) {
                         // If the item was unshared from self, add it it to the arrays
                         if ($item['permissions'] == OC_Share::UNSHARED) {
                             $sources[] = basename($item['source']);
                             $targets[] = "";
                         } else {
                             $sources[] = basename($item['source']);
                             $targets[] = basename($item['target']);
                         }
                     }
                 }
                 // Don't waste time if there aren't any modified items in the current directory
                 if (empty($sources)) {
                     return $dh;
                 } else {
                     global $FAKEDIRS;
                     $files = array();
                     while (($filename = readdir($dh)) !== false) {
                         if ($filename != "." && $filename != "..") {
                             // If the file isn't in the sources array it isn't modified and can be added as is
                             if (!in_array($filename, $sources)) {
                                 $files[] = $filename;
                                 // The file has a different name than the source and is added to the fakedirs
                             } else {
                                 $target = $targets[array_search($filename, $sources)];
                                 // Don't add the file if it was unshared from self by the user
                                 if ($target != "") {
                                     $files[] = $target;
                                 }
                             }
                         }
                     }
                     $FAKEDIRS['shared'] = $files;
                     return opendir('fakedir://shared');
                 }
             } else {
                 return $dh;
             }
         }
     }
 }