resources/src/main/java/org/robolectric/res/android/CppAssetManager.java
boolean scanAndMergeDirLocked(Ref<SortedVector<AssetDir.FileInfo>> pMergedInfoRef,
      final asset_path ap, final String rootDir, final String dirName) {
    SortedVector<AssetDir.FileInfo> pMergedInfo = pMergedInfoRef.get();
    assert (pMergedInfo != null);

    //printf("scanAndMergeDir: %s %s %s\n", ap.path.string(), rootDir, dirName);

    String8 path = createPathNameLocked(ap, rootDir);
    if (dirName.charAt(0) != '\0') {
      path.appendPath(dirName);
    }

    SortedVector<AssetDir.FileInfo> pContents = scanDirLocked(path);
    if (pContents == null) {
      return false;
    }

    // if we wanted to do an incremental cache fill, we would do it here

      /*
       * Process "exclude" directives.  If we find a filename that ends with
       * ".EXCLUDE", we look for a matching entry in the "merged" set, and
       * remove it if we find it.  We also delete the "exclude" entry.
       */
    int i, count, exclExtLen;

    count = pContents.size();
    exclExtLen = kExcludeExtension.length();
    for (i = 0; i < count; i++) {
      final String name;
      int nameLen;

      name = pContents.itemAt(i).getFileName().string();
      nameLen = name.length();
      if (name.endsWith(kExcludeExtension)) {
        String8 match = new String8(name, nameLen - exclExtLen);
        int matchIdx;

        matchIdx = AssetDir.FileInfo.findEntry(pMergedInfo, match);
        if (matchIdx > 0) {
          ALOGV("Excluding '%s' [%s]\n",
              pMergedInfo.itemAt(matchIdx).getFileName().string(),
              pMergedInfo.itemAt(matchIdx).getSourceName().string());
          pMergedInfo.removeAt(matchIdx);
        } else {
          //printf("+++ no match on '%s'\n", (final char*) match);
        }

        ALOGD("HEY: size=%d removing %d\n", (int) pContents.size(), i);
        pContents.removeAt(i);
        i--;        // adjust "for" loop
        count--;    //  and loop limit
      }
    }

    mergeInfoLocked(pMergedInfoRef, pContents);

    return true;
  }
boolean scanAndMergeDirLocked(Ref<SortedVector<AssetDir.FileInfo>> pMergedInfoRef,
      final asset_path ap, final String rootDir, final String dirName) {
    SortedVector<AssetDir.FileInfo> pMergedInfo = pMergedInfoRef.get();
    assert (pMergedInfo != null);

    //printf("scanAndMergeDir: %s %s %s\n", ap.path.string(), rootDir, dirName);

    String8 path = createPathNameLocked(ap, rootDir);
    if (dirName.charAt(0) != '\0') {
      path.appendPath(dirName);
    }

    SortedVector<AssetDir.FileInfo> pContents = scanDirLocked(path);
    if (pContents == null) {
      return false;
    }

    // if we wanted to do an incremental cache fill, we would do it here

      /*
       * Process "exclude" directives.  If we find a filename that ends with
       * ".EXCLUDE", we look for a matching entry in the "merged" set, and
       * remove it if we find it.  We also delete the "exclude" entry.
       */
    int i, count, exclExtLen;

    count = pContents.size();
    exclExtLen = kExcludeExtension.length();
    for (i = 0; i < count; i++) {
      final String name;
      int nameLen;

      name = pContents.itemAt(i).getFileName().string();
      nameLen = name.length();
      if (name.endsWith(kExcludeExtension)) {
        String8 match = new String8(name, nameLen - exclExtLen);
        int matchIdx;

        matchIdx = AssetDir.FileInfo.findEntry(pMergedInfo, match);
        if (matchIdx > 0) {
          ALOGV("Excluding '%s' [%s]\n",
              pMergedInfo.itemAt(matchIdx).getFileName().string(),
              pMergedInfo.itemAt(matchIdx).getSourceName().string());
          pMergedInfo.removeAt(matchIdx);
        } else {
          //printf("+++ no match on '%s'\n", (final char*) match);
        }

        ALOGD("HEY: size=%d removing %d\n", (int) pContents.size(), i);
        pContents.removeAt(i);
        i--;        // adjust "for" loop
        count--;    //  and loop limit
      }
    }

    mergeInfoLocked(pMergedInfoRef, pContents);

    return true;
  }
/*
Scan the contents of the specified directory and merge them into the
"pMergedInfo" vector, removing previous entries if we find "exclude"
directives.

Returns "false" if we found nothing to contribute.