nsOutputFileStream strm(dirSpec + kCookiesPermFileName);
dirSpec += kCookiesPermFileName; PRBool ignored; dirSpec.ResolveSymlink(ignored); nsOutputFileStream strm(dirSpec);
Permission_Save(PRBool notify) {  permission_HostStruct * hostStruct;  permission_TypeStruct * typeStruct;  if (!permission_changed) {    return;  }  if (permission_list == nsnull) {    return;  }  nsFileSpec dirSpec;  nsresult rval = CKutil_ProfileDirectory(dirSpec);  if (NS_FAILED(rval)) {    return;  }  nsOutputFileStream strm(dirSpec + kCookiesPermFileName);  if (!strm.is_open()) {    return;  }#define PERMISSIONFILE_LINE1 "# HTTP Permission File\n"#define PERMISSIONFILE_LINE2 "# http://www.netscape.com/newsref/std/cookie_spec.html\n"#define PERMISSIONFILE_LINE3 "# This is a generated file!  Do not edit.\n\n"  strm.write(PERMISSIONFILE_LINE1, PL_strlen(PERMISSIONFILE_LINE1));  strm.write(PERMISSIONFILE_LINE2, PL_strlen(PERMISSIONFILE_LINE2));  strm.write(PERMISSIONFILE_LINE3, PL_strlen(PERMISSIONFILE_LINE3));  /* format shall be:   * host \t permission \t permission ... \n   */    PRInt32 hostCount = permission_list->Count();  for (PRInt32 i = 0; i < hostCount; ++i) {    hostStruct = NS_STATIC_CAST(permission_HostStruct*, permission_list->ElementAt(i));    if (hostStruct) {      strm.write(hostStruct->host, strlen(hostStruct->host));      PRInt32 typeCount = hostStruct->permissionList->Count();      for (PRInt32 typeIndex=0; typeIndex<typeCount; typeIndex++) {        typeStruct = NS_STATIC_CAST          (permission_TypeStruct*, hostStruct->permissionList->ElementAt(typeIndex));        strm.write("\t", 1);        nsCAutoString tmp; tmp.AppendInt(typeStruct->type);        strm.write(tmp.get(), tmp.Length());        if (typeStruct->permission) {          strm.write("T", 1);        } else {          strm.write("F", 1);        }      }      strm.write("\n", 1);    }  }  /* save current state of nag boxs' checkmarks */  strm.write("@@@@", 4);  for (PRInt32 type = 0; type < NUMBER_OF_PERMISSIONS; type++) {    strm.write("\t", 1);    nsCAutoString tmp; tmp.AppendInt(type);    strm.write(tmp.get(), tmp.Length());    if (permission_GetRememberChecked(type)) {      strm.write("T", 1);    } else {      strm.write("F", 1);    }  }  strm.write("\n", 1);  permission_changed = PR_FALSE;  strm.flush();  strm.close();  /* Notify cookie manager dialog to update its display */  if (notify) {    nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));    if (os) {      os->NotifyObservers(nsnull, "cookieChanged", NS_LITERAL_STRING("permissions").get());    }  }}