nsOutputFileStream strm(dirSpec + signonFileName);
nsOutputFileStream strm(dirSpec + signonFileName, nsOutputFileStream::kDefaultMode, 0600);
si_SaveSignonDataLocked(char * state, PRBool notify) {  si_SignonURLStruct * url;  si_SignonUserStruct * user;  si_SignonDataStruct * data;  si_Reject * reject;  /* do nothing if signon list has not changed */  if(!si_signon_list_changed) {    return(-1);  }#ifdef APPLE_KEYCHAIN  if (KeychainManagerAvailable()) {    return si_SaveSignonDataInKeychain();  }#endif  /* do nothing if we are unable to open file that contains signon list */  nsFileSpec dirSpec;  nsresult rv = Wallet_ProfileDirectory(dirSpec);  if (NS_FAILED(rv)) {    return 0;  }  nsOutputFileStream strm(dirSpec + signonFileName);  if (!strm.is_open()) {    return 0;  }  /* write out the format revision number */  si_WriteLine(strm, NS_ConvertASCIItoUCS2(HEADER_VERSION));  /* format for next part of file shall be:   * passwordRealm -- first url/username on reject list   * userName   * passwordRealm -- second url/username on reject list   * userName   * ...     -- etc.   * .       -- end of list   */  /* write out reject list */  if (si_reject_list) {    PRInt32 rejectCount = LIST_COUNT(si_reject_list);    for (PRInt32 i=0; i<rejectCount; i++) {      reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(i));      si_WriteLine(strm, NS_ConvertASCIItoUCS2(reject->passwordRealm));    }  }  si_WriteLine(strm, NS_LITERAL_STRING("."));  /* format for cached logins shall be:   * url LINEBREAK {name LINEBREAK value LINEBREAK}*  . LINEBREAK   * if type is password, name is preceded by an asterisk (*)   */  /* write out each URL node */  if((si_signon_list)) {    PRInt32 urlCount = LIST_COUNT(si_signon_list);    for (PRInt32 i2=0; i2<urlCount; i2++) {      url = NS_STATIC_CAST(si_SignonURLStruct*, si_signon_list->ElementAt(i2));      /* write out each user node of the URL node */      PRInt32 userCount = url->signonUser_list.Count();      for (PRInt32 i3=0; i3<userCount; i3++) {        user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list.ElementAt(i3));        si_WriteLine          (strm, NS_ConvertASCIItoUCS2(url->passwordRealm));        /* write out each data node of the user node */        PRInt32 dataCount = user->signonData_list.Count();        for (PRInt32 i4=0; i4<dataCount; i4++) {          data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list.ElementAt(i4));          if (data->isPassword) {            si_WriteChar(strm, '*');          }          si_WriteLine(strm, nsAutoString(data->name));          si_WriteLine(strm, nsAutoString(data->value));        }        si_WriteLine(strm, NS_LITERAL_STRING("."));      }    }  }  si_signon_list_changed = PR_FALSE;  strm.flush();  strm.close();  /* Notify signon manager dialog to update its display */  if (notify) {    nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));    if (os) {      os->NotifyObservers(nsnull, "signonChanged", NS_ConvertASCIItoUCS2(state).get());    }  }  return 0;}