Interface Mount

All Superinterfaces:
Proxy
All Known Implementing Classes:
Mount.Mount$Impl

@Generated("org.javagi.JavaGI") public interface Mount extends Proxy

The GMount interface represents a user-visible mount, such as a mounted file system.

GMount is a ‘mounted’ filesystem that you can access. Mounted is in quotes because it’s not the same as a UNIX mount, it might be a GVFS mount, but you can still access the files on it if you use GIO.

A GMount might be associated with a Volume (such as a USB flash drive) which hosts it.

Unmounting a GMount instance is an asynchronous operation. For more information about asynchronous operations, see AsyncResult and Task. To unmount a GMount instance, first call unmountWithOperation(Set, MountOperation, Cancellable, AsyncReadyCallback) with (at least) the GMount instance and a Gio.AsyncReadyCallback. The callback will be fired when the operation has resolved (either with success or failure), and a AsyncResult structure will be passed to the callback. That callback should then call unmountWithOperationFinish(AsyncResult) with the GMount and the AsyncResult data to see if the operation was completed successfully. If an error is present when unmountWithOperationFinish(AsyncResult) is called, then it will be filled with any error information.

Note, when porting from GnomeVFS, GMount is the moral equivalent of GnomeVFSVolume.

  • Method Details

    • getType

      static @Nullable Type getType()
      Get the GType of the Mount class.
      Returns:
      the GType
    • canEject

      default boolean canEject()
      Checks if this Mount can be ejected.
      Returns:
      true if the this Mount can be ejected.
    • canUnmount

      default boolean canUnmount()
      Checks if this Mount can be unmounted.
      Returns:
      true if the this Mount can be unmounted.
    • eject

      @Deprecated default void eject(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Deprecated.
      Use g_mount_eject_with_operation() instead.
      Ejects a mount. This is an asynchronous operation, and is finished by calling g_mount_eject_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the unmount if required for eject
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
    • eject

      @Deprecated default void eject(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Deprecated.
      Use g_mount_eject_with_operation() instead.
      Ejects a mount. This is an asynchronous operation, and is finished by calling g_mount_eject_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the unmount if required for eject
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
    • ejectFinish

      @Deprecated default boolean ejectFinish(AsyncResult result) throws GErrorException
      Deprecated.
      Use g_mount_eject_with_operation_finish() instead.
      Finishes ejecting a mount. If any errors occurred during the operation, error will be set to contain the errors and false will be returned.
      Parameters:
      result - a GAsyncResult.
      Returns:
      true if the mount was successfully ejected. false otherwise.
      Throws:
      GErrorException - see GError
    • ejectWithOperation

      default void ejectWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Ejects a mount. This is an asynchronous operation, and is finished by calling g_mount_eject_with_operation_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the unmount if required for eject
      mountOperation - a GMountOperation or null to avoid user interaction.
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
      Since:
      2.22
    • ejectWithOperation

      default void ejectWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Ejects a mount. This is an asynchronous operation, and is finished by calling g_mount_eject_with_operation_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the unmount if required for eject
      mountOperation - a GMountOperation or null to avoid user interaction.
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
      Since:
      2.22
    • ejectWithOperationFinish

      default boolean ejectWithOperationFinish(AsyncResult result) throws GErrorException
      Finishes ejecting a mount. If any errors occurred during the operation, error will be set to contain the errors and false will be returned.
      Parameters:
      result - a GAsyncResult.
      Returns:
      true if the mount was successfully ejected. false otherwise.
      Throws:
      GErrorException - see GError
      Since:
      2.22
    • getDefaultLocation

      default File getDefaultLocation()
      Gets the default location of mount. The default location of the given this Mount is a path that reflects the main entry point for the user (e.g. the home directory, or the root of the volume).
      Returns:
      a GFile. The returned object should be unreffed with g_object_unref() when no longer needed.
    • getDrive

      default @Nullable Drive getDrive()

      Gets the drive for the mount.

      This is a convenience method for getting the GVolume and then using that object to get the GDrive.

      Returns:
      a GDrive or null if this Mount is not associated with a volume or a drive. The returned object should be unreffed with g_object_unref() when no longer needed.
    • getIcon

      default Icon getIcon()
      Gets the icon for mount.
      Returns:
      a GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.
    • getName

      default String getName()
      Gets the name of mount.
      Returns:
      the name for the given mount. The returned string should be freed with g_free() when no longer needed.
    • getRoot

      default File getRoot()
      Gets the root directory on mount.
      Returns:
      a GFile. The returned object should be unreffed with g_object_unref() when no longer needed.
    • getSortKey

      default @Nullable String getSortKey()
      Gets the sort key for mount, if any.
      Returns:
      Sorting key for this Mount or null if no such key is available.
      Since:
      2.32
    • getSymbolicIcon

      default Icon getSymbolicIcon()
      Gets the symbolic icon for mount.
      Returns:
      a GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.
      Since:
      2.34
    • getUuid

      default @Nullable String getUuid()
      Gets the UUID for the mount. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns null if there is no UUID available.
      Returns:
      the UUID for this Mount or null if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.
    • getVolume

      default @Nullable Volume getVolume()
      Gets the volume for the mount.
      Returns:
      a GVolume or null if this Mount is not associated with a volume. The returned object should be unreffed with g_object_unref() when no longer needed.
    • guessContentType

      default void guessContentType(boolean forceRescan, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Tries to guess the type of content stored on mount. Returns one or more textual identifiers of well-known content types (typically prefixed with "x-content/"), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

      This is an asynchronous operation (see g_mount_guess_content_type_sync() for the synchronous version), and is finished by calling g_mount_guess_content_type_finish() with the this Mount and GAsyncResult data returned in the callback.

      Parameters:
      forceRescan - Whether to force a rescan of the content. Otherwise a cached result will be used if available
      cancellable - optional GCancellable object, null to ignore
      callback - a GAsyncReadyCallback
      Since:
      2.18
    • guessContentTypeFinish

      default String[] guessContentTypeFinish(AsyncResult result) throws GErrorException
      Finishes guessing content types of mount. If any errors occurred during the operation, error will be set to contain the errors and false will be returned. In particular, you may get an IOErrorEnum.NOT_SUPPORTED if the mount does not support content guessing.
      Parameters:
      result - a GAsyncResult
      Returns:
      a null-terminated array of content types or null on error. Caller should free this array with g_strfreev() when done with it.
      Throws:
      GErrorException - see GError
      Since:
      2.18
    • guessContentTypeSync

      default String[] guessContentTypeSync(boolean forceRescan, @Nullable Cancellable cancellable) throws GErrorException

      Tries to guess the type of content stored on mount. Returns one or more textual identifiers of well-known content types (typically prefixed with "x-content/"), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

      This is a synchronous operation and as such may block doing IO; see g_mount_guess_content_type() for the asynchronous version.

      Parameters:
      forceRescan - Whether to force a rescan of the content. Otherwise a cached result will be used if available
      cancellable - optional GCancellable object, null to ignore
      Returns:
      a null-terminated array of content types or null on error. Caller should free this array with g_strfreev() when done with it.
      Throws:
      GErrorException - see GError
      Since:
      2.18
    • isShadowed

      default boolean isShadowed()

      Determines if this Mount is shadowed. Applications or libraries should avoid displaying this Mount in the user interface if it is shadowed.

      A mount is said to be shadowed if there exists one or more user visible objects (currently GMount objects) with a root that is inside the root of mount.

      One application of shadow mounts is when exposing a single file system that is used to address several logical volumes. In this situation, a GVolumeMonitor implementation would create two GVolume objects (for example, one for the camera functionality of the device and one for a SD card reader on the device) with activation URIs gphoto2://[usb:001,002]/store1/ and gphoto2://[usb:001,002]/store2/. When the underlying mount (with root gphoto2://[usb:001,002]/) is mounted, said GVolumeMonitor implementation would create two GMount objects (each with their root matching the corresponding volume activation root) that would shadow the original mount.

      The proxy monitor in GVfs 2.26 and later, automatically creates and manage shadow mounts (and shadows the underlying mount) if the activation root on a GVolume is set.

      Returns:
      true if this Mount is shadowed.
      Since:
      2.20
    • remount

      default void remount(Set<MountMountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Remounts a mount. This is an asynchronous operation, and is finished by calling g_mount_remount_finish() with the this Mount and GAsyncResults data returned in the callback.

      Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.

      Parameters:
      flags - flags affecting the operation
      mountOperation - a GMountOperation or null to avoid user interaction.
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
    • remount

      default void remount(MountMountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Remounts a mount. This is an asynchronous operation, and is finished by calling g_mount_remount_finish() with the this Mount and GAsyncResults data returned in the callback.

      Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.

      Parameters:
      flags - flags affecting the operation
      mountOperation - a GMountOperation or null to avoid user interaction.
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
    • remountFinish

      default boolean remountFinish(AsyncResult result) throws GErrorException
      Finishes remounting a mount. If any errors occurred during the operation, error will be set to contain the errors and false will be returned.
      Parameters:
      result - a GAsyncResult.
      Returns:
      true if the mount was successfully remounted. false otherwise.
      Throws:
      GErrorException - see GError
    • shadow

      default void shadow()
      Increments the shadow count on mount. Usually used by GVolumeMonitor implementations when creating a shadow mount for mount, see g_mount_is_shadowed() for more information. The caller will need to emit the GMount::changed signal on this Mount manually.
      Since:
      2.20
    • unmount

      @Deprecated default void unmount(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Deprecated.
      Use g_mount_unmount_with_operation() instead.
      Unmounts a mount. This is an asynchronous operation, and is finished by calling g_mount_unmount_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the operation
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
    • unmount

      @Deprecated default void unmount(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Deprecated.
      Use g_mount_unmount_with_operation() instead.
      Unmounts a mount. This is an asynchronous operation, and is finished by calling g_mount_unmount_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the operation
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
    • unmountFinish

      @Deprecated default boolean unmountFinish(AsyncResult result) throws GErrorException
      Deprecated.
      Use g_mount_unmount_with_operation_finish() instead.
      Finishes unmounting a mount. If any errors occurred during the operation, error will be set to contain the errors and false will be returned.
      Parameters:
      result - a GAsyncResult.
      Returns:
      true if the mount was successfully unmounted. false otherwise.
      Throws:
      GErrorException - see GError
    • unmountWithOperation

      default void unmountWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Unmounts a mount. This is an asynchronous operation, and is finished by calling g_mount_unmount_with_operation_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the operation
      mountOperation - a GMountOperation or null to avoid user interaction.
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
      Since:
      2.22
    • unmountWithOperation

      default void unmountWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      Unmounts a mount. This is an asynchronous operation, and is finished by calling g_mount_unmount_with_operation_finish() with the this Mount and GAsyncResult data returned in the callback.
      Parameters:
      flags - flags affecting the operation
      mountOperation - a GMountOperation or null to avoid user interaction.
      cancellable - optional GCancellable object, null to ignore.
      callback - a GAsyncReadyCallback, or null.
      Since:
      2.22
    • unmountWithOperationFinish

      default boolean unmountWithOperationFinish(AsyncResult result) throws GErrorException
      Finishes unmounting a mount. If any errors occurred during the operation, error will be set to contain the errors and false will be returned.
      Parameters:
      result - a GAsyncResult.
      Returns:
      true if the mount was successfully unmounted. false otherwise.
      Throws:
      GErrorException - see GError
      Since:
      2.22
    • unshadow

      default void unshadow()
      Decrements the shadow count on mount. Usually used by GVolumeMonitor implementations when destroying a shadow mount for mount, see g_mount_is_shadowed() for more information. The caller will need to emit the GMount::changed signal on this Mount manually.
      Since:
      2.20
    • onChanged

      Emitted when the mount has been changed.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitChanged

      default void emitChanged()
      Emits the "changed" signal. See onChanged(Mount.ChangedCallback).
    • onPreUnmount

      This signal may be emitted when the GMount is about to be unmounted.

      This signal depends on the backend and is only emitted if GIO was used to unmount.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.22
      See Also:
    • emitPreUnmount

      default void emitPreUnmount()
      Emits the "pre-unmount" signal. See onPreUnmount(Mount.PreUnmountCallback).
    • onUnmounted

      This signal is emitted when the GMount have been unmounted. If the recipient is holding references to the object they should release them so the object can be finalized.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitUnmounted

      default void emitUnmounted()
      Emits the "unmounted" signal. See onUnmounted(Mount.UnmountedCallback).