ECode PdfEditor::Write( /* [in] */ IParcelFileDescriptor* output) /*throws IOException*/ { Int32 fd = 0; ECode ec = ThrowIfClosed(); FAIL_GOTO(ec, error); ec = NativeWrite(mNativeDocument, (output->GetFd(&fd), fd)); FAIL_GOTO(ec, error); error: AutoPtr<IIoUtils> iu; CIoUtils::AcquireSingleton((IIoUtils**)&iu); return iu->CloseQuietly(ICloseable::Probe(output)); }
static int WriteNativeData(FieldSpec *field, FILE *file) { long length; /* number of elements */ if (file == NULL || field == NULL || field->type == NO_TYPE) return FALSE; length = FieldLength(field); if (length != 0 && field->data == NULL) return FALSE; return (NativeWrite(field->data, field->type, length, file) == length); }
static int WriteNativeArray(Array *array, FILE *file) { short type, rank; long *dim; void *data; long length; if (array == NULL || file == NULL) return FALSE; type = array->type; rank = array->rank; dim = array->dim; data = array->data; if (fwrite(&type, sizeof(short), 1, file) != 1) return FALSE; if (fwrite(&rank, sizeof(short), 1, file) != 1) return FALSE; if (rank > 0) { if (dim == NULL) return FALSE; if (fwrite(dim, sizeof(long), rank, file) != rank) return FALSE; } length = LongProd(rank, dim); if (length > 0) { if (data == NULL) return FALSE; if (NativeWrite(data, type, length, file) != length) return FALSE; } return TRUE; }
long WriteNativeSamples(void *data, long nrec, FieldSpec **fields, FILE *file) { int type; long length; if (data == NULL) { DebugMsg(1, "WriteNativeSamples: NULL data pointer."); return 0; } if (nrec < 0) { DebugMsg(1, ("WriteNativeSamples: " "negative number of records specified.")); return 0; } if (fields == NULL || fields[0] == NULL || fields[1] != NULL || fields[0]->occurrence != REQUIRED) { DebugMsg(1, "WriteNativeSamples: bad \"fields\" array."); return 0; } if (file == NULL) { DebugMsg(1, "WriteNativeSamples: NULL file pointer."); return 0; } type = fields[0]->type; if (type == NO_TYPE) return 0; length = FieldLength(fields[0]); if (nrec*length == 0) return nrec; return NativeWrite(data, type, nrec*length, file) / length; }