if (!localFile) {  rv = Wallet_DefaultsDirectory(dirSpec); if (NS_FAILED(rv)) { return; } nsInputFileStream strm2(dirSpec + filename); strm = strm2; } if (!strm.is_open()) {  return; }
return;
wallet_ReadFromFile    (const char * filename, nsVoidArray*& list, PRBool localFile, PlacementType placement = AT_END) {  /* open input stream */  nsFileSpec dirSpec;  nsresult rv;  rv = Wallet_ProfileDirectory(dirSpec);  if (NS_FAILED(rv)) {    return;  }  nsInputFileStream strm(dirSpec + filename);  if (!strm.is_open()) {    if (!localFile) {      /* if we failed to download the file, see if an initial version of it exists */      rv = Wallet_DefaultsDirectory(dirSpec);      if (NS_FAILED(rv)) {        return;      }      nsInputFileStream strm2(dirSpec + filename);      strm = strm2;    }    if (!strm.is_open()) {      /* still not open so give up */      return;    }  }  /* read in the header */  if (filename == schemaValueFileName) {    if (!wallet_GetHeader(strm)) {      /* something's wrong -- ignore the file */      strm.close();      return;    }  }  for (;;) {    static nsAutoString item1;    item1.Truncate(0);    if (NS_FAILED(wallet_GetLine(strm, item1))) {      /* end of file reached */      break;    }#ifdef AutoCapture    /* Distinguished schema list is a list of single entries, not name/value pairs */    if (PL_strcmp(filename, distinguishedSchemaFileName) == 0) {      nsVoidArray* dummy = NULL;      wallet_WriteToList(item1, item1, dummy, list, PR_FALSE, placement);      continue;    }#endif    static nsAutoString item2;    item2.Truncate(0);    if (NS_FAILED(wallet_GetLine(strm, item2))) {      /* unexpected end of file reached */      break;    }    if (item2.Length()==0) {      /* the value must have been deleted */      nsVoidArray* dummy = NULL;      wallet_WriteToList(item1, item2, dummy, list, PR_FALSE, placement);      continue;    }    static nsAutoString item3;    item3.Truncate(0);    if (NS_FAILED(wallet_GetLine(strm, item3))) {      /* end of file reached */      nsVoidArray* dummy = NULL;      wallet_WriteToList(item1, item2, dummy, list, PR_FALSE, placement);      strm.close();      return;    }    if (item3.Length()==0) {      /* just a pair of values, no need for a sublist */      nsVoidArray* dummy = NULL;      wallet_WriteToList(item1, item2, dummy, list, PR_FALSE, placement);    } else {      /* need to create a sublist and put item2 and item3 onto it */      nsVoidArray * itemList = new nsVoidArray();      if (!itemList) {        break;      }      wallet_Sublist * sublist = new wallet_Sublist;      if (!sublist) {        break;      }      sublist->item.SetCapacity(item2.Length());      sublist->item = item2;      itemList->AppendElement(sublist);      sublist = new wallet_Sublist;      if (!sublist) {        break;      }      sublist->item.SetCapacity(item3.Length());      sublist->item = item3;      itemList->AppendElement(sublist);      /* add any following items to sublist up to next blank line */      static nsAutoString dummy2;      dummy2.Truncate(0);      for (;;) {        /* get next item for sublist */        item3.SetLength(0);        if (NS_FAILED(wallet_GetLine(strm, item3))) {          /* end of file reached */          wallet_WriteToList(item1, dummy2, itemList, list, PR_FALSE, placement);          strm.close();          return;        }        if (item3.Length()==0) {          /* blank line reached indicating end of sublist */          wallet_WriteToList(item1, dummy2, itemList, list, PR_FALSE, placement);          break;        }        /* add item to sublist */        sublist = new wallet_Sublist;        if (!sublist) {          break;        }        sublist->item = item3;        sublist->item.SetCapacity(item3.Length());        itemList->AppendElement(sublist);      }    }  }  strm.close();}