Class File

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class File extends GObject

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.

  • Constructor Details

    • File

      public File(MemorySegment address)
      Create a File instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • File

      public File()
      Create a new File.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the File class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected File asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • checkFileOnDisk

      public void checkFileOnDisk()

      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.

      GtkSourceFile 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 isLocal().

    • getCompressionType

      public CompressionType getCompressionType()
    • getEncoding

      public Encoding getEncoding()
      The encoding is initially null. After a successful file loading or saving operation, the encoding is non-null.
      Returns:
      the character encoding.
    • getLocation

      public @Nullable File getLocation()
    • getNewlineType

      public NewlineType getNewlineType()
    • isDeleted

      public boolean isDeleted()

      Returns whether the file has been deleted. If the File:location is null, returns false.

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

      Returns:
      whether the file has been deleted.
    • isExternallyModified

      public boolean isExternallyModified()

      Returns whether the file is externally modified. If the File:location is null, returns false.

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

      Returns:
      whether the file is externally modified.
    • isLocal

      public boolean isLocal()
      Returns whether the file is local. If the File:location is null, returns false.
      Returns:
      whether the file is local.
    • isReadonly

      public boolean isReadonly()

      Returns whether the file is read-only. If the File:location is null, returns false.

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

      Returns:
      whether the file is read-only.
    • setLocation

      public void setLocation(@Nullable File location)
      Sets the location.
      Parameters:
      location - the new GFile, or null.
    • setMountOperationFactory

      public void setMountOperationFactory(@Nullable MountOperationFactory callback)

      Sets a MountOperationFactory function that will be called when a MountOperation must be created.

      This is useful for creating a MountOperation with the parent Window.

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

      Parameters:
      callback - a GtkSourceMountOperationFactory to call when a GMountOperation is needed.
    • builder

      public static File.Builder<? extends File.Builder> builder()
      A File.Builder object constructs a File with the specified properties. Use the various set...() methods to set properties, and finish construction with File.Builder.build().
      Returns:
      the builder object