Interface Mount
- All Superinterfaces:
Proxy
- All Known Implementing Classes:
Mount.Mount$Impl
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(java.util.Set<org.gnome.gio.MountUnmountFlags>, org.gnome.gio.MountOperation, org.gnome.gio.Cancellable, org.gnome.gio.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(org.gnome.gio.AsyncResult)
with the GMount and the AsyncResult data to see if the
operation was completed successfully. If an error is present when
unmountWithOperationFinish(org.gnome.gio.AsyncResult) is called, then it will be
filled with any error information.
Note, when porting from GnomeVFS, GMount is the
moral equivalent of GnomeVFSVolume.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFunctional interface declaration of theChangedCallbackcallback.static classThe Mount$Impl type represents a native instance of the Mount interface.static classInterface for implementing operations for mounts.static interfaceFunctional interface declaration of thePreUnmountCallbackcallback.static interfaceFunctional interface declaration of theUnmountedCallbackcallback. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanEject()Checks if this Mount can be ejected.default booleanChecks if this Mount can be unmounted.default voideject(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_eject_with_operation() instead.default voideject(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_eject_with_operation() instead.default booleanejectFinish(AsyncResult result) Deprecated.Use g_mount_eject_with_operation_finish() instead.default voidejectWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Ejects a mount.default voidejectWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Ejects a mount.default booleanejectWithOperationFinish(AsyncResult result) Finishes ejecting a mount.default voidEmits the "changed" signal.default voidEmits the "pre-unmount" signal.default voidEmits the "unmounted" signal.default FileGets the default location ofmount.The default location of the given this Mount is a path that reflects the main entry point for the user (e.g.default @Nullable DrivegetDrive()Gets the drive for themount.default IcongetIcon()Gets the icon formount.default StringgetName()Gets the name ofmount.default FilegetRoot()Gets the root directory onmount.default @Nullable StringGets the sort key formount,if any.default IconGets the symbolic icon formount.static @Nullable TypegetType()Get the GType of the Mount classdefault @Nullable StringgetUuid()Gets the UUID for themount.The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string.default @Nullable VolumeGets the volume for themount.default voidguessContentType(boolean forceRescan, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Tries to guess the type of content stored onmount.Returns one or more textual identifiers of well-known content types (typically prefixed with "x-content/"), e.g.default String[]guessContentTypeFinish(AsyncResult result) Finishes guessing content types ofmount.If any errors occurred during the operation,errorwill be set to contain the errors andfalsewill be returned.default String[]guessContentTypeSync(boolean forceRescan, @Nullable Cancellable cancellable) Tries to guess the type of content stored onmount.Returns one or more textual identifiers of well-known content types (typically prefixed with "x-content/"), e.g.default booleanDetermines if this Mount is shadowed.default SignalConnection<Mount.ChangedCallback> onChanged(Mount.ChangedCallback handler) Emitted when the mount has been changed.default SignalConnection<Mount.PreUnmountCallback> onPreUnmount(Mount.PreUnmountCallback handler) This signal may be emitted when theGMountis about to be unmounted.default SignalConnection<Mount.UnmountedCallback> onUnmounted(Mount.UnmountedCallback handler) This signal is emitted when theGMounthave been unmounted.default voidremount(Set<MountMountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Remounts a mount.default voidremount(MountMountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Remounts a mount.default booleanremountFinish(AsyncResult result) Finishes remounting a mount.default voidshadow()Increments the shadow count onmount.Usually used byGVolumeMonitorimplementations when creating a shadow mount formount,see g_mount_is_shadowed() for more information.default voidunmount(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_unmount_with_operation() instead.default voidunmount(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_unmount_with_operation() instead.default booleanunmountFinish(AsyncResult result) Deprecated.Use g_mount_unmount_with_operation_finish() instead.default voidunmountWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a mount.default voidunmountWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a mount.default booleanFinishes unmounting a mount.default voidunshadow()Decrements the shadow count onmount.Usually used byGVolumeMonitorimplementations when destroying a shadow mount formount,see g_mount_is_shadowed() for more information.
-
Method Details
-
getType
-
canEject
default boolean canEject()Checks if this Mount can be ejected.- Returns:
trueif the this Mount can be ejected.
-
canUnmount
default boolean canUnmount()Checks if this Mount can be unmounted.- Returns:
trueif 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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the unmount if required for ejectcancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.
-
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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the unmount if required for ejectcancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.
-
ejectFinish
Deprecated.Use g_mount_eject_with_operation_finish() instead.Finishes ejecting a mount. If any errors occurred during the operation,errorwill be set to contain the errors andfalsewill be returned.- Parameters:
result- aGAsyncResult.- Returns:
trueif the mount was successfully ejected.falseotherwise.- Throws:
GErrorException- seeGError
-
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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the unmount if required for ejectmountOperation- aGMountOperationornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.- 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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the unmount if required for ejectmountOperation- aGMountOperationornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.- Since:
- 2.22
-
ejectWithOperationFinish
Finishes ejecting a mount. If any errors occurred during the operation,errorwill be set to contain the errors andfalsewill be returned.- Parameters:
result- aGAsyncResult.- Returns:
trueif the mount was successfully ejected.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.22
-
getDefaultLocation
Gets the default location ofmount.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
Gets the drive for themount.This is a convenience method for getting the
GVolumeand then using that object to get theGDrive.- Returns:
- a
GDriveornullif 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
Gets the icon formount.- Returns:
- a
GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.
-
getName
Gets the name ofmount.- Returns:
- the name for the given
mount.The returned string should be freed with g_free() when no longer needed.
-
getRoot
Gets the root directory onmount.- Returns:
- a
GFile. The returned object should be unreffed with g_object_unref() when no longer needed.
-
getSortKey
Gets the sort key formount,if any.- Returns:
- Sorting key for this Mount or
nullif no such key is available. - Since:
- 2.32
-
getSymbolicIcon
Gets the symbolic icon formount.- Returns:
- a
GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. - Since:
- 2.34
-
getUuid
Gets the UUID for themount.The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returnsnullif there is no UUID available.- Returns:
- the UUID for this Mount or
nullif no UUID can be computed. The returned string should be freed with g_free() when no longer needed.
-
getVolume
Gets the volume for themount.- Returns:
- a
GVolumeornullif 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 onmount.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
GAsyncResultdata returned in thecallback.- Parameters:
forceRescan- Whether to force a rescan of the content. Otherwise a cached result will be used if availablecancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallback- Since:
- 2.18
-
guessContentTypeFinish
Finishes guessing content types ofmount.If any errors occurred during the operation,errorwill be set to contain the errors andfalsewill be returned. In particular, you may get anIOErrorEnum.NOT_SUPPORTEDif the mount does not support content guessing.- Parameters:
result- aGAsyncResult- Returns:
- a
null-terminated array of content types ornullon error. Caller should free this array with g_strfreev() when done with it. - Throws:
GErrorException- seeGError- Since:
- 2.18
-
guessContentTypeSync
default String[] guessContentTypeSync(boolean forceRescan, @Nullable Cancellable cancellable) throws GErrorException Tries to guess the type of content stored onmount.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 availablecancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
null-terminated array of content types ornullon error. Caller should free this array with g_strfreev() when done with it. - Throws:
GErrorException- seeGError- 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
GMountobjects) with a root that is inside the root ofmount.One application of shadow mounts is when exposing a single file system that is used to address several logical volumes. In this situation, a
GVolumeMonitorimplementation would create twoGVolumeobjects (for example, one for the camera functionality of the device and one for a SD card reader on the device) with activation URIsgphoto2://[usb:001,002]/store1/andgphoto2://[usb:001,002]/store2/. When the underlying mount (with rootgphoto2://[usb:001,002]/) is mounted, saidGVolumeMonitorimplementation would create twoGMountobjects (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
GVolumeis set.- Returns:
trueif 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 andGAsyncResultsdata returned in thecallback.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 operationmountOperation- aGMountOperationornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.
-
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 andGAsyncResultsdata returned in thecallback.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 operationmountOperation- aGMountOperationornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.
-
remountFinish
Finishes remounting a mount. If any errors occurred during the operation,errorwill be set to contain the errors andfalsewill be returned.- Parameters:
result- aGAsyncResult.- Returns:
trueif the mount was successfully remounted.falseotherwise.- Throws:
GErrorException- seeGError
-
shadow
default void shadow()Increments the shadow count onmount.Usually used byGVolumeMonitorimplementations when creating a shadow mount formount,see g_mount_is_shadowed() for more information. The caller will need to emit theGMount::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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the operationcancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.
-
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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the operationcancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.
-
unmountFinish
Deprecated.Use g_mount_unmount_with_operation_finish() instead.Finishes unmounting a mount. If any errors occurred during the operation,errorwill be set to contain the errors andfalsewill be returned.- Parameters:
result- aGAsyncResult.- Returns:
trueif the mount was successfully unmounted.falseotherwise.- Throws:
GErrorException- seeGError
-
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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperationornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.- 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 andGAsyncResultdata returned in thecallback.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperationornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignore.callback- aGAsyncReadyCallback, ornull.- Since:
- 2.22
-
unmountWithOperationFinish
Finishes unmounting a mount. If any errors occurred during the operation,errorwill be set to contain the errors andfalsewill be returned.- Parameters:
result- aGAsyncResult.- Returns:
trueif the mount was successfully unmounted.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.22
-
unshadow
default void unshadow()Decrements the shadow count onmount.Usually used byGVolumeMonitorimplementations when destroying a shadow mount formount,see g_mount_is_shadowed() for more information. The caller will need to emit theGMount::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. SeeonChanged(org.gnome.gio.Mount.ChangedCallback). -
onPreUnmount
This signal may be emitted when theGMountis 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. SeeonPreUnmount(org.gnome.gio.Mount.PreUnmountCallback). -
onUnmounted
This signal is emitted when theGMounthave 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. SeeonUnmounted(org.gnome.gio.Mount.UnmountedCallback).
-