public function fopen($path, $mode)
 {
     if ($source = $this->getSourcePath($path)) {
         switch ($mode) {
             case 'r+':
             case 'rb+':
             case 'w+':
             case 'wb+':
             case 'x+':
             case 'xb+':
             case 'a+':
             case 'ab+':
             case 'w':
             case 'wb':
             case 'x':
             case 'xb':
             case 'a':
             case 'ab':
                 $creatable = $this->isCreatable($path);
                 $updatable = $this->isUpdatable($path);
                 // if neither permissions given, no need to continue
                 if (!$creatable && !$updatable) {
                     return false;
                 }
                 $exists = $this->file_exists($path);
                 // if a file exists, updatable permissions are required
                 if ($exists && !$updatable) {
                     return false;
                 }
                 // part file is allowed if !$creatable but the final file is $updatable
                 if (pathinfo($path, PATHINFO_EXTENSION) !== 'part') {
                     if (!$exists && !$creatable) {
                         return false;
                     }
                 }
         }
         $info = array('target' => $this->getMountPoint() . $path, 'source' => $source, 'mode' => $mode);
         \OCP\Util::emitHook('\\OC\\Files\\Storage\\Shared', 'fopen', $info);
         return parent::fopen($path, $mode);
     }
     return false;
 }