File

class File(**properties: Any)

Superclasses: Object

On-disk representation of a Buffer.

A GtkSourceFile object is the on-disk representation of a Buffer. With a GtkSourceFile, you can create and configure a FileLoader and FileSaver which take by default the values of the GtkSourceFile properties (except for the file loader which auto-detect some properties). On a successful load or save operation, the GtkSourceFile properties are updated. If an operation fails, the GtkSourceFile properties have still the previous valid values.

Constructors

class File
classmethod new() File

Methods

class File
check_file_on_disk() None

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.

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

Since this function is synchronous, it is advised to call it only on local files. See is_local.

get_compression_type() CompressionType
get_encoding() Encoding

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

get_location() File
get_newline_type() NewlineType
is_deleted() bool

Returns whether the file has been deleted. If the location is None, returns False.

To have an up-to-date value, you must first call check_file_on_disk.

is_externally_modified() bool

Returns whether the file is externally modified. If the location is None, returns False.

To have an up-to-date value, you must first call check_file_on_disk.

is_local() bool

Returns whether the file is local. If the location is None, returns False.

is_readonly() bool

Returns whether the file is read-only. If the location is None, returns False.

To have an up-to-date value, you must first call check_file_on_disk.

set_location(location: File | None = None) None

Sets the location.

Parameters:

location – the new File, or None.

Properties

class File
props.compression_type: CompressionType

The compression type.

props.encoding: Encoding

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

props.location: File

The location.

props.newline_type: NewlineType

The line ending type.

props.read_only: bool

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

Fields

class File
parent_instance