if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) {   if (rv == NS_ERROR_FILE_NOT_FOUND) rv = NS_OK; return rv; }
pref_LoadPrefsInDir(nsIFile* aDir, char const *const *aSpecialFiles, PRUint32 aSpecialFilesCount){  nsresult rv, rv2;  PRBool hasMoreElements;  nsCOMPtr<nsISimpleEnumerator> dirIterator;  // this may fail in some normal cases, such as embedders who do not use a GRE  rv = aDir->GetDirectoryEntries(getter_AddRefs(dirIterator));  if (NS_FAILED(rv)) return rv;  rv = dirIterator->HasMoreElements(&hasMoreElements);  NS_ENSURE_SUCCESS(rv, rv);  nsCOMArray<nsIFile> prefFiles(INITIAL_PREF_FILES);  nsCOMArray<nsIFile> specialFiles(aSpecialFilesCount);  nsCOMPtr<nsIFile> prefFile;  while (hasMoreElements && NS_SUCCEEDED(rv)) {    nsCAutoString leafName;    rv = dirIterator->GetNext(getter_AddRefs(prefFile));    if (NS_FAILED(rv)) {      break;    }    prefFile->GetNativeLeafName(leafName);    NS_ASSERTION(!leafName.IsEmpty(), "Failure in default prefs: directory enumerator returned empty file?");    // Skip non-js files    if (StringEndsWith(leafName, NS_LITERAL_CSTRING(".js"))) {      PRBool shouldParse = PR_TRUE;      // separate out special files      for (PRUint32 i = 0; i < aSpecialFilesCount; ++i) {        if (leafName.Equals(nsDependentCString(aSpecialFiles[i]))) {          shouldParse = PR_FALSE;          // special files should be process in order; we put them into          // the array by index; this can make the array sparse          specialFiles.ReplaceObjectAt(prefFile, i);        }      }      if (shouldParse) {        prefFiles.AppendObject(prefFile);      }    }    rv = dirIterator->HasMoreElements(&hasMoreElements);  }  if (prefFiles.Count() + specialFiles.Count() == 0) {    NS_WARNING("No default pref files found.");    if (NS_SUCCEEDED(rv)) {      rv = NS_SUCCESS_FILE_DIRECTORY_EMPTY;    }    return rv;  }  prefFiles.Sort(pref_CompareFileNames, nsnull);    PRUint32 arrayCount = prefFiles.Count();  PRUint32 i;  for (i = 0; i < arrayCount; ++i) {    rv2 = openPrefFile(prefFiles[i]);    if (NS_FAILED(rv2)) {      NS_ERROR("Default pref file not parsed successfully.");      rv = rv2;    }  }  arrayCount = specialFiles.Count();  for (i = 0; i < arrayCount; ++i) {    // this may be a sparse array; test before parsing    nsIFile* file = specialFiles[i];    if (file) {      rv2 = openPrefFile(file);      if (NS_FAILED(rv2)) {        NS_ERROR("Special default pref file not parsed successfully.");        rv = rv2;      }    }  }  return rv;}