Example #1
0
File: node.php Project: evanjt/core
 /**
  * @return string
  */
 public function getDavPermissions()
 {
     $p = '';
     if ($this->info->isShared()) {
         $p .= 'S';
     }
     if ($this->info->isShareable()) {
         $p .= 'R';
     }
     if ($this->info->isMounted()) {
         $p .= 'M';
     }
     if ($this->info->isDeletable()) {
         $p .= 'D';
     }
     if ($this->info->isDeletable()) {
         $p .= 'NV';
         // Renameable, Moveable
     }
     if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
         if ($this->info->isUpdateable()) {
             $p .= 'W';
         }
     } else {
         if ($this->info->isCreatable()) {
             $p .= 'CK';
         }
     }
     return $p;
 }
Example #2
0
 /**
  * Comparator function to sort files alphabetically and have
  * the directories appear first
  *
  * @param \OCP\Files\FileInfo $a file
  * @param \OCP\Files\FileInfo $b file
  * @return int -1 if $a must come before $b, 1 otherwise
  */
 public static function compareFileNames(FileInfo $a, FileInfo $b)
 {
     $aType = $a->getType();
     $bType = $b->getType();
     if ($aType === 'dir' and $bType !== 'dir') {
         return -1;
     } elseif ($aType !== 'dir' and $bType === 'dir') {
         return 1;
     } else {
         return \OCP\Util::naturalSortCompare($a->getName(), $b->getName());
     }
 }
Example #3
0
 /**
  * Comparator function to sort files alphabetically and have
  * the directories appear first
  *
  * @param \OCP\Files\FileInfo $a file
  * @param \OCP\Files\FileInfo $b file
  * @return int -1 if $a must come before $b, 1 otherwise
  */
 public static function compareFileNames($a, $b)
 {
     $aType = $a->getType();
     $bType = $b->getType();
     if ($aType === 'dir' and $bType !== 'dir') {
         return -1;
     } elseif ($aType !== 'dir' and $bType === 'dir') {
         return 1;
     } else {
         return strnatcasecmp($a->getName(), $b->getName());
     }
 }