static int extentCompare()

in hfs/extents.c [24:58]


static int extentCompare(BTKey* vLeft, BTKey* vRight) {
  HFSPlusExtentKey* left;
  HFSPlusExtentKey* right;
  
  left = (HFSPlusExtentKey*) vLeft;
  right =(HFSPlusExtentKey*) vRight;
  
  if(left->forkType < right->forkType) {
    return -1;
  } else if(left->forkType > right->forkType) {
    return 1;
  } else {
    if(left->fileID < right->fileID) {
      return -1;
    } else if(left->fileID > right->fileID) {
      return 1;
    } else {
      if(left->startBlock < right->startBlock) {
        return -1;
      } else if(left->startBlock > right->startBlock) {
        return 1;
      } else {
        /* do a safety check on key length. Otherwise, bad things may happen later on when we try to add or remove with this key */
        if(left->keyLength == right->keyLength) {
          return 0;
        } else if(left->keyLength < right->keyLength) {
          return -1;
        } else {
          return 1;
        }
        return 0;
      }
    }
  }
}