Output to unstructured files: GSF Reference Manual

## Output to unstructured files

Output to unstructured files

## Functions

gsf_off_t | gsf_output_size ()
gboolean | gsf_output_close ()
gsf_off_t | gsf_output_tell ()
gboolean | gsf_output_seek ()
gboolean | gsf_output_write ()
gboolean | gsf_output_puts ()
gboolean | gsf_output_printf ()
gsf_off_t | gsf_output_vprintf ()
GsfOutfile * | gsf_output_container ()
char const * | gsf_output_name ()
gboolean | gsf_output_set_name_from_filename ()
GQuark | gsf_output_error_id ()
gboolean | gsf_output_set_error ()
GError const * | gsf_output_error ()
gboolean | gsf_output_is_closed ()
gboolean | gsf_output_wrap ()
gboolean | gsf_output_unwrap ()

## Properties

GsfOutfile * | container | Read / Write
gboolean | is-closed | Read
GDateTime * | modtime | Read / Write / Construct Only
gchar * | name | Read / Write
gint64 | position | Read
gint64 | size | Read

## Types and Values

| GsfOutput

## Object Hierarchy

        GObject
        ╰── GsfOutput
            ├── GsfOutfile
            ├── GsfOutputBzip
            ├── GsfOutputCsv
            ├── GsfOutputGZip
            ├── GsfOutputIconv
            ├── GsfOutputIOChannel
            ├── GsfOutputMemory
            ╰── GsfOutputStdio

## Description

## Functions

### gsf_output_size ()

    gsf_off_t
    gsf_output_size (GsfOutput *output);

Determine the size of the output stream `output` .

#### Parameters

output | GsfOutput |

#### Returns

the size of the output, or -1 if it does not have a size.

### gsf_output_close ()

    gboolean
    gsf_output_close (GsfOutput *output);

Close a stream.

[virtual Close]

#### Parameters

output | GsfOutput |

#### Returns

`FALSE` on error

### gsf_output_tell ()

    gsf_off_t
    gsf_output_tell (GsfOutput *output);

Tell the current position in `output` , similar to

ftell(3).

#### Parameters

output | GsfOutput |

#### Returns

the current position in the file

### gsf_output_seek ()

    gboolean
    gsf_output_seek (GsfOutput *output,
                     gsf_off_t offset,
                     GSeekType whence);

Reposition in output stream `output` . `whence` specifies what the offset is relative to: the beginning of the stream (`G_SEEK_SET`), current position in the stream (`G_SEEK_CUR`) or the end of the stream (`G_SEEK_END`). This function is similar to

fseek(3).

[virtual Seek]

#### Parameters

output | GsfOutput |
offset | Relative amount to reposition |
whence | What the offset is relative to. |

#### Returns

`FALSE` on error.

### gsf_output_write ()

    gboolean
    gsf_output_write (GsfOutput *output,
                      size_t num_bytes,
                      guint8 const *data);

Write `num_bytes` of `data` to `output` .

[virtual Write]

#### Parameters

output | Output stream |
num_bytes | Number of bytes to write |
data | Data to write. | [in][array length=num_bytes]

#### Returns

`FALSE` on error.

### gsf_output_puts ()

    gboolean
    gsf_output_puts (GsfOutput *output,
                     char const *line);

Like fputs, this assumes that the line already ends with a newline

#### Parameters

output | A GsfOutput |
line | Nul terminated string to write |

#### Returns

`TRUE` if successful, `FALSE` if not

### gsf_output_printf ()

    gboolean
    gsf_output_printf (GsfOutput *output,
                       char const *format,
                       ...);

Output `Varargs` to `output` using the format string `format` , similar to

printf(3).

#### Parameters

output | A GsfOutput |
format | The printf-style format string |
... | the arguments for `format` |

#### Returns

`TRUE` if successful, `FALSE` if not

### gsf_output_vprintf ()

    gsf_off_t
    gsf_output_vprintf (GsfOutput *output,
                        char const *format,
                        va_list args);

Output `args` to `output` using the format string `format` , similar to

vprintf(3).

[virtual Vprintf]

#### Parameters

output | A GsfOutput |
format | The printf-style format string |
args | the arguments for `format` |

#### Returns

number of bytes printed, a negative value if not successful

### gsf_output_container ()

    GsfOutfile *
    gsf_output_container (GsfOutput const *output);

#### Returns

`output` 's container.

[transfer none][nullable]

### gsf_output_name ()

    char const   *
    gsf_output_name (GsfOutput const *output);

Give the name of `output` .

#### Parameters

output | GsfOutput |

#### Returns

`output` 's name in utf8 form.

[transfer none][nullable]

### gsf_output_set_name_from_filename ()

    gboolean
    gsf_output_set_name_from_filename (GsfOutput *output,
                                       char const *filename);

This is a utility routine that should only be used by derived outputs.

#### Parameters

output | the output stream |
filename | the (fs-sys encoded) filename |

#### Returns

`TRUE` if the assignment was ok.

### gsf_output_error_id ()

    GQuark
    gsf_output_error_id (void);

### gsf_output_set_error ()

    gboolean
    gsf_output_set_error (GsfOutput *output,
                          gint code,
                          char const *format,
                          ...);

This is a utility routine that should only be used by derived outputs.

#### Parameters

output | GsfOutput |
code | The error id |
format | printf style format string |
... | arguments for `format` |

#### Returns

Always returns `FALSE` to facilitate its use.

### gsf_output_error ()

    GError const *
    gsf_output_error (GsfOutput const *output);

#### Returns

the last error logged on the output.

[transfer none][nullable]

### gsf_output_is_closed ()

    gboolean
    gsf_output_is_closed (GsfOutput const *output);

#### Parameters

output | GsfOutput |

#### Returns

`TRUE` if `output` has already been closed.

### gsf_output_wrap ()

    gboolean
    gsf_output_wrap (GObject *wrapper,
                     GsfOutput *wrapee);

#### Returns

`TRUE` if the wrapping succeeded.

### gsf_output_unwrap ()

    gboolean
    gsf_output_unwrap (GObject *wrapper,
                       GsfOutput *wrapee);

#### Returns

`TRUE` if the unwrapping succeeded.

## Types and Values

### GsfOutput

    typedef struct _GsfOutput GsfOutput;

Class representing an output stream, counterpart to GsfInput.

## Property Details

### The `“container”` property

      “container”                GsfOutfile *

The container, optionally `NULL`, in which this output lives.

Flags: Read / Write

### The `“is-closed”` property

      “is-closed”                gboolean

`TRUE` if the output has been closed.

Flags: Read

Default value: FALSE

### The `“modtime”` property

      “modtime”                  GDateTime *

The time the output was last updated. This must be set on object construction and represents the timestamp to put on the resulting file or GsfOutfile member. Not all derived classes will actually do anything with this property.

Flags: Read / Write / Construct Only

### The `“name”` property

      “name”                     gchar *

The output's name.

Flags: Read / Write

Default value: NULL

### The `“position”` property

      “position”                 gint64

The current position in the output.

Flags: Read

Allowed values: >= 0

Default value: 0

### The `“size”` property

      “size”                     gint64

The current file size.

Flags: Read

Allowed values: >= 0

Default value: 0