Interface Mount
- All Superinterfaces:
Proxy
- All Known Implementing Classes:
Mount.MountImpl
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
Modifier and TypeInterfaceDescriptionstatic interface
Functional interface declaration of theChangedCallback
callback.static class
Interface for implementing operations for mounts.static class
The MountImpl type represents a native instance of the Mount interface.static interface
Functional interface declaration of thePreUnmountCallback
callback.static interface
Functional interface declaration of theUnmountedCallback
callback. -
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
canEject()
Checks if this Mount can be ejected.default boolean
Checks if this Mount can be unmounted.default void
eject
(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_eject_with_operation() instead.default void
eject
(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_eject_with_operation() instead.default boolean
ejectFinish
(AsyncResult result) Deprecated.Use g_mount_eject_with_operation_finish() instead.default void
ejectWithOperation
(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Ejects a mount.default void
ejectWithOperation
(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Ejects a mount.default boolean
ejectWithOperationFinish
(AsyncResult result) Finishes ejecting a mount.default void
Emits the "changed" signal.default void
Emits the "pre-unmount" signal.default void
Emits the "unmounted" signal.default File
Gets the default location of this Mount.default Drive
getDrive()
Gets the drive for the this Mount.default Icon
getIcon()
Gets the icon for this Mount.default String
getName()
Gets the name of this Mount.default File
getRoot()
Gets the root directory on this Mount.default String
Gets the sort key for this Mount, if any.default Icon
Gets the symbolic icon for this Mount.static Type
getType()
Get the GType of the Mount classdefault String
getUuid()
Gets the UUID for the this Mount.default Volume
Gets the volume for the this Mount.default void
guessContentType
(boolean forceRescan, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Tries to guess the type of content stored on this Mount.default String[]
guessContentTypeFinish
(AsyncResult result) Finishes guessing content types of this Mount.default String[]
guessContentTypeSync
(boolean forceRescan, @Nullable Cancellable cancellable) Tries to guess the type of content stored on this Mount.default boolean
Determines 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 theGMount
is about to be unmounted.default SignalConnection
<Mount.UnmountedCallback> onUnmounted
(Mount.UnmountedCallback handler) This signal is emitted when theGMount
have been unmounted.default void
remount
(Set<MountMountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Remounts a mount.default void
remount
(MountMountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Remounts a mount.default boolean
remountFinish
(AsyncResult result) Finishes remounting a mount.default void
shadow()
Increments the shadow count on this Mount.default void
unmount
(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_unmount_with_operation() instead.default void
unmount
(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_mount_unmount_with_operation() instead.default boolean
unmountFinish
(AsyncResult result) Deprecated.Use g_mount_unmount_with_operation_finish() instead.default void
unmountWithOperation
(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a mount.default void
unmountWithOperation
(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a mount.default boolean
Finishes unmounting a mount.default void
unshadow()
Decrements the shadow count on this Mount.
-
Method Details
-
getType
-
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 @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the unmount if required for ejectcancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
eject
@Deprecated default void eject(MountUnmountFlags flags, @Nullable @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the unmount if required for ejectcancellable
- optionalGCancellable
object,null
to 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,error
will be set to contain the errors andfalse
will be returned.- Parameters:
result
- aGAsyncResult
.- Returns:
true
if the mount was successfully ejected.false
otherwise.- Throws:
GErrorException
- seeGError
-
ejectWithOperation
default void ejectWithOperation(Set<MountUnmountFlags> flags, @Nullable @Nullable MountOperation mountOperation, @Nullable @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the unmount if required for ejectmountOperation
- aGMountOperation
ornull
to avoid user interaction.cancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
ejectWithOperation
default void ejectWithOperation(MountUnmountFlags flags, @Nullable @Nullable MountOperation mountOperation, @Nullable @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the unmount if required for ejectmountOperation
- aGMountOperation
ornull
to avoid user interaction.cancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
ejectWithOperationFinish
Finishes ejecting a mount. If any errors occurred during the operation,error
will be set to contain the errors andfalse
will be returned.- Parameters:
result
- aGAsyncResult
.- Returns:
true
if the mount was successfully ejected.false
otherwise.- Throws:
GErrorException
- seeGError
-
getDefaultLocation
Gets the default location of this 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
Gets the drive for the this Mount.This is a convenience method for getting the
GVolume
and then using that object to get theGDrive
.- Returns:
- a
GDrive
ornull
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
Gets the icon for this Mount.- Returns:
- a
GIcon
. The returned object should be unreffed with g_object_unref() when no longer needed.
-
getName
Gets the name of this Mount.- Returns:
- the name for the given this Mount. The returned string should be freed with g_free() when no longer needed.
-
getRoot
Gets the root directory on this Mount.- Returns:
- a
GFile
. The returned object should be unreffed with g_object_unref() when no longer needed.
-
getSortKey
Gets the sort key for this Mount, if any.- Returns:
- Sorting key for this Mount or
null
if no such key is available.
-
getSymbolicIcon
Gets the symbolic icon for this Mount.- Returns:
- a
GIcon
. The returned object should be unreffed with g_object_unref() when no longer needed.
-
getUuid
Gets the UUID for the this Mount. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returnsnull
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
Gets the volume for the this Mount.- Returns:
- a
GVolume
ornull
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 @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Tries to guess the type of content stored on this 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 thecallback
.- Parameters:
forceRescan
- Whether to force a rescan of the content. Otherwise a cached result will be used if availablecancellable
- optionalGCancellable
object,null
to ignorecallback
- aGAsyncReadyCallback
-
guessContentTypeFinish
Finishes guessing content types of this Mount. If any errors occurred during the operation,error
will be set to contain the errors andfalse
will be returned. In particular, you may get anIOErrorEnum.NOT_SUPPORTED
if the mount does not support content guessing.- Parameters:
result
- aGAsyncResult
- Returns:
- a
null
-terminated array of content types ornull
on error. Caller should free this array with g_strfreev() when done with it. - Throws:
GErrorException
- seeGError
-
guessContentTypeSync
default String[] guessContentTypeSync(boolean forceRescan, @Nullable @Nullable Cancellable cancellable) throws GErrorException Tries to guess the type of content stored on this 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 availablecancellable
- optionalGCancellable
object,null
to ignore- Returns:
- a
null
-terminated array of content types ornull
on error. Caller should free this array with g_strfreev() when done with it. - Throws:
GErrorException
- seeGError
-
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 this 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 twoGVolume
objects (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, saidGVolumeMonitor
implementation would create twoGMount
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.
-
remount
default void remount(Set<MountMountFlags> flags, @Nullable @Nullable MountOperation mountOperation, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Remounts a mount. This is an asynchronous operation, and is finished by calling g_mount_remount_finish() with the this Mount andGAsyncResults
data 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
- aGMountOperation
ornull
to avoid user interaction.cancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
remount
default void remount(MountMountFlags flags, @Nullable @Nullable MountOperation mountOperation, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Remounts a mount. This is an asynchronous operation, and is finished by calling g_mount_remount_finish() with the this Mount andGAsyncResults
data 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
- aGMountOperation
ornull
to avoid user interaction.cancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
remountFinish
Finishes remounting a mount. If any errors occurred during the operation,error
will be set to contain the errors andfalse
will be returned.- Parameters:
result
- aGAsyncResult
.- Returns:
true
if the mount was successfully remounted.false
otherwise.- Throws:
GErrorException
- seeGError
-
shadow
default void shadow()Increments the shadow count on this Mount. Usually used byGVolumeMonitor
implementations when creating a shadow mount for this Mount, see g_mount_is_shadowed() for more information. The caller will need to emit theGMount
::changed signal on this Mount manually. -
unmount
@Deprecated default void unmount(Set<MountUnmountFlags> flags, @Nullable @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the operationcancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
unmount
@Deprecated default void unmount(MountUnmountFlags flags, @Nullable @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the operationcancellable
- optionalGCancellable
object,null
to 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,error
will be set to contain the errors andfalse
will be returned.- Parameters:
result
- aGAsyncResult
.- Returns:
true
if the mount was successfully unmounted.false
otherwise.- Throws:
GErrorException
- seeGError
-
unmountWithOperation
default void unmountWithOperation(Set<MountUnmountFlags> flags, @Nullable @Nullable MountOperation mountOperation, @Nullable @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the operationmountOperation
- aGMountOperation
ornull
to avoid user interaction.cancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
unmountWithOperation
default void unmountWithOperation(MountUnmountFlags flags, @Nullable @Nullable MountOperation mountOperation, @Nullable @Nullable Cancellable cancellable, @Nullable @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 andGAsyncResult
data returned in thecallback
.- Parameters:
flags
- flags affecting the operationmountOperation
- aGMountOperation
ornull
to avoid user interaction.cancellable
- optionalGCancellable
object,null
to ignore.callback
- aGAsyncReadyCallback
, ornull
.
-
unmountWithOperationFinish
Finishes unmounting a mount. If any errors occurred during the operation,error
will be set to contain the errors andfalse
will be returned.- Parameters:
result
- aGAsyncResult
.- Returns:
true
if the mount was successfully unmounted.false
otherwise.- Throws:
GErrorException
- seeGError
-
unshadow
default void unshadow()Decrements the shadow count on this Mount. Usually used byGVolumeMonitor
implementations when destroying a shadow mount for this Mount, see g_mount_is_shadowed() for more information. The caller will need to emit theGMount
::changed signal on this Mount manually. -
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 theGMount
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
- See Also:
-
emitPreUnmount
default void emitPreUnmount()Emits the "pre-unmount" signal. SeeonPreUnmount(org.gnome.gio.Mount.PreUnmountCallback)
. -
onUnmounted
This signal is emitted when theGMount
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. SeeonUnmounted(org.gnome.gio.Mount.UnmountedCallback)
.
-