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 type of the None singleton.

props.encoding: Encoding#

The type of the None singleton.

props.location: File#

The type of the None singleton.

props.newline_type: NewlineType#

The type of the None singleton.

props.read_only: bool#

The type of the None singleton.

Fields#

class File
parent_instance#