Beispiel #1
0
 /**
  * @param IFile $file
  * @param bool $foldersFirst
  * @return int A negative value if the current file should be placed before $file,
  * zero (0) if they are equals, a positive value otherwise.
  */
 public function compareTo(IFile $file, $foldersFirst = false)
 {
     if ($foldersFirst) {
         $isDirThis = $this->isDirectory();
         $isDirFile = $file->isDirectory();
         if ($isDirThis && !$isDirFile) {
             return -1;
         } else {
             if ($isDirFile && !$isDirThis) {
                 return 1;
             }
         }
     }
     $urlParts = $file->getURLComponents();
     $urlParts['path'] = $file->getPathFromRoot();
     //needed to resolve the path (if relative)
     $absolutePathFile = AdvancedPathLib::buildURL($urlParts);
     $urlParts = $this->getURLComponents();
     $urlParts['path'] = $this->getPathFromRoot();
     //needed to resolve the path (if relative)
     $absolutePathThis = AdvancedPathLib::buildURL($urlParts);
     return utf8_strcasecmp($absolutePathThis, $absolutePathFile);
 }