if (!data->file_stream)
if (!data->output_file_stream)
MimePartBufferWrite (MimePartBufferData *data,					 const char *buf, PRInt32 size){  int status = 0;  NS_ASSERTION(data && buf && size > 0, "MimePartBufferWrite: Bad param");  if (!data || !buf || size <= 0)	return -1;  /* If we don't yet have a buffer (either memory or file) try and make a	 memory buffer.   */  if (!data->part_buffer &&	  !data->file_buffer_name)	{	  int target_size = TARGET_MEMORY_BUFFER_SIZE;	  while (target_size > 0)		{		  data->part_buffer = (char *) PR_MALLOC(target_size);		  if (data->part_buffer) break;					/* got it! */		  target_size -= TARGET_MEMORY_BUFFER_QUANTUM;	/* decrease it and try														   again */		}	  if (data->part_buffer)		data->part_buffer_size = target_size;	  else		data->part_buffer_size = 0;	  data->part_buffer_fp = 0;	}  /* Ok, if at this point we still don't have either kind of buffer, try and	 make a file buffer. */  if (!data->part_buffer && !data->file_buffer_name)	{	  data->file_buffer_name = GetOSTempFile("nsma");	  if (!data->file_buffer_name) return MIME_OUT_OF_MEMORY;	  data->file_stream = PR_Open(data->file_buffer_name, PR_RDWR | PR_CREATE_FILE, 493);	  if (!data->file_stream)		return MIME_UNABLE_TO_OPEN_TMP_FILE;  }  NS_ASSERTION(data->part_buffer || data->file_stream, "no part_buffer or file_stream");  /* If this buf will fit in the memory buffer, put it there.   */  if (data->part_buffer &&	  data->part_buffer_fp + size < data->part_buffer_size)	{	  nsCRT::memcpy(data->part_buffer + data->part_buffer_fp,				buf, size);	  data->part_buffer_fp += size;	}  /* Otherwise it won't fit; write it to the file instead. */  else	{	  /* If the file isn't open yet, open it, and dump the memory buffer		 to it. */	  if (!data->file_stream)		{		  if (!data->file_buffer_name)			data->file_buffer_name = GetOSTempFile("nsma");		  if (!data->file_buffer_name) return MIME_OUT_OF_MEMORY;		  data->file_stream = PR_Open(data->file_buffer_name, PR_RDWR | PR_CREATE_FILE, 493);		  if (!data->file_stream)			return MIME_UNABLE_TO_OPEN_TMP_FILE;		  if (data->part_buffer && data->part_buffer_fp)			{			  status = PR_Write (data->file_stream,						data->part_buffer,						data->part_buffer_fp);			  if (status < 0) return status;			}		  PR_FREEIF(data->part_buffer);		  data->part_buffer_fp = 0;		  data->part_buffer_size = 0;		}	  /* Dump this buf to the file. */	  status = PR_Write (data->file_stream, buf, size);	  if (status < 0) return status;	}  return 0;}