示例#1
0
文件: hfs.c 项目: carriercomm/osx-2
static long CompareHFSPlusCatalogKeys(void * key, void * testKey)
{
    HFSPlusCatalogKey *searchKey, *trialKey;
    long              result, searchParentID, trialParentID;
  
    searchKey = key;
    trialKey  = testKey;
  
    searchParentID = SWAP_BE32(searchKey->parentID);
    trialParentID  = SWAP_BE32(trialKey->parentID);

    // parent dirID is unsigned
    if (searchParentID > trialParentID)      result = 1;
    else if (searchParentID < trialParentID) result = -1;
    else {
        // parent dirID's are equal, compare names
        if ((searchKey->nodeName.length == 0) || (trialKey->nodeName.length == 0))
            result = searchKey->nodeName.length - trialKey->nodeName.length;
        else
          if (gCaseSensitive) {
            result = BinaryUnicodeCompare(&searchKey->nodeName.unicode[0],
                                          SWAP_BE16(searchKey->nodeName.length),
                                          &trialKey->nodeName.unicode[0],
                                          SWAP_BE16(trialKey->nodeName.length));
          } else {
            result = FastUnicodeCompare(&searchKey->nodeName.unicode[0],
                                        SWAP_BE16(searchKey->nodeName.length),
                                        &trialKey->nodeName.unicode[0],
                                        SWAP_BE16(trialKey->nodeName.length));
          }
    }

    return result;
}
示例#2
0
文件: catalog.c 项目: mucit/opensn0w
static int catalogCompareCS(BTKey* vLeft, BTKey* vRight) {
  HFSPlusCatalogKey* left;
  HFSPlusCatalogKey* right;
  
  left = (HFSPlusCatalogKey*) vLeft;
  right =(HFSPlusCatalogKey*) vRight;
   
  if(left->parentID < right->parentID) {
    return -1;
  } else if(left->parentID > right->parentID) {
    return 1;
  } else {
    return FastUnicodeCompare(left->nodeName.unicode, left->nodeName.length, right->nodeName.unicode, right->nodeName.length);
  }
}