## GtefFile GtefFile — On-disk representation of a GtefBuffer |

## Functions

GMountOperation * | (*GtefMountOperationFactory) ()
GtefFile * | gtef_file_new ()
GtefFileMetadata * | gtef_file_get_file_metadata ()
GFile * | gtef_file_get_location ()
void | gtef_file_set_location ()
const gchar * | gtef_file_get_short_name ()
const GtefEncoding * | gtef_file_get_encoding ()
GtefNewlineType | gtef_file_get_newline_type ()
GtefCompressionType | gtef_file_get_compression_type ()
void | gtef_file_check_file_on_disk ()
gboolean | gtef_file_is_local ()
gboolean | gtef_file_is_externally_modified ()
gboolean | gtef_file_is_deleted ()
gboolean | gtef_file_is_readonly ()
void | gtef_file_set_mount_operation_factory ()

## Properties

GtefCompressionType | compression-type | Read
GtefEncoding * | encoding | Read
GFile * | location | Read / Write / Construct
GtefNewlineType | newline-type | Read
gboolean | read-only | Read
gchar * | short-name | Read

## Types and Values

| GtefFile
enum | GtefNewlineType
#define | GTEF_NEWLINE_TYPE_DEFAULT
enum | GtefCompressionType

## Object Hierarchy

        GEnum
        ├── GtefCompressionType
        ╰── GtefNewlineType
        GObject
        ╰── GtefFile

## Includes

    #include <gtef/gtef.h>

## Description

A GtefFile object is the on-disk representation of a GtefBuffer.

With a GtefFile, you can create and configure a GtefFileLoader and GtefFileSaver which take by default the values of the GtefFile properties (except for the file loader which auto-detect some properties). On a successful load or save operation, the GtefFile properties are updated. If an operation fails, the GtefFile properties have still the previous valid values.

GtefFile is a fork of GtkSourceFile. GtefFileLoader is a new implementation for file loading, but it needs to call private functions of GtefFile in order to update its properties. So it was not possible for GtefFileLoader to use GtkSourceFile. So the whole file loading and saving API of GtkSourceView has been forked; hopefully the new implementation will be folded back to GtkSourceView in a later version.

## Functions

### GtefMountOperationFactory ()

    GMountOperation *
    (*GtefMountOperationFactory) (GtefFile *file,
                                  gpointer userdata);

Type definition for a function that will be called to create a GMountOperation. This is useful for creating a GtkMountOperation.

#### Parameters

file | a GtefFile. |
userdata | user data |

Since: 1.0

### gtef_file_new ()

    GtefFile *
    gtef_file_new (void);

#### Returns

a new GtefFile object.

Since: 1.0

### gtef_file_get_file_metadata ()

    GtefFileMetadata *
    gtef_file_get_file_metadata (GtefFile *file);

#### Parameters

file | a GtefFile. |

#### Returns

the associated GtefFileMetadata.

[transfer none]

Since: 1.0

### gtef_file_get_location ()

    GFile *
    gtef_file_get_location (GtefFile *file);

#### Parameters

file | a GtefFile. |

#### Returns

the GFile.

[transfer none]

Since: 1.0

### gtef_file_set_location ()

    void
    gtef_file_set_location (GtefFile *file,
                            GFile *location);

Sets the location.

#### Parameters

file | a GtefFile. |
location | the new GFile, or `NULL`. | [nullable]

Since: 1.0

### gtef_file_get_short_name ()

    const gchar *
    gtef_file_get_short_name (GtefFile *file);

Gets the `file` short name. If the “location” isn't `NULL`, returns its display-name (see G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME). Otherwise returns "Untitled File N", with N the Nth untitled file of the application, starting at 1. When an untitled file is closed, its number is released and can be used by a later untitled file.

#### Parameters

file | a GtefFile. |

#### Returns

the `file` short name.

Since: 1.0

### gtef_file_get_encoding ()

    const GtefEncoding *
    gtef_file_get_encoding (GtefFile *file);

The encoding is initially `NULL`. After a successful file loading or saving operation, the encoding is non-`NULL`.

#### Parameters

file | a GtefFile. |

#### Returns

the character encoding.

Since: 1.0

### gtef_file_get_newline_type ()

    GtefNewlineType
    gtef_file_get_newline_type (GtefFile *file);

#### Parameters

file | a GtefFile. |

#### Returns

the newline type.

Since: 1.0

### gtef_file_get_compression_type ()

    GtefCompressionType
    gtef_file_get_compression_type (GtefFile *file);

#### Parameters

file | a GtefFile. |

#### Returns

the compression type.

Since: 1.0

### gtef_file_check_file_on_disk ()

    void
    gtef_file_check_file_on_disk (GtefFile *file);

Checks synchronously the file on disk, to know whether the file is externally modified, or has been deleted, and whether the file is read-only.

GtefFile doesn't create a GFileMonitor to track those properties, so this function needs to be called instead. Creating lots of GFileMonitor's would take lots of resources.

Since this function is synchronous, it is advised to call it only on local files. See `gtef_file_is_local()`.

#### Parameters

file | a GtefFile. |

Since: 1.0

### gtef_file_is_local ()

    gboolean
    gtef_file_is_local (GtefFile *file);

Returns whether the file is local. If the “location” is `NULL`, returns `FALSE`.

#### Parameters

file | a GtefFile. |

#### Returns

whether the file is local.

Since: 1.0

### gtef_file_is_externally_modified ()

    gboolean
    gtef_file_is_externally_modified (GtefFile *file);

Returns whether the file is externally modified. If the “location” is `NULL`, returns `FALSE`.

To have an up-to-date value, you must first call `gtef_file_check_file_on_disk()`.

#### Parameters

file | a GtefFile. |

#### Returns

whether the file is externally modified.

Since: 1.0

### gtef_file_is_deleted ()

    gboolean
    gtef_file_is_deleted (GtefFile *file);

Returns whether the file has been deleted. If the “location” is `NULL`, returns `FALSE`.

To have an up-to-date value, you must first call `gtef_file_check_file_on_disk()`.

#### Parameters

file | a GtefFile. |

#### Returns

whether the file has been deleted.

Since: 1.0

### gtef_file_is_readonly ()

    gboolean
    gtef_file_is_readonly (GtefFile *file);

Returns whether the file is read-only. If the “location” is `NULL`, returns `FALSE`.

To have an up-to-date value, you must first call `gtef_file_check_file_on_disk()`.

#### Parameters

file | a GtefFile. |

#### Returns

whether the file is read-only.

Since: 1.0

### gtef_file_set_mount_operation_factory ()

    void
    gtef_file_set_mount_operation_factory (GtefFile *file,
                                           GtefMountOperationFactory callback,
                                           gpointer user_data,
                                           GDestroyNotify notify);

Sets a GtefMountOperationFactory function that will be called when a GMountOperation must be created. This is useful for creating a GtkMountOperation with the parent GtkWindow.

If a mount operation factory isn't set, `g_mount_operation_new()` will be called.

#### Parameters

file | a GtefFile. |
callback | a GtefMountOperationFactory to call when a GMountOperation is needed. | [scope notified]
user_data | the data to pass to the `callback` function. | [closure]
notify | function to call on `user_data` when the `callback` is no longer needed, or `NULL`. | [nullable]

Since: 1.0

## Types and Values

### GtefFile

    typedef struct _GtefFile GtefFile;

### enum GtefNewlineType

#### Members

GTEF_NEWLINE_TYPE_LF | line feed, used on UNIX. |
GTEF_NEWLINE_TYPE_CR | carriage return, used on Mac. |
GTEF_NEWLINE_TYPE_CR_LF | carriage return followed by a line feed, used on Windows. |

Since: 1.0

### GTEF_NEWLINE_TYPE_DEFAULT

    #define GTEF_NEWLINE_TYPE_DEFAULT GTEF_NEWLINE_TYPE_CR_LF

The default newline type on the current OS.

Since: 1.0

### enum GtefCompressionType

#### Members

GTEF_COMPRESSION_TYPE_NONE | plain text. |
GTEF_COMPRESSION_TYPE_GZIP | gzip compression. |

Since: 1.0

## Property Details

### The `“compression-type”` property

      “compression-type”         GtefCompressionType

The compression type.

Flags: Read

Default value: GTEF_COMPRESSION_TYPE_NONE

Since: 1.0

### The `“encoding”` property

      “encoding”                 GtefEncoding *

The character encoding, initially `NULL`. After a successful file loading or saving operation, the encoding is non-`NULL`.

Flags: Read

Since: 1.0

### The `“location”` property

      “location”                 GFile *

The location.

Flags: Read / Write / Construct

Since: 1.0

### The `“newline-type”` property

      “newline-type”             GtefNewlineType

The line ending type.

Flags: Read

Default value: GTEF_NEWLINE_TYPE_LF

Since: 1.0

### The `“read-only”` property

      “read-only”                gboolean

Whether the file is read-only or not. The value of this property is not updated automatically (there is no file monitors).

Flags: Read

Default value: FALSE

Since: 1.0

### The `“short-name”` property

      “short-name”               gchar *

The file short name. See `gtef_file_get_short_name()`.

Flags: Read

Default value: NULL

Since: 1.0

## See Also

GtefFileLoader, GtefFileSaver, GtefFileMetadata