Interface File
- All Superinterfaces:
Proxy
- All Known Implementing Classes:
File.File$Impl
GFile is a high level abstraction for manipulating files on a
virtual file system. GFiles are lightweight, immutable objects
that do no I/O upon creation. It is necessary to understand that
GFile objects do not represent files, merely an identifier for a
file. All file content I/O is implemented as streaming operations
(see InputStream and OutputStream).
To construct a GFile, you can use:
newForPath(java.lang.String)if you have a path.newForUri(java.lang.String)if you have a URI.newForCommandlineArg(java.lang.String)ornewForCommandlineArgAndCwd(java.lang.String, java.lang.String)for a command line argument.newTmp(java.lang.String, org.javagi.base.Out<org.gnome.gio.FileIOStream>)to create a temporary file from a template.newTmpAsync(java.lang.String, int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)to asynchronously create a temporary file.newTmpDirAsync(java.lang.String, int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)to asynchronously create a temporary directory.parseName(java.lang.String)from a UTF-8 string gotten fromgetParseName().newBuildFilename(java.lang.String, java.lang.Object...)ornewBuildFilenamev(java.lang.String[])to create a file from path elements.
One way to think of a GFile is as an abstraction of a pathname. For
normal files the system pathname is what is stored internally, but as
GFiles are extensible it could also be something else that corresponds
to a pathname in a userspace implementation of a filesystem.
GFiles make up hierarchies of directories and files that correspond to
the files on a filesystem. You can move through the file system with
GFile using getParent() to get an identifier for the
parent directory, getChild(java.lang.String) to get a child within a
directory, and resolveRelativePath(java.lang.String) to resolve a relative
path between two GFiles. There can be multiple hierarchies, so you may not
end up at the same root if you repeatedly call getParent()
on two different files.
All GFiles have a basename (get with getBasename()). These
names are byte strings that are used to identify the file on the filesystem
(relative to its parent directory) and there is no guarantees that they
have any particular charset encoding or even make any sense at all. If
you want to use filenames in a user interface you should use the display
name that you can get by requesting the
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with
queryInfo(java.lang.String, java.util.Set<org.gnome.gio.FileQueryInfoFlags>, org.gnome.gio.Cancellable). This is guaranteed to be in UTF-8 and can be
used in a user interface. But always store the real basename or the GFile
to use to actually access the file, because there is no way to go from a
display name to the actual name.
Using GFile as an identifier has the same weaknesses as using a path
in that there may be multiple aliases for the same file. For instance,
hard or soft links may cause two different GFiles to refer to the same
file. Other possible causes for aliases are: case insensitive filesystems,
short and long names on FAT/NTFS, or bind mounts in Linux. If you want to
check if two GFiles point to the same file you can query for the
G_FILE_ATTRIBUTE_ID_FILE attribute. Note that GFile does some trivial
canonicalization of pathnames passed in, so that trivial differences in
the path string used at creation (duplicated slashes, slash at end of
path, . or .. path segments, etc) does not create different GFiles.
Many GFile operations have both synchronous and asynchronous versions
to suit your application. Asynchronous versions of synchronous functions
simply have _async() appended to their function names. The asynchronous
I/O functions call a Gio.AsyncReadyCallback which is then used to
finalize the operation, producing a AsyncResult which is then
passed to the function’s matching _finish() operation.
It is highly recommended to use asynchronous calls when running within a shared main loop, such as in the main thread of an application. This avoids I/O operations blocking other sources on the main loop from being dispatched. Synchronous I/O operations should be performed from worker threads. See the introduction to asynchronous programming section for more.
Some GFile operations almost always take a noticeable amount of time, and
so do not have synchronous analogs. Notable cases include:
mountMountable(java.util.Set<org.gnome.gio.MountMountFlags>, org.gnome.gio.MountOperation, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)to mount a mountable file.unmountMountableWithOperation(java.util.Set<org.gnome.gio.MountUnmountFlags>, org.gnome.gio.MountOperation, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)to unmount a mountable file.ejectMountableWithOperation(java.util.Set<org.gnome.gio.MountUnmountFlags>, org.gnome.gio.MountOperation, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)to eject a mountable file.
Entity Tags
One notable feature of GFiles are entity tags, or ‘etags’ for
short. Entity tags are somewhat like a more abstract version of the
traditional mtime, and can be used to quickly determine if the file
has been modified from the version on the file system. See the
HTTP 1.1
specification
for HTTP ETag headers, which are a very similar concept.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe File$Impl type represents a native instance of the File interface.static classAn interface for writing VFS file handles. -
Method Summary
Modifier and TypeMethodDescriptiondefault FileOutputStreamappendTo(Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) Gets an output stream for appending data to the file.default FileOutputStreamappendTo(FileCreateFlags flags, @Nullable Cancellable cancellable) Gets an output stream for appending data to the file.default voidappendToAsync(Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for appending.default voidappendToAsync(FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for appending.default FileOutputStreamFinishes an asynchronous file append operation started with g_file_append_to_async().default StringbuildAttributeListForCopy(Set<FileCopyFlags> flags, @Nullable Cancellable cancellable) Prepares the file attribute query string for copying tofile.default StringbuildAttributeListForCopy(FileCopyFlags flags, @Nullable Cancellable cancellable) Prepares the file attribute query string for copying tofile.default booleancopy(File destination, Set<FileCopyFlags> flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) Copies the file this File to the location specified bydestination.Can not handle recursive copies of directories.default booleancopy(File destination, FileCopyFlags flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) Copies the file this File to the location specified bydestination.Can not handle recursive copies of directories.default voidcopyAsync(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Copies the file this File to the location specified bydestinationasynchronously.default voidcopyAsync(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Copies the file this File to the location specified bydestinationasynchronously.default voidcopyAsyncWithClosures(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofcopyAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.default voidcopyAsyncWithClosures(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofcopyAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.default booleancopyAttributes(File destination, Set<FileCopyFlags> flags, @Nullable Cancellable cancellable) Copies the file attributes from this File todestination.default booleancopyAttributes(File destination, FileCopyFlags flags, @Nullable Cancellable cancellable) Copies the file attributes from this File todestination.default booleancopyFinish(AsyncResult res) Finishes copying the file started with g_file_copy_async().default FileOutputStreamcreate(Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) Creates a new file and returns an output stream for writing to it.default FileOutputStreamcreate(FileCreateFlags flags, @Nullable Cancellable cancellable) Creates a new file and returns an output stream for writing to it.default voidcreateAsync(Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns an output stream for writing to it.default voidcreateAsync(FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns an output stream for writing to it.default FileOutputStreamcreateFinish(AsyncResult res) Finishes an asynchronous file create operation started with g_file_create_async().default FileIOStreamcreateReadwrite(Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) Creates a new file and returns a stream for reading and writing to it.default FileIOStreamcreateReadwrite(FileCreateFlags flags, @Nullable Cancellable cancellable) Creates a new file and returns a stream for reading and writing to it.default voidcreateReadwriteAsync(Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns a stream for reading and writing to it.default voidcreateReadwriteAsync(FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns a stream for reading and writing to it.default FileIOStreamFinishes an asynchronous file create operation started with g_file_create_readwrite_async().default booleandelete(@Nullable Cancellable cancellable) Deletes a file.default voiddeleteAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously delete a file.default booleandeleteFinish(AsyncResult result) Finishes deleting a file started with g_file_delete_async().default Filedup()Duplicates aGFilehandle.default voidejectMountable(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_eject_mountable_with_operation() instead.default voidejectMountable(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_eject_mountable_with_operation() instead.default booleanejectMountableFinish(AsyncResult result) Deprecated.Use g_file_eject_mountable_with_operation_finish() instead.default voidejectMountableWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous eject on a mountable.default voidejectMountableWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous eject on a mountable.default booleanFinishes an asynchronous eject operation started by g_file_eject_mountable_with_operation().default FileEnumeratorenumerateChildren(String attributes, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Gets the requested information about the files in a directory.default FileEnumeratorenumerateChildren(String attributes, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Gets the requested information about the files in a directory.default voidenumerateChildrenAsync(String attributes, Set<FileQueryInfoFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about the files in a directory.default voidenumerateChildrenAsync(String attributes, FileQueryInfoFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about the files in a directory.default FileEnumeratorFinishes an async enumerate children operation.default booleanChecks if the two givenGFilesrefer to the same file.default MountfindEnclosingMount(@Nullable Cancellable cancellable) Gets aGMountfor theGFile.default voidfindEnclosingMountAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the mount for the file.default MountFinishes an asynchronous find mount request.default @Nullable StringGets the base name (the last component of the path) for a givenGFile.default FileGets a child of this File with basename equal toname.default FilegetChildForDisplayName(String displayName) Gets the child of this File for a givendisplayName(i.e.default @Nullable FileGets the parent directory for thefile.If the this File represents the root directory of the file system, thennullwill be returned.default StringGets the parse name of thefile.A parse name is a UTF-8 string that describes the file such that one can get theGFileback using g_file_parse_name().default @Nullable StringgetPath()Gets the local pathname forGFile, if one exists.default @Nullable StringgetRelativePath(File descendant) Gets the path fordescendantrelative toparent.static @Nullable TypegetType()Get the GType of the File classdefault StringgetUri()Gets the URI for thefile.default @Nullable StringGets the URI scheme for aGFile.default inthash()Creates a hash value for aGFile.default booleanChecks if this File has a parent, and optionally, if it isparent.default booleanChecks whether this File has the prefix specified byprefix.default booleanhasUriScheme(String uriScheme) Checks to see if aGFilehas a given URI scheme.default booleanisNative()Checks to see if a file is native to the platform.default byte[]loadBytes(@Nullable Cancellable cancellable, @Nullable Out<String> etagOut) Loads the contents of this File and returns it asGBytes.default voidloadBytesAsync(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously loads the contents of this File asGBytes.default byte[]loadBytesFinish(AsyncResult result, @Nullable Out<String> etagOut) Completes an asynchronous request to g_file_load_bytes_async().default booleanloadContents(@Nullable Cancellable cancellable, @Nullable Out<byte[]> contents, @Nullable Out<String> etagOut) Loads the content of the file into memory.default voidloadContentsAsync(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous load of thefile'scontents.default booleanloadContentsFinish(AsyncResult res, @Nullable Out<byte[]> contents, @Nullable Out<String> etagOut) Finishes an asynchronous load of thefile'scontents.default voidloadPartialContentsAsync(@Nullable Cancellable cancellable, @Nullable FileReadMoreCallback readMoreCallback, @Nullable AsyncReadyCallback callback) Reads the partial contents of a file.default booleanloadPartialContentsFinish(AsyncResult res, @Nullable Out<byte[]> contents, @Nullable Out<String> etagOut) Finishes an asynchronous partial load operation that was started with g_file_load_partial_contents_async().default booleanmakeDirectory(@Nullable Cancellable cancellable) Creates a directory.default voidmakeDirectoryAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a directory.default booleanmakeDirectoryFinish(AsyncResult result) Finishes an asynchronous directory creation, started with g_file_make_directory_async().default booleanmakeDirectoryWithParents(@Nullable Cancellable cancellable) Creates a directory and any parent directories that may not exist similar to 'mkdir -p'.default booleanmakeSymbolicLink(String symlinkValue, @Nullable Cancellable cancellable) Creates a symbolic link named this File which contains the stringsymlinkValue.default voidmakeSymbolicLinkAsync(String symlinkValue, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a symbolic link named this File which contains the stringsymlinkValue.default booleanmakeSymbolicLinkFinish(AsyncResult result) Finishes an asynchronous symbolic link creation, started with g_file_make_symbolic_link_async().default booleanmeasureDiskUsage(Set<FileMeasureFlags> flags, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable Out<Long> diskUsage, @Nullable Out<Long> numDirs, @Nullable Out<Long> numFiles) Recursively measures the disk usage offile.default booleanmeasureDiskUsage(FileMeasureFlags flags, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable Out<Long> diskUsage, @Nullable Out<Long> numDirs, @Nullable Out<Long> numFiles) Recursively measures the disk usage offile.default voidmeasureDiskUsageAsync(Set<FileMeasureFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Recursively measures the disk usage offile.default voidmeasureDiskUsageAsync(FileMeasureFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Recursively measures the disk usage offile.default booleanmeasureDiskUsageFinish(AsyncResult result, @Nullable Out<Long> diskUsage, @Nullable Out<Long> numDirs, @Nullable Out<Long> numFiles) Collects the results from an earlier call to g_file_measure_disk_usage_async().default FileMonitormonitor(Set<FileMonitorFlags> flags, @Nullable Cancellable cancellable) Obtains a file or directory monitor for the given file, depending on the type of the file.default FileMonitormonitor(FileMonitorFlags flags, @Nullable Cancellable cancellable) Obtains a file or directory monitor for the given file, depending on the type of the file.default FileMonitormonitorDirectory(Set<FileMonitorFlags> flags, @Nullable Cancellable cancellable) Obtains a directory monitor for the given file.default FileMonitormonitorDirectory(FileMonitorFlags flags, @Nullable Cancellable cancellable) Obtains a directory monitor for the given file.default FileMonitormonitorFile(Set<FileMonitorFlags> flags, @Nullable Cancellable cancellable) Obtains a file monitor for the given file.default FileMonitormonitorFile(FileMonitorFlags flags, @Nullable Cancellable cancellable) Obtains a file monitor for the given file.default voidmountEnclosingVolume(Set<MountMountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts amountOperation,mounting the volume that contains the filelocation.default voidmountEnclosingVolume(MountMountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts amountOperation,mounting the volume that contains the filelocation.default booleanFinishes a mount operation started by g_file_mount_enclosing_volume().default voidmountMountable(Set<MountMountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Mounts a file of type G_FILE_TYPE_MOUNTABLE.default voidmountMountable(MountMountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Mounts a file of type G_FILE_TYPE_MOUNTABLE.default FilemountMountableFinish(AsyncResult result) Finishes a mount operation.default booleanmove(File destination, Set<FileCopyFlags> flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) Tries to move the file or directory this File to the location specified bydestination.If native move operations are supported then this is used, otherwise a copy + delete fallback is used.default booleanmove(File destination, FileCopyFlags flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) Tries to move the file or directory this File to the location specified bydestination.If native move operations are supported then this is used, otherwise a copy + delete fallback is used.default voidmoveAsync(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Asynchronously moves a file this File to the location ofdestination.For details of the behaviour, see g_file_move().default voidmoveAsync(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Asynchronously moves a file this File to the location ofdestination.For details of the behaviour, see g_file_move().default voidmoveAsyncWithClosures(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofmoveAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.default voidmoveAsyncWithClosures(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofmoveAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.default booleanmoveFinish(AsyncResult result) Finishes an asynchronous file movement, started with g_file_move_async().static FilenewBuildFilename(String firstElement, Object... varargs) Constructs aGFilefrom a series of elements using the correct separator for filenames.static FilenewBuildFilenamev(@Nullable String @Nullable [] args) Constructs aGFilefrom a vector of elements using the correct separator for filenames.static FileCreates aGFilewith the given argument from the command line.static FilenewForCommandlineArgAndCwd(String arg, String cwd) Creates aGFilewith the given argument from the command line.static FilenewForPath(String path) Constructs aGFilefor a given path.static FileConstructs aGFilefor a given URI.static FilenewTmp(@Nullable String tmpl, Out<FileIOStream> iostream) Opens a file in the preferred directory for temporary files (as returned by g_get_tmp_dir()) and returns aGFileandGFileIOStreampointing to it.static voidnewTmpAsync(@Nullable String tmpl, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens a file in the preferred directory for temporary files (as returned by g_get_tmp_dir()) as g_file_new_tmp().static voidnewTmpDirAsync(@Nullable String tmpl, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a directory in the preferred directory for temporary files (as returned by g_get_tmp_dir()) as g_dir_make_tmp().static FilenewTmpDirFinish(AsyncResult result) Finishes a temporary directory creation started by g_file_new_tmp_dir_async().static FilenewTmpFinish(AsyncResult result, Out<FileIOStream> iostream) Finishes a temporary file creation started by g_file_new_tmp_async().default FileIOStreamopenReadwrite(@Nullable Cancellable cancellable) Opens an existing file for reading and writing.default voidopenReadwriteAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for reading and writing.default FileIOStreamFinishes an asynchronous file read operation started with g_file_open_readwrite_async().static FileConstructs aGFilewith the givenparseName(i.e.default @Nullable StringpeekPath()Exactly like g_file_get_path(), but caches the result via g_object_set_qdata_full().default voidpollMountable(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Polls a file of typeFileType.MOUNTABLE.default booleanpollMountableFinish(AsyncResult result) Finishes a poll operation.default AppInfoqueryDefaultHandler(@Nullable Cancellable cancellable) Returns theGAppInfothat is registered as the default application to handle the file specified byfile.default voidqueryDefaultHandlerAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Async version of g_file_query_default_handler().default AppInfoqueryDefaultHandlerFinish(AsyncResult result) Finishes a g_file_query_default_handler_async() operation.default booleanqueryExists(@Nullable Cancellable cancellable) Utility function to check if a particular file exists.default FileInfoqueryFilesystemInfo(String attributes, @Nullable Cancellable cancellable) Similar to g_file_query_info(), but obtains information about the filesystem the this File is on, rather than the file itself.default voidqueryFilesystemInfoAsync(String attributes, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about the filesystem that the specified this File is on.default FileInfoFinishes an asynchronous filesystem info query.default FileTypequeryFileType(Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Utility function to inspect theGFileTypeof a file.default FileTypequeryFileType(FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Utility function to inspect theGFileTypeof a file.default FileInfoqueryInfo(String attributes, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Gets the requested information about specifiedfile.default FileInfoqueryInfo(String attributes, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Gets the requested information about specifiedfile.default voidqueryInfoAsync(String attributes, Set<FileQueryInfoFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about specifiedfile.The result is aGFileInfoobject that contains key-value attributes (such as type or size for the file).default voidqueryInfoAsync(String attributes, FileQueryInfoFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about specifiedfile.The result is aGFileInfoobject that contains key-value attributes (such as type or size for the file).default FileInfoFinishes an asynchronous file info query.default FileAttributeInfoListquerySettableAttributes(@Nullable Cancellable cancellable) Obtain the list of settable attributes for the file.default FileAttributeInfoListqueryWritableNamespaces(@Nullable Cancellable cancellable) Obtain the list of attribute namespaces where new attributes can be created by a user.default FileInputStreamread(@Nullable Cancellable cancellable) Opens a file for reading.default voidreadAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for reading.default FileInputStreamreadFinish(AsyncResult res) Finishes an asynchronous file read operation started with g_file_read_async().default FileOutputStreamreplace(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) Returns an output stream for overwriting the file, possibly creating a backup copy of the file first.default FileOutputStreamreplace(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable) Returns an output stream for overwriting the file, possibly creating a backup copy of the file first.default voidreplaceAsync(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.default voidreplaceAsync(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.default booleanreplaceContents(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Out<String> newEtag, @Nullable Cancellable cancellable) Replaces the contents of this File withcontentsoflengthbytes.default booleanreplaceContents(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Out<String> newEtag, @Nullable Cancellable cancellable) Replaces the contents of this File withcontentsoflengthbytes.default voidreplaceContentsAsync(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous replacement of this File with the givencontentsoflengthbytes.default voidreplaceContentsAsync(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous replacement of this File with the givencontentsoflengthbytes.default voidreplaceContentsBytesAsync(byte[] contents, @Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Same as g_file_replace_contents_async() but takes aGBytesinput instead.default voidreplaceContentsBytesAsync(byte[] contents, @Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Same as g_file_replace_contents_async() but takes aGBytesinput instead.default booleanreplaceContentsFinish(AsyncResult res, @Nullable Out<String> newEtag) Finishes an asynchronous replace of the givenfile.See g_file_replace_contents_async().default FileOutputStreamreplaceFinish(AsyncResult res) Finishes an asynchronous file replace operation started with g_file_replace_async().default FileIOStreamreplaceReadwrite(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first.default FileIOStreamreplaceReadwrite(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable) Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first.default voidreplaceReadwriteAsync(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.default voidreplaceReadwriteAsync(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.default FileIOStreamFinishes an asynchronous file replace operation started with g_file_replace_readwrite_async().default FileresolveRelativePath(String relativePath) Resolves a relative path for this File to an absolute path.default booleansetAttribute(String attribute, FileAttributeType type, @Nullable MemorySegment valueP, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Sets an attribute in the file with attribute nameattributetovalueP.default booleansetAttribute(String attribute, FileAttributeType type, @Nullable MemorySegment valueP, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Sets an attribute in the file with attribute nameattributetovalueP.default booleansetAttributeByteString(String attribute, String value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.BYTE_STRINGtovalue.Ifattributeis of a different type, this operation will fail, returningfalse.default booleansetAttributeByteString(String attribute, String value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.BYTE_STRINGtovalue.Ifattributeis of a different type, this operation will fail, returningfalse.default booleansetAttributeInt32(String attribute, int value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.INT32tovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeInt32(String attribute, int value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.INT32tovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeInt64(String attribute, long value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.INT64tovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeInt64(String attribute, long value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.INT64tovalue.Ifattributeis of a different type, this operation will fail.default voidsetAttributesAsync(FileInfo info, Set<FileQueryInfoFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sets the attributes of this File withinfo.default voidsetAttributesAsync(FileInfo info, FileQueryInfoFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sets the attributes of this File withinfo.default booleansetAttributesFinish(AsyncResult result, Out<FileInfo> info) Finishes setting an attribute started in g_file_set_attributes_async().default booleansetAttributesFromInfo(FileInfo info, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Tries to set all attributes in theGFileInfoon the target values, not stopping on the first error.default booleansetAttributesFromInfo(FileInfo info, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Tries to set all attributes in theGFileInfoon the target values, not stopping on the first error.default booleansetAttributeString(String attribute, String value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.STRINGtovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeString(String attribute, String value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.STRINGtovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeUint32(String attribute, int value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.UINT32tovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeUint32(String attribute, int value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.UINT32tovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeUint64(String attribute, long value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.UINT64tovalue.Ifattributeis of a different type, this operation will fail.default booleansetAttributeUint64(String attribute, long value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) Setsattributeof typeFileAttributeType.UINT64tovalue.Ifattributeis of a different type, this operation will fail.default FilesetDisplayName(String displayName, @Nullable Cancellable cancellable) Renames this File to the specified display name.default voidsetDisplayNameAsync(String displayName, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sets the display name for a givenGFile.default FileFinishes setting a display name started with g_file_set_display_name_async().default voidstartMountable(Set<DriveStartFlags> flags, @Nullable MountOperation startOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts a file of typeFileType.MOUNTABLE.default voidstartMountable(DriveStartFlags flags, @Nullable MountOperation startOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts a file of typeFileType.MOUNTABLE.default booleanstartMountableFinish(AsyncResult result) Finishes a start operation.default voidstopMountable(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Stops a file of typeFileType.MOUNTABLE.default voidstopMountable(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Stops a file of typeFileType.MOUNTABLE.default booleanstopMountableFinish(AsyncResult result) Finishes a stop operation, see g_file_stop_mountable() for details.default booleanChecks if this File supports thread-default main contexts (seeMainContext.pushThreadDefault()) If this returnsfalse, you cannot perform asynchronous operations on this File in a thread that has a thread-default context.default booleantrash(@Nullable Cancellable cancellable) Sends this File to the "Trashcan", if possible.default voidtrashAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sends this File to the Trash location, if possible.default booleantrashFinish(AsyncResult result) Finishes an asynchronous file trashing operation, started with g_file_trash_async().default voidunmountMountable(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_unmount_mountable_with_operation() instead.default voidunmountMountable(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_unmount_mountable_with_operation() instead.default booleanunmountMountableFinish(AsyncResult result) Deprecated.Use g_file_unmount_mountable_with_operation_finish() instead.default voidunmountMountableWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a file of typeFileType.MOUNTABLE.default voidunmountMountableWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a file of typeFileType.MOUNTABLE.default booleanFinishes an unmount operation, see g_file_unmount_mountable_with_operation() for details.
-
Method Details
-
getType
-
newBuildFilename
Constructs aGFilefrom a series of elements using the correct separator for filenames.Using this function is equivalent to calling g_build_filename(), followed by g_file_new_for_path() on the result.
- Parameters:
firstElement- the first element in the pathvarargs- remaining elements in path, terminated bynull- Returns:
- a new
GFile - Since:
- 2.56
-
newBuildFilenamev
Constructs aGFilefrom a vector of elements using the correct separator for filenames.Using this function is equivalent to calling g_build_filenamev(), followed by g_file_new_for_path() on the result.
- Parameters:
args-null-terminated array of strings containing the path elements.- Returns:
- a new
GFile - Since:
- 2.78
-
newForCommandlineArg
Creates aGFilewith the given argument from the command line. The value ofargcan be either a URI, an absolute path or a relative path resolved relative to the current working directory. This operation never fails, but the returned object might not support any I/O operation ifargpoints to a malformed path.Note that on Windows, this function expects its argument to be in UTF-8 -- not the system code page. This means that you should not use this function with string from argv as it is passed to main(). g_win32_get_command_line() will return a UTF-8 version of the commandline.
GApplicationalso uses UTF-8 but g_application_command_line_create_file_for_arg() may be more useful for you there. It is also always possible to use this function withGOptionContextarguments of typeOptionArg.FILENAME.- Parameters:
arg- a command line string- Returns:
- a new
GFile. Free the returned object with g_object_unref().
-
newForCommandlineArgAndCwd
Creates aGFilewith the given argument from the command line.This function is similar to g_file_new_for_commandline_arg() except that it allows for passing the current working directory as an argument instead of using the current working directory of the process.
This is useful if the commandline argument was given in a context other than the invocation of the current process.
See also g_application_command_line_create_file_for_arg().
- Parameters:
arg- a command line stringcwd- the current working directory of the commandline- Returns:
- a new
GFile - Since:
- 2.36
-
newForPath
Constructs aGFilefor a given path. This operation never fails, but the returned object might not support any I/O operation ifpathis malformed.- Parameters:
path- a string containing a relative or absolute path. The string must be encoded in the glib filename encoding.- Returns:
- a new
GFilefor the givenpath.Free the returned object with g_object_unref().
-
newForUri
Constructs aGFilefor a given URI. This operation never fails, but the returned object might not support any I/O operation ifuriis malformed or if the uri type is not supported.- Parameters:
uri- a UTF-8 string containing a URI- Returns:
- a new
GFilefor the givenuri.Free the returned object with g_object_unref().
-
newTmp
Opens a file in the preferred directory for temporary files (as returned by g_get_tmp_dir()) and returns aGFileandGFileIOStreampointing to it.tmplshould be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it isnull, a default template is used.Unlike the other
GFileconstructors, this will returnnullif a temporary file could not be created.- Parameters:
tmpl- Template for the file name, as in g_file_open_tmp(), ornullfor a default templateiostream- on return, aGFileIOStreamfor the created file- Returns:
- a new
GFile. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.32
-
newTmpAsync
static void newTmpAsync(@Nullable String tmpl, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens a file in the preferred directory for temporary files (as returned by g_get_tmp_dir()) as g_file_new_tmp().tmplshould be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it isnull, a default template is used.- Parameters:
tmpl- Template for the file name, as in g_file_open_tmp(), ornullfor a default templateioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is done- Since:
- 2.74
-
newTmpDirAsync
static void newTmpDirAsync(@Nullable String tmpl, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a directory in the preferred directory for temporary files (as returned by g_get_tmp_dir()) as g_dir_make_tmp().tmplshould be a string in the GLib file name encoding containing a sequence of six 'X' characters, and containing no directory components. If it isnull, a default template is used.- Parameters:
tmpl- Template for the file name, as in g_dir_make_tmp(), ornullfor a default templateioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is done- Since:
- 2.74
-
newTmpDirFinish
Finishes a temporary directory creation started by g_file_new_tmp_dir_async().- Parameters:
result- aGAsyncResult- Returns:
- a new
GFile. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.74
-
newTmpFinish
Finishes a temporary file creation started by g_file_new_tmp_async().- Parameters:
result- aGAsyncResultiostream- on return, aGFileIOStreamfor the created file- Returns:
- a new
GFile. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.74
-
parseName
Constructs aGFilewith the givenparseName(i.e. something given by g_file_get_parse_name()). This operation never fails, but the returned object might not support any I/O operation if theparseNamecannot be parsed.- Parameters:
parseName- a file name or path to be parsed- Returns:
- a new
GFile.
-
appendTo
default FileOutputStream appendTo(Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Gets an output stream for appending data to the file. If the file doesn't already exist it is created.By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.Some file systems don't allow all file names, and may return an
IOErrorEnum.INVALID_FILENAMEerror. If the file is a directory theIOErrorEnum.IS_DIRECTORYerror will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
flags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileOutputStream, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
appendTo
default FileOutputStream appendTo(FileCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException Gets an output stream for appending data to the file. If the file doesn't already exist it is created.By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.Some file systems don't allow all file names, and may return an
IOErrorEnum.INVALID_FILENAMEerror. If the file is a directory theIOErrorEnum.IS_DIRECTORYerror will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
flags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileOutputStream, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
appendToAsync
default void appendToAsync(Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for appending.For more details, see g_file_append_to() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_append_to_finish() to get the result of the operation.- Parameters:
flags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
appendToAsync
default void appendToAsync(FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for appending.For more details, see g_file_append_to() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_append_to_finish() to get the result of the operation.- Parameters:
flags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
appendToFinish
Finishes an asynchronous file append operation started with g_file_append_to_async().- Parameters:
res-GAsyncResult- Returns:
- a valid
GFileOutputStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
buildAttributeListForCopy
default String buildAttributeListForCopy(Set<FileCopyFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Prepares the file attribute query string for copying tofile.This function prepares an attribute query string to be passed to g_file_query_info() to get a list of attributes normally copied with the file (see g_file_copy_attributes() for the detailed description). This function is used by the implementation of g_file_copy_attributes() and is useful when one needs to query and set the attributes in two stages (e.g., for recursive move of a directory).
- Parameters:
flags- a set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- an attribute query string for g_file_query_info(),
or
nullif an error occurs. - Throws:
GErrorException- seeGError- Since:
- 2.68
-
buildAttributeListForCopy
default String buildAttributeListForCopy(FileCopyFlags flags, @Nullable Cancellable cancellable) throws GErrorException Prepares the file attribute query string for copying tofile.This function prepares an attribute query string to be passed to g_file_query_info() to get a list of attributes normally copied with the file (see g_file_copy_attributes() for the detailed description). This function is used by the implementation of g_file_copy_attributes() and is useful when one needs to query and set the attributes in two stages (e.g., for recursive move of a directory).
- Parameters:
flags- a set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- an attribute query string for g_file_query_info(),
or
nullif an error occurs. - Throws:
GErrorException- seeGError- Since:
- 2.68
-
copy
default boolean copy(File destination, Set<FileCopyFlags> flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) throws GErrorException Copies the file this File to the location specified bydestination.Can not handle recursive copies of directories.If the flag
FileCopyFlags.OVERWRITEis specified an already existingdestinationfile is overwritten.If the flag
FileCopyFlags.NOFOLLOW_SYMLINKSis specified then symlinks will be copied as symlinks, otherwise the target of the this File symlink will be copied.If the flag
FileCopyFlags.ALL_METADATAis specified then all the metadata that is possible to copy is copied, not just the default subset (which, for instance, does not include the owner, seeGFileInfo).If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
progressCallbackis notnull, then the operation can be monitored by setting this to aGFileProgressCallbackfunction.progressCallbackDatawill be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.If the this File file does not exist, then the
IOErrorEnum.NOT_FOUNDerror is returned, independent on the status of thedestination.If
FileCopyFlags.OVERWRITEis not specified and the target exists, then the errorIOErrorEnum.EXISTSis returned.If trying to overwrite a file over a directory, the
IOErrorEnum.IS_DIRECTORYerror is returned. If trying to overwrite a directory with a directory theIOErrorEnum.WOULD_MERGEerror is returned.If the source is a directory and the target does not exist, or
FileCopyFlags.OVERWRITEis specified and the target is a file, then theIOErrorEnum.WOULD_RECURSEerror is returned.If you are interested in copying the
GFileobject itself (not the on-disk file), see g_file_dup().- Parameters:
destination- destinationGFileflags- set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignoreprogressCallback- function to callback with progress information, ornullif progress information is not needed- Returns:
trueon success,falseotherwise.- Throws:
GErrorException- seeGError
-
copy
default boolean copy(File destination, FileCopyFlags flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) throws GErrorException Copies the file this File to the location specified bydestination.Can not handle recursive copies of directories.If the flag
FileCopyFlags.OVERWRITEis specified an already existingdestinationfile is overwritten.If the flag
FileCopyFlags.NOFOLLOW_SYMLINKSis specified then symlinks will be copied as symlinks, otherwise the target of the this File symlink will be copied.If the flag
FileCopyFlags.ALL_METADATAis specified then all the metadata that is possible to copy is copied, not just the default subset (which, for instance, does not include the owner, seeGFileInfo).If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
progressCallbackis notnull, then the operation can be monitored by setting this to aGFileProgressCallbackfunction.progressCallbackDatawill be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.If the this File file does not exist, then the
IOErrorEnum.NOT_FOUNDerror is returned, independent on the status of thedestination.If
FileCopyFlags.OVERWRITEis not specified and the target exists, then the errorIOErrorEnum.EXISTSis returned.If trying to overwrite a file over a directory, the
IOErrorEnum.IS_DIRECTORYerror is returned. If trying to overwrite a directory with a directory theIOErrorEnum.WOULD_MERGEerror is returned.If the source is a directory and the target does not exist, or
FileCopyFlags.OVERWRITEis specified and the target is a file, then theIOErrorEnum.WOULD_RECURSEerror is returned.If you are interested in copying the
GFileobject itself (not the on-disk file), see g_file_dup().- Parameters:
destination- destinationGFileflags- set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignoreprogressCallback- function to callback with progress information, ornullif progress information is not needed- Returns:
trueon success,falseotherwise.- Throws:
GErrorException- seeGError
-
copyAsync
default void copyAsync(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Copies the file this File to the location specified bydestinationasynchronously. For details of the behaviour, see g_file_copy().If
progressCallbackis notnull, then that function that will be called just like in g_file_copy(). The callback will run in the default main context of the thread calling g_file_copy_async() — the same context ascallbackis run in.When the operation is finished,
callbackwill be called. You can then call g_file_copy_finish() to get the result of the operation.- Parameters:
destination- destinationGFileflags- set ofGFileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignoreprogressCallback- function to callback with progress information, ornullif progress information is not neededcallback- aGAsyncReadyCallbackto call when the request is satisfied
-
copyAsync
default void copyAsync(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Copies the file this File to the location specified bydestinationasynchronously. For details of the behaviour, see g_file_copy().If
progressCallbackis notnull, then that function that will be called just like in g_file_copy(). The callback will run in the default main context of the thread calling g_file_copy_async() — the same context ascallbackis run in.When the operation is finished,
callbackwill be called. You can then call g_file_copy_finish() to get the result of the operation.- Parameters:
destination- destinationGFileflags- set ofGFileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignoreprogressCallback- function to callback with progress information, ornullif progress information is not neededcallback- aGAsyncReadyCallbackto call when the request is satisfied
-
copyAsyncWithClosures
default void copyAsyncWithClosures(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofcopyAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.- Parameters:
destination- destinationGio.Fileflags- set ofGio.FileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalCancellableobject,NULLto ignoreprogressCallbackClosure-GObject.Closureto invoke with progress information, orNULLif progress information is not neededreadyCallbackClosure-GObject.Closureto invoke when the request is satisfied- Since:
- 2.82
-
copyAsyncWithClosures
default void copyAsyncWithClosures(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofcopyAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.- Parameters:
destination- destinationGio.Fileflags- set ofGio.FileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalCancellableobject,NULLto ignoreprogressCallbackClosure-GObject.Closureto invoke with progress information, orNULLif progress information is not neededreadyCallbackClosure-GObject.Closureto invoke when the request is satisfied- Since:
- 2.82
-
copyAttributes
default boolean copyAttributes(File destination, Set<FileCopyFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Copies the file attributes from this File todestination.Normally only a subset of the file attributes are copied, those that are copies in a normal file copy operation (which for instance does not include e.g. owner). However if
FileCopyFlags.ALL_METADATAis specified inflags,then all the metadata that is possible to copy is copied. This is useful when implementing move by copy + delete source.- Parameters:
destination- aGFileto copy attributes toflags- a set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif the attributes were copied successfully,falseotherwise.- Throws:
GErrorException- seeGError
-
copyAttributes
default boolean copyAttributes(File destination, FileCopyFlags flags, @Nullable Cancellable cancellable) throws GErrorException Copies the file attributes from this File todestination.Normally only a subset of the file attributes are copied, those that are copies in a normal file copy operation (which for instance does not include e.g. owner). However if
FileCopyFlags.ALL_METADATAis specified inflags,then all the metadata that is possible to copy is copied. This is useful when implementing move by copy + delete source.- Parameters:
destination- aGFileto copy attributes toflags- a set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif the attributes were copied successfully,falseotherwise.- Throws:
GErrorException- seeGError
-
copyFinish
Finishes copying the file started with g_file_copy_async().- Parameters:
res- aGAsyncResult- Returns:
- a
trueon success,falseon error. - Throws:
GErrorException- seeGError
-
create
default FileOutputStream create(Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Creates a new file and returns an output stream for writing to it. The file must not already exist.By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If a file or directory with this name already exists the
IOErrorEnum.EXISTSerror will be returned. Some file systems don't allow all file names, and may return anIOErrorEnum.INVALID_FILENAMEerror, and if the name is to longIOErrorEnum.FILENAME_TOO_LONGwill be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
flags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileOutputStreamfor the newly created file, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
create
default FileOutputStream create(FileCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException Creates a new file and returns an output stream for writing to it. The file must not already exist.By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If a file or directory with this name already exists the
IOErrorEnum.EXISTSerror will be returned. Some file systems don't allow all file names, and may return anIOErrorEnum.INVALID_FILENAMEerror, and if the name is to longIOErrorEnum.FILENAME_TOO_LONGwill be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
flags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileOutputStreamfor the newly created file, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
createAsync
default void createAsync(Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns an output stream for writing to it. The file must not already exist.For more details, see g_file_create() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_create_finish() to get the result of the operation.- Parameters:
flags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
createAsync
default void createAsync(FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns an output stream for writing to it. The file must not already exist.For more details, see g_file_create() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_create_finish() to get the result of the operation.- Parameters:
flags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
createFinish
Finishes an asynchronous file create operation started with g_file_create_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileOutputStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
createReadwrite
default FileIOStream createReadwrite(Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Creates a new file and returns a stream for reading and writing to it. The file must not already exist.By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If a file or directory with this name already exists, the
IOErrorEnum.EXISTSerror will be returned. Some file systems don't allow all file names, and may return anIOErrorEnum.INVALID_FILENAMEerror, and if the name is too long,IOErrorEnum.FILENAME_TOO_LONGwill be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
- Parameters:
flags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileIOStreamfor the newly created file, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.22
-
createReadwrite
default FileIOStream createReadwrite(FileCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException Creates a new file and returns a stream for reading and writing to it. The file must not already exist.By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If a file or directory with this name already exists, the
IOErrorEnum.EXISTSerror will be returned. Some file systems don't allow all file names, and may return anIOErrorEnum.INVALID_FILENAMEerror, and if the name is too long,IOErrorEnum.FILENAME_TOO_LONGwill be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
- Parameters:
flags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileIOStreamfor the newly created file, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.22
-
createReadwriteAsync
default void createReadwriteAsync(Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns a stream for reading and writing to it. The file must not already exist.For more details, see g_file_create_readwrite() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_create_readwrite_finish() to get the result of the operation.- Parameters:
flags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
createReadwriteAsync
default void createReadwriteAsync(FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a new file and returns a stream for reading and writing to it. The file must not already exist.For more details, see g_file_create_readwrite() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_create_readwrite_finish() to get the result of the operation.- Parameters:
flags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
createReadwriteFinish
Finishes an asynchronous file create operation started with g_file_create_readwrite_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileIOStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.22
-
delete
Deletes a file. If the this File is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().If this File doesn’t exist,
IOErrorEnum.NOT_FOUNDwill be returned. This allows for deletion to be implemented avoiding time-of-check to time-of-use races:g_autoptr(GError) local_error = NULL; if (!g_file_delete (my_file, my_cancellable, &local_error) && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) { // deletion failed for some reason other than the file not existing: // so report the error g_warning ("Failed to delete %s: %s", g_file_peek_path (my_file), local_error->message); }If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif the file was deleted.falseotherwise.- Throws:
GErrorException- seeGError
-
deleteAsync
default void deleteAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously delete a file. If the this File is a directory, it will only be deleted if it is empty. This has the same semantics as g_unlink().- Parameters:
ioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.34
-
deleteFinish
Finishes deleting a file started with g_file_delete_async().- Parameters:
result- aGAsyncResult- Returns:
trueif the file was deleted.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.34
-
dup
Duplicates aGFilehandle. This operation does not duplicate the actual file or directory represented by theGFile; see g_file_copy() if attempting to copy a file.g_file_dup() is useful when a second handle is needed to the same underlying file, for use in a separate thread (
GFileis not thread-safe). For use within the same thread, use g_object_ref() to increment the existing object’s reference count.This call does no blocking I/O.
- Returns:
- a new
GFilethat is a duplicate of the givenGFile.
-
ejectMountable
@Deprecated default void ejectMountable(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_eject_mountable_with_operation() instead.Starts an asynchronous eject on a mountable. When this operation has completed,callbackwill be called withuserUserdata, and the operation can be finalized with g_file_eject_mountable_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- flags affecting the operationcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
ejectMountable
@Deprecated default void ejectMountable(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_eject_mountable_with_operation() instead.Starts an asynchronous eject on a mountable. When this operation has completed,callbackwill be called withuserUserdata, and the operation can be finalized with g_file_eject_mountable_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- flags affecting the operationcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
ejectMountableFinish
Deprecated.Use g_file_eject_mountable_with_operation_finish() instead.Finishes an asynchronous eject operation started by g_file_eject_mountable().- Parameters:
result- aGAsyncResult- Returns:
trueif the this File was ejected successfully.falseotherwise.- Throws:
GErrorException- seeGError
-
ejectMountableWithOperation
default void ejectMountableWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous eject on a mountable. When this operation has completed,callbackwill be called withuserUserdata, and the operation can be finalized with g_file_eject_mountable_with_operation_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
ejectMountableWithOperation
default void ejectMountableWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous eject on a mountable. When this operation has completed,callbackwill be called withuserUserdata, and the operation can be finalized with g_file_eject_mountable_with_operation_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
ejectMountableWithOperationFinish
Finishes an asynchronous eject operation started by g_file_eject_mountable_with_operation().- Parameters:
result- aGAsyncResult- Returns:
trueif the this File was ejected successfully.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.22
-
enumerateChildren
default FileEnumerator enumerateChildren(String attributes, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Gets the requested information about the files in a directory. The result is aGFileEnumeratorobject that will give outGFileInfoobjects for all the files in the directory.The
attributesvalue is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set.attributesshould be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are available as defines, likeG_FILE_ATTRIBUTE_STANDARD_NAME.G_FILE_ATTRIBUTE_STANDARD_NAMEshould always be specified if you plan to call g_file_enumerator_get_child() or g_file_enumerator_iterate() on the returned enumerator.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If the file does not exist, the
IOErrorEnum.NOT_FOUNDerror will be returned. If the file is not a directory, theIOErrorEnum.NOT_DIRECTORYerror will be returned. Other errors are possible too.- Parameters:
attributes- an attribute query stringflags- a set ofGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- A
GFileEnumeratorif successful,nullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
enumerateChildren
default FileEnumerator enumerateChildren(String attributes, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Gets the requested information about the files in a directory. The result is aGFileEnumeratorobject that will give outGFileInfoobjects for all the files in the directory.The
attributesvalue is a string that specifies the file attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set.attributesshould be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "standard::*" means all attributes in the standard namespace. An example attribute query be "standard::*,owner::user". The standard attributes are available as defines, likeG_FILE_ATTRIBUTE_STANDARD_NAME.G_FILE_ATTRIBUTE_STANDARD_NAMEshould always be specified if you plan to call g_file_enumerator_get_child() or g_file_enumerator_iterate() on the returned enumerator.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If the file does not exist, the
IOErrorEnum.NOT_FOUNDerror will be returned. If the file is not a directory, theIOErrorEnum.NOT_DIRECTORYerror will be returned. Other errors are possible too.- Parameters:
attributes- an attribute query stringflags- a set ofGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- A
GFileEnumeratorif successful,nullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
enumerateChildrenAsync
default void enumerateChildrenAsync(String attributes, Set<FileQueryInfoFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about the files in a directory. The result is aGFileEnumeratorobject that will give outGFileInfoobjects for all the files in the directory.For more details, see g_file_enumerate_children() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_enumerate_children_finish() to get the result of the operation.- Parameters:
attributes- an attribute query stringflags- a set ofGFileQueryInfoFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
enumerateChildrenAsync
default void enumerateChildrenAsync(String attributes, FileQueryInfoFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about the files in a directory. The result is aGFileEnumeratorobject that will give outGFileInfoobjects for all the files in the directory.For more details, see g_file_enumerate_children() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_enumerate_children_finish() to get the result of the operation.- Parameters:
attributes- an attribute query stringflags- a set ofGFileQueryInfoFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
enumerateChildrenFinish
Finishes an async enumerate children operation. See g_file_enumerate_children_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileEnumeratorornullif an error occurred. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
equal
Checks if the two givenGFilesrefer to the same file.Note that two
GFilesthat differ can still refer to the same file on the filesystem due to various forms of filename aliasing.This call does no blocking I/O.
- Parameters:
file2- the secondGFile- Returns:
trueif this File andfile2are equal.
-
findEnclosingMount
Gets aGMountfor theGFile.GMountis returned only for user interesting locations, seeGVolumeMonitor. If theGFileIfacefor this File does not have amount,errorwill be set toIOErrorEnum.NOT_FOUNDandnullwillbe returned.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GMountwhere the this File is located ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
findEnclosingMountAsync
default void findEnclosingMountAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the mount for the file.For more details, see g_file_find_enclosing_mount() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_find_enclosing_mount_finish() to get the result of the operation.- Parameters:
ioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
findEnclosingMountFinish
Finishes an asynchronous find mount request. See g_file_find_enclosing_mount_async().- Parameters:
res- aGAsyncResult- Returns:
GMountfor given this File ornullon error. Free the returned object with g_object_unref().- Throws:
GErrorException- seeGError
-
getBasename
Gets the base name (the last component of the path) for a givenGFile.If called for the top level of a system (such as the filesystem root or a uri like sftp://host/) it will return a single directory separator (and on Windows, possibly a drive letter).
The base name is a byte string (not UTF-8). It has no defined encoding or rules other than it may not contain zero bytes. If you want to use filenames in a user interface you should use the display name that you can get by requesting the
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAMEattribute with g_file_query_info().This call does no blocking I/O.
- Returns:
- string containing the
GFile's base name, ornullif givenGFileis invalid. The returned string should be freed with g_free() when no longer needed.
-
getChild
Gets a child of this File with basename equal toname.Note that the file with that specific name might not exist, but you can still have a
GFilethat points to it. You can use this for instance to create that file.This call does no blocking I/O.
- Parameters:
name- string containing the child's basename- Returns:
- a
GFileto a child specified byname.Free the returned object with g_object_unref().
-
getChildForDisplayName
Gets the child of this File for a givendisplayName(i.e. a UTF-8 version of the name). If this function fails, it returnsnullanderrorwill be set. This is very useful when constructing aGFilefor a new file and the user entered the filename in the user interface, for instance when you select a directory and type a filename in the file selector.This call does no blocking I/O.
- Parameters:
displayName- string to a possible child- Returns:
- a
GFileto the specified child, ornullif the display name couldn't be converted. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
getParent
Gets the parent directory for thefile.If the this File represents the root directory of the file system, thennullwill be returned.This call does no blocking I/O.
- Returns:
- a
GFilestructure to the parent of the givenGFileornullif there is no parent. Free the returned object with g_object_unref().
-
getParseName
Gets the parse name of thefile.A parse name is a UTF-8 string that describes the file such that one can get theGFileback using g_file_parse_name().This is generally used to show the
GFileas a nice full-pathname kind of string in a user interface, like in a location entry.For local files with names that can safely be converted to UTF-8 the pathname is used, otherwise the IRI is used (a form of URI that allows UTF-8 characters unescaped).
This call does no blocking I/O.
- Returns:
- a string containing the
GFile's parse name. The returned string should be freed with g_free() when no longer needed.
-
getPath
Gets the local pathname forGFile, if one exists. If non-null, this is guaranteed to be an absolute, canonical path. It might contain symlinks.This call does no blocking I/O.
- Returns:
- string containing the
GFile's path, ornullif no such path exists. The returned string should be freed with g_free() when no longer needed.
-
getRelativePath
Gets the path fordescendantrelative toparent.This call does no blocking I/O.
- Parameters:
descendant- inputGFile- Returns:
- string with the relative path from
descendanttoparent,ornullifdescendantdoesn't have this File as prefix. The returned string should be freed with g_free() when no longer needed.
-
getUri
Gets the URI for thefile.This call does no blocking I/O.
- Returns:
- a string containing the
GFile's URI. If theGFilewas constructed with an invalid URI, an invalid URI is returned. The returned string should be freed with g_free() when no longer needed.
-
getUriScheme
Gets the URI scheme for aGFile. RFC 3986 decodes the scheme as:
Common schemes include "file", "http", "ftp", etc.URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]The scheme can be different from the one used to construct the
GFile, in that it might be replaced with one that is logically equivalent to theGFile.This call does no blocking I/O.
- Returns:
- a string containing the URI scheme for the given
GFileornullif theGFilewas constructed with an invalid URI. The returned string should be freed with g_free() when no longer needed.
-
hasParent
Checks if this File has a parent, and optionally, if it isparent.If
parentisnullthen this function returnstrueif this File has any parent at all. Ifparentis non-nullthentrueis only returned if this File is an immediate child ofparent.- Parameters:
parent- the parent to check for, ornull- Returns:
trueif this File is an immediate child ofparent(or any parent in the case thatparentisnull).- Since:
- 2.24
-
hasPrefix
Checks whether this File has the prefix specified byprefix.In other words, if the names of initial elements of
file'spathname matchprefix.Only full pathname elements are matched, so a path like /foo is not considered a prefix of /foobar, only of /foo/bar.A
GFileis not a prefix of itself. If you want to check for equality, use g_file_equal().This call does no I/O, as it works purely on names. As such it can sometimes return
falseeven if this File is inside aprefix(from a filesystem point of view), because the prefix of this File is an alias ofprefix.- Parameters:
prefix- inputGFile- Returns:
trueif thefile'sparent, grandparent, etc isprefix,falseotherwise.
-
hasUriScheme
Checks to see if aGFilehas a given URI scheme.This call does no blocking I/O.
- Parameters:
uriScheme- a string containing a URI scheme- Returns:
trueifGFile's backend supports the given URI scheme,falseif URI scheme isnull, not supported, orGFileis invalid.
-
hash
default int hash()Creates a hash value for aGFile.This call does no blocking I/O.
- Returns:
- 0 if this File is not a valid
GFile, otherwise an integer that can be used as hash value for theGFile. This function is intended for easily hashing aGFileto add to aGHashTableor similar data structure.
-
isNative
default boolean isNative()Checks to see if a file is native to the platform.A native file is one expressed in the platform-native filename format, e.g. "C:\\Windows" or "/usr/bin/". This does not mean the file is local, as it might be on a locally mounted remote filesystem.
On some systems non-native files may be available using the native filesystem via a userspace filesystem (FUSE), in these cases this call will return
false, but g_file_get_path() will still return a native path.This call does no blocking I/O.
- Returns:
trueif this File is native
-
loadBytes
default byte[] loadBytes(@Nullable Cancellable cancellable, @Nullable Out<String> etagOut) throws GErrorException Loads the contents of this File and returns it asGBytes.If this File is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling g_file_load_contents() and g_bytes_new_take().
For resources,
etagOutwill be set tonull.The data contained in the resulting
GBytesis always zero-terminated, but this is not included in theGByteslength. The resultingGBytesshould be freed with g_bytes_unref() when no longer in use.- Parameters:
cancellable- aGCancellableornulletagOut- a location to place the current entity tag for the file, ornullif the entity tag is not needed- Returns:
- a
GBytesornullanderroris set - Throws:
GErrorException- seeGError- Since:
- 2.56
-
loadBytesAsync
default void loadBytesAsync(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously loads the contents of this File asGBytes.If this File is a resource:// based URI, the resulting bytes will reference the embedded resource instead of a copy. Otherwise, this is equivalent to calling g_file_load_contents_async() and g_bytes_new_take().
callbackshould call g_file_load_bytes_finish() to get the result of this asynchronous operation.See g_file_load_bytes() for more information.
- Parameters:
cancellable- aGCancellableornullcallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.56
-
loadBytesFinish
default byte[] loadBytesFinish(AsyncResult result, @Nullable Out<String> etagOut) throws GErrorException Completes an asynchronous request to g_file_load_bytes_async().For resources,
etagOutwill be set tonull.The data contained in the resulting
GBytesis always zero-terminated, but this is not included in theGByteslength. The resultingGBytesshould be freed with g_bytes_unref() when no longer in use.See g_file_load_bytes() for more information.
- Parameters:
result- aGAsyncResultprovided to the callbacketagOut- a location to place the current entity tag for the file, ornullif the entity tag is not needed- Returns:
- a
GBytesornullanderroris set - Throws:
GErrorException- seeGError- Since:
- 2.56
-
loadContents
default boolean loadContents(@Nullable Cancellable cancellable, @Nullable Out<byte[]> contents, @Nullable Out<String> etagOut) throws GErrorException Loads the content of the file into memory. The data is always zero-terminated, but this is not included in the resultantlength.The returnedcontentsshould be freed with g_free() when no longer needed.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignorecontents- a location to place the contents of the fileetagOut- a location to place the current entity tag for the file, ornullif the entity tag is not needed- Returns:
trueif thefile'scontents were successfully loaded.falseif there were errors.- Throws:
GErrorException- seeGError
-
loadContentsAsync
default void loadContentsAsync(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous load of thefile'scontents.For more details, see g_file_load_contents() which is the synchronous version of this call.
When the load operation has completed,
callbackwill be called withuserdata. To finish the operation, call g_file_load_contents_finish() with theGAsyncResultreturned by thecallback.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
loadContentsFinish
default boolean loadContentsFinish(AsyncResult res, @Nullable Out<byte[]> contents, @Nullable Out<String> etagOut) throws GErrorException Finishes an asynchronous load of thefile'scontents. The contents are placed incontents,andlengthis set to the size of thecontentsstring. Thecontentsshould be freed with g_free() when no longer needed. IfetagOutis present, it will be set to the new entity tag for thefile.- Parameters:
res- aGAsyncResultcontents- a location to place the contents of the fileetagOut- a location to place the current entity tag for the file, ornullif the entity tag is not needed- Returns:
trueif the load was successful. Iffalseanderroris present, it will be set appropriately.- Throws:
GErrorException- seeGError
-
loadPartialContentsAsync
default void loadPartialContentsAsync(@Nullable Cancellable cancellable, @Nullable FileReadMoreCallback readMoreCallback, @Nullable AsyncReadyCallback callback) Reads the partial contents of a file. AGFileReadMoreCallbackshould be used to stop reading from the file when appropriate, else this function will behave exactly as g_file_load_contents_async(). This operation can be finished by g_file_load_partial_contents_finish().Users of this function should be aware that
userDatais passed to both thereadMoreCallbackand thecallback.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignorereadMoreCallback- aGFileReadMoreCallbackto receive partial data and to specify whether further data should be readcallback- aGAsyncReadyCallbackto call when the request is satisfied
-
loadPartialContentsFinish
default boolean loadPartialContentsFinish(AsyncResult res, @Nullable Out<byte[]> contents, @Nullable Out<String> etagOut) throws GErrorException Finishes an asynchronous partial load operation that was started with g_file_load_partial_contents_async(). The data is always zero-terminated, but this is not included in the resultantlength.The returnedcontentsshould be freed with g_free() when no longer needed.- Parameters:
res- aGAsyncResultcontents- a location to place the contents of the fileetagOut- a location to place the current entity tag for the file, ornullif the entity tag is not needed- Returns:
trueif the load was successful. Iffalseanderroris present, it will be set appropriately.- Throws:
GErrorException- seeGError
-
makeDirectory
Creates a directory.Note that this will only create a child directory of the immediate parent directory of the path or URI given by the
GFile. To recursively create directories, see g_file_make_directory_with_parents().This function will fail if the parent directory does not exist, setting
errortoIOErrorEnum.NOT_FOUND. If the file system doesn't support creating directories, this function will fail, settingerrortoIOErrorEnum.NOT_SUPPORTED. If the directory already exists,Gio.IOErrorEnum.EXISTSwill be returned.For a local
GFilethe newly created directory will have the default (current) ownership and permissions of the current process.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
trueon successful creation,falseotherwise.- Throws:
GErrorException- seeGError
-
makeDirectoryAsync
default void makeDirectoryAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a directory.- Parameters:
ioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.38
-
makeDirectoryFinish
Finishes an asynchronous directory creation, started with g_file_make_directory_async().- Parameters:
result- aGAsyncResult- Returns:
trueon successful directory creation,falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.38
-
makeDirectoryWithParents
Creates a directory and any parent directories that may not exist similar to 'mkdir -p'. If the file system does not support creating directories, this function will fail, settingerrortoIOErrorEnum.NOT_SUPPORTED. If the directory itself already exists, this function will fail settingerrortoIOErrorEnum.EXISTS, unlike the similar g_mkdir_with_parents().For a local
GFilethe newly created directories will have the default (current) ownership and permissions of the current process.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif all directories have been successfully created,falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.18
-
makeSymbolicLink
default boolean makeSymbolicLink(String symlinkValue, @Nullable Cancellable cancellable) throws GErrorException Creates a symbolic link named this File which contains the stringsymlinkValue.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
symlinkValue- a string with the path for the target of the new symlinkcancellable- optionalGCancellableobject,nullto ignore- Returns:
trueon the creation of a new symlink,falseotherwise.- Throws:
GErrorException- seeGError
-
makeSymbolicLinkAsync
default void makeSymbolicLinkAsync(String symlinkValue, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously creates a symbolic link named this File which contains the stringsymlinkValue.- Parameters:
symlinkValue- a string with the path for the target of the new symlinkioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.74
-
makeSymbolicLinkFinish
Finishes an asynchronous symbolic link creation, started with g_file_make_symbolic_link_async().- Parameters:
result- aGAsyncResult- Returns:
trueon successful directory creation,falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.74
-
measureDiskUsage
default boolean measureDiskUsage(Set<FileMeasureFlags> flags, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable Out<Long> diskUsage, @Nullable Out<Long> numDirs, @Nullable Out<Long> numFiles) throws GErrorException Recursively measures the disk usage offile.This is essentially an analog of the 'du' command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links).
By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless
FileMeasureFlags.REPORT_ANY_ERRORis given inflags.The returned size,
diskUsage,is in bytes and should be formatted with g_format_size() in order to get something reasonable for showing in a user interface.progressCallbackandprogressDatacan be given to request periodic progress updates while scanning. See the documentation forGFileMeasureProgressCallbackfor information about when and how the callback will be invoked.- Parameters:
flags-GFileMeasureFlagscancellable- optionalGCancellableprogressCallback- aGFileMeasureProgressCallbackdiskUsage- the number of bytes of disk space usednumDirs- the number of directories encounterednumFiles- the number of non-directories encountered- Returns:
trueif successful, with the out parameters set.falseotherwise, witherrorset.- Throws:
GErrorException- seeGError- Since:
- 2.38
-
measureDiskUsage
default boolean measureDiskUsage(FileMeasureFlags flags, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable Out<Long> diskUsage, @Nullable Out<Long> numDirs, @Nullable Out<Long> numFiles) throws GErrorException Recursively measures the disk usage offile.This is essentially an analog of the 'du' command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links).
By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless
FileMeasureFlags.REPORT_ANY_ERRORis given inflags.The returned size,
diskUsage,is in bytes and should be formatted with g_format_size() in order to get something reasonable for showing in a user interface.progressCallbackandprogressDatacan be given to request periodic progress updates while scanning. See the documentation forGFileMeasureProgressCallbackfor information about when and how the callback will be invoked.- Parameters:
flags-GFileMeasureFlagscancellable- optionalGCancellableprogressCallback- aGFileMeasureProgressCallbackdiskUsage- the number of bytes of disk space usednumDirs- the number of directories encounterednumFiles- the number of non-directories encountered- Returns:
trueif successful, with the out parameters set.falseotherwise, witherrorset.- Throws:
GErrorException- seeGError- Since:
- 2.38
-
measureDiskUsageAsync
default void measureDiskUsageAsync(Set<FileMeasureFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Recursively measures the disk usage offile.This is the asynchronous version of g_file_measure_disk_usage(). See there for more information.
- Parameters:
flags-GFileMeasureFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableprogressCallback- aGFileMeasureProgressCallbackcallback- aGAsyncReadyCallbackto call when complete- Since:
- 2.38
-
measureDiskUsageAsync
default void measureDiskUsageAsync(FileMeasureFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileMeasureProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Recursively measures the disk usage offile.This is the asynchronous version of g_file_measure_disk_usage(). See there for more information.
- Parameters:
flags-GFileMeasureFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableprogressCallback- aGFileMeasureProgressCallbackcallback- aGAsyncReadyCallbackto call when complete- Since:
- 2.38
-
measureDiskUsageFinish
default boolean measureDiskUsageFinish(AsyncResult result, @Nullable Out<Long> diskUsage, @Nullable Out<Long> numDirs, @Nullable Out<Long> numFiles) throws GErrorException Collects the results from an earlier call to g_file_measure_disk_usage_async(). See g_file_measure_disk_usage() for more information.- Parameters:
result- theGAsyncResultpassed to yourGAsyncReadyCallbackdiskUsage- the number of bytes of disk space usednumDirs- the number of directories encounterednumFiles- the number of non-directories encountered- Returns:
trueif successful, with the out parameters set.falseotherwise, witherrorset.- Throws:
GErrorException- seeGError- Since:
- 2.38
-
monitor
default FileMonitor monitor(Set<FileMonitorFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Obtains a file or directory monitor for the given file, depending on the type of the file.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- a set ofGFileMonitorFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileMonitorfor the givenfile,ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.18
-
monitor
default FileMonitor monitor(FileMonitorFlags flags, @Nullable Cancellable cancellable) throws GErrorException Obtains a file or directory monitor for the given file, depending on the type of the file.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- a set ofGFileMonitorFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileMonitorfor the givenfile,ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.18
-
monitorDirectory
default FileMonitor monitorDirectory(Set<FileMonitorFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.It does not make sense for
flagsto containFileMonitorFlags.WATCH_HARD_LINKS, since hard links can not be made to directories. It is not possible to monitor all the files in a directory for changes made via hard links; if you want to do this then you must register individual watches with g_file_monitor().- Parameters:
flags- a set ofGFileMonitorFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileMonitorfor the givenfile,ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
monitorDirectory
default FileMonitor monitorDirectory(FileMonitorFlags flags, @Nullable Cancellable cancellable) throws GErrorException Obtains a directory monitor for the given file. This may fail if directory monitoring is not supported.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.It does not make sense for
flagsto containFileMonitorFlags.WATCH_HARD_LINKS, since hard links can not be made to directories. It is not possible to monitor all the files in a directory for changes made via hard links; if you want to do this then you must register individual watches with g_file_monitor().- Parameters:
flags- a set ofGFileMonitorFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileMonitorfor the givenfile,ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
monitorFile
default FileMonitor monitorFile(Set<FileMonitorFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Obtains a file monitor for the given file. If no file notification mechanism exists, then regular polling of the file is used.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
flagscontainsFileMonitorFlags.WATCH_HARD_LINKSthen the monitor will also attempt to report changes made to the file via another filename (ie, a hard link). Without this flag, you can only rely on changes made through the filename contained in this File to be reported. Using this flag may result in an increase in resource usage, and may not have any effect depending on theGFileMonitorbackend and/or filesystem type.- Parameters:
flags- a set ofGFileMonitorFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileMonitorfor the givenfile,ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
monitorFile
default FileMonitor monitorFile(FileMonitorFlags flags, @Nullable Cancellable cancellable) throws GErrorException Obtains a file monitor for the given file. If no file notification mechanism exists, then regular polling of the file is used.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
flagscontainsFileMonitorFlags.WATCH_HARD_LINKSthen the monitor will also attempt to report changes made to the file via another filename (ie, a hard link). Without this flag, you can only rely on changes made through the filename contained in this File to be reported. Using this flag may result in an increase in resource usage, and may not have any effect depending on theGFileMonitorbackend and/or filesystem type.- Parameters:
flags- a set ofGFileMonitorFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileMonitorfor the givenfile,ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
mountEnclosingVolume
default void mountEnclosingVolume(Set<MountMountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts amountOperation,mounting the volume that contains the filelocation.When this operation has completed,
callbackwill be called withuserUserdata, and the operation can be finalized with g_file_mount_enclosing_volume_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperationornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied, ornull
-
mountEnclosingVolume
default void mountEnclosingVolume(MountMountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts amountOperation,mounting the volume that contains the filelocation.When this operation has completed,
callbackwill be called withuserUserdata, and the operation can be finalized with g_file_mount_enclosing_volume_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperationornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied, ornull
-
mountEnclosingVolumeFinish
Finishes a mount operation started by g_file_mount_enclosing_volume().- Parameters:
result- aGAsyncResult- Returns:
trueif successful. If an error has occurred, this function will returnfalseand seterrorappropriately if present.- Throws:
GErrorException- seeGError
-
mountMountable
default void mountMountable(Set<MountMountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Mounts a file of type G_FILE_TYPE_MOUNTABLE. UsingmountOperation,you can request callbacks when, for instance, passwords are needed during authentication.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
mountMountable
default void mountMountable(MountMountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Mounts a file of type G_FILE_TYPE_MOUNTABLE. UsingmountOperation,you can request callbacks when, for instance, passwords are needed during authentication.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
mountMountableFinish
Finishes a mount operation. See g_file_mount_mountable() for details.Finish an asynchronous mount operation that was started with g_file_mount_mountable().
- Parameters:
result- aGAsyncResult- Returns:
- a
GFileornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
move
default boolean move(File destination, Set<FileCopyFlags> flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) throws GErrorException Tries to move the file or directory this File to the location specified bydestination.If native move operations are supported then this is used, otherwise a copy + delete fallback is used. The native implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not.If the flag
FileCopyFlags.OVERWRITEis specified an already existingdestinationfile is overwritten.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
progressCallbackis notnull, then the operation can be monitored by setting this to aGFileProgressCallbackfunction.progressCallbackDatawill be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.If the this File file does not exist, then the
IOErrorEnum.NOT_FOUNDerror is returned, independent on the status of thedestination.If
FileCopyFlags.OVERWRITEis not specified and the target exists, then the errorIOErrorEnum.EXISTSis returned.If trying to overwrite a file over a directory, the
IOErrorEnum.IS_DIRECTORYerror is returned. If trying to overwrite a directory with a directory theIOErrorEnum.WOULD_MERGEerror is returned.If the source is a directory and the target does not exist, or
FileCopyFlags.OVERWRITEis specified and the target is a file, then theIOErrorEnum.WOULD_RECURSEerror may be returned (if the native move operation isn't available).- Parameters:
destination-GFilepointing to the destination locationflags- set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignoreprogressCallback-GFileProgressCallbackfunction for updates- Returns:
trueon successful move,falseotherwise.- Throws:
GErrorException- seeGError
-
move
default boolean move(File destination, FileCopyFlags flags, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback) throws GErrorException Tries to move the file or directory this File to the location specified bydestination.If native move operations are supported then this is used, otherwise a copy + delete fallback is used. The native implementation may support moving directories (for instance on moves inside the same filesystem), but the fallback code does not.If the flag
FileCopyFlags.OVERWRITEis specified an already existingdestinationfile is overwritten.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
progressCallbackis notnull, then the operation can be monitored by setting this to aGFileProgressCallbackfunction.progressCallbackDatawill be passed to this function. It is guaranteed that this callback will be called after all data has been transferred with the total number of bytes copied during the operation.If the this File file does not exist, then the
IOErrorEnum.NOT_FOUNDerror is returned, independent on the status of thedestination.If
FileCopyFlags.OVERWRITEis not specified and the target exists, then the errorIOErrorEnum.EXISTSis returned.If trying to overwrite a file over a directory, the
IOErrorEnum.IS_DIRECTORYerror is returned. If trying to overwrite a directory with a directory theIOErrorEnum.WOULD_MERGEerror is returned.If the source is a directory and the target does not exist, or
FileCopyFlags.OVERWRITEis specified and the target is a file, then theIOErrorEnum.WOULD_RECURSEerror may be returned (if the native move operation isn't available).- Parameters:
destination-GFilepointing to the destination locationflags- set ofGFileCopyFlagscancellable- optionalGCancellableobject,nullto ignoreprogressCallback-GFileProgressCallbackfunction for updates- Returns:
trueon successful move,falseotherwise.- Throws:
GErrorException- seeGError
-
moveAsync
default void moveAsync(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Asynchronously moves a file this File to the location ofdestination.For details of the behaviour, see g_file_move().If
progressCallbackis notnull, then that function that will be called just like in g_file_move(). The callback will run in the default main context of the thread calling g_file_move_async() — the same context ascallbackis run in.When the operation is finished,
callbackwill be called. You can then call g_file_move_finish() to get the result of the operation.- Parameters:
destination-GFilepointing to the destination locationflags- set ofGFileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignoreprogressCallback-GFileProgressCallbackfunction for updatescallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.72
-
moveAsync
default void moveAsync(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable FileProgressCallback progressCallback, @Nullable AsyncReadyCallback callback) Asynchronously moves a file this File to the location ofdestination.For details of the behaviour, see g_file_move().If
progressCallbackis notnull, then that function that will be called just like in g_file_move(). The callback will run in the default main context of the thread calling g_file_move_async() — the same context ascallbackis run in.When the operation is finished,
callbackwill be called. You can then call g_file_move_finish() to get the result of the operation.- Parameters:
destination-GFilepointing to the destination locationflags- set ofGFileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignoreprogressCallback-GFileProgressCallbackfunction for updatescallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.72
-
moveAsyncWithClosures
default void moveAsyncWithClosures(File destination, Set<FileCopyFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofmoveAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.- Parameters:
destination- destinationGio.Fileflags- set ofGio.FileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalCancellableobject,NULLto ignoreprogressCallbackClosure-GObject.Closureto invoke with progress information, orNULLif progress information is not neededreadyCallbackClosure-GObject.Closureto invoke when the request is satisfied- Since:
- 2.82
-
moveAsyncWithClosures
default void moveAsyncWithClosures(File destination, FileCopyFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable Closure progressCallbackClosure, Closure readyCallbackClosure) Version ofmoveAsync(org.gnome.gio.File, java.util.Set<org.gnome.gio.FileCopyFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.FileProgressCallback, org.gnome.gio.AsyncReadyCallback)using closures instead of callbacks for easier binding in other languages.- Parameters:
destination- destinationGio.Fileflags- set ofGio.FileCopyFlagsioPriority- the I/O priority of the requestcancellable- optionalCancellableobject,NULLto ignoreprogressCallbackClosure-GObject.Closureto invoke with progress information, orNULLif progress information is not neededreadyCallbackClosure-GObject.Closureto invoke when the request is satisfied- Since:
- 2.82
-
moveFinish
Finishes an asynchronous file movement, started with g_file_move_async().- Parameters:
result- aGAsyncResult- Returns:
trueon successful file move,falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.72
-
openReadwrite
Opens an existing file for reading and writing. The result is aGFileIOStreamthat can be used to read and write the contents of the file.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If the file does not exist, the
IOErrorEnum.NOT_FOUNDerror will be returned. If the file is a directory, theIOErrorEnum.IS_DIRECTORYerror will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on. Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.- Parameters:
cancellable- aGCancellable- Returns:
GFileIOStreamornullon error. Free the returned object with g_object_unref().- Throws:
GErrorException- seeGError- Since:
- 2.22
-
openReadwriteAsync
default void openReadwriteAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for reading and writing.For more details, see g_file_open_readwrite() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_open_readwrite_finish() to get the result of the operation.- Parameters:
ioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
openReadwriteFinish
Finishes an asynchronous file read operation started with g_file_open_readwrite_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileIOStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.22
-
peekPath
Exactly like g_file_get_path(), but caches the result via g_object_set_qdata_full(). This is useful for example in C applications which mixg_file_*APIs with native ones. It also avoids an extra duplicated string when possible, so will be generally more efficient.This call does no blocking I/O.
- Returns:
- string containing the
GFile's path, ornullif no such path exists. The returned string is owned byfile. - Since:
- 2.56
-
pollMountable
default void pollMountable(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Polls a file of typeFileType.MOUNTABLE.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.- Parameters:
cancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied, ornull- Since:
- 2.22
-
pollMountableFinish
Finishes a poll operation. See g_file_poll_mountable() for details.Finish an asynchronous poll operation that was polled with g_file_poll_mountable().
- Parameters:
result- aGAsyncResult- Returns:
trueif the operation finished successfully.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.22
-
queryDefaultHandler
Returns theGAppInfothat is registered as the default application to handle the file specified byfile.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GAppInfoif the handle was found,nullif there were errors. When you are done with it, release it with g_object_unref() - Throws:
GErrorException- seeGError
-
queryDefaultHandlerAsync
default void queryDefaultHandlerAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Async version of g_file_query_default_handler().- Parameters:
ioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is done- Since:
- 2.60
-
queryDefaultHandlerFinish
Finishes a g_file_query_default_handler_async() operation.- Parameters:
result- aGAsyncResult- Returns:
- a
GAppInfoif the handle was found,nullif there were errors. When you are done with it, release it with g_object_unref() - Throws:
GErrorException- seeGError- Since:
- 2.60
-
queryExists
Utility function to check if a particular file exists.The fallback implementation of this API is using
queryInfo(java.lang.String, java.util.Set<org.gnome.gio.FileQueryInfoFlags>, org.gnome.gio.Cancellable)and therefore may do blocking I/O. To asynchronously query the existence of a file, usequeryInfoAsync(java.lang.String, java.util.Set<org.gnome.gio.FileQueryInfoFlags>, int, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).Note that in many cases it is racy to first check for file existence and then execute something based on the outcome of that, because the file might have been created or removed in between the operations. The general approach to handling that is to not check, but just do the operation and handle the errors as they come.
As an example of race-free checking, take the case of reading a file, and if it doesn't exist, creating it. There are two racy versions: read it, and on error create it; and: check if it exists, if not create it. These can both result in two processes creating the file (with perhaps a partially written file as the result). The correct approach is to always try to create the file with g_file_create() which will either atomically create the file or fail with a
IOErrorEnum.EXISTSerror.However, in many cases an existence check is useful in a user interface, for instance to make a menu item sensitive/insensitive, so that you don't have to fool users that something is possible and then just show an error dialog. If you do this, you should make sure to also handle the errors that can happen due to races when you execute the operation.
- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif the file exists (and can be detected without error),falseotherwise (or if cancelled).
-
queryFileType
Utility function to inspect theGFileTypeof a file. This is implemented using g_file_query_info() and as such does blocking I/O.The primary use case of this method is to check if a file is a regular file, directory, or symlink.
- Parameters:
flags- a set ofGFileQueryInfoFlagspassed to g_file_query_info()cancellable- optionalGCancellableobject,nullto ignore- Returns:
- The
GFileTypeof the file andFileType.UNKNOWNif the file does not exist - Since:
- 2.18
-
queryFileType
Utility function to inspect theGFileTypeof a file. This is implemented using g_file_query_info() and as such does blocking I/O.The primary use case of this method is to check if a file is a regular file, directory, or symlink.
- Parameters:
flags- a set ofGFileQueryInfoFlagspassed to g_file_query_info()cancellable- optionalGCancellableobject,nullto ignore- Returns:
- The
GFileTypeof the file andFileType.UNKNOWNif the file does not exist - Since:
- 2.18
-
queryFilesystemInfo
default FileInfo queryFilesystemInfo(String attributes, @Nullable Cancellable cancellable) throws GErrorException Similar to g_file_query_info(), but obtains information about the filesystem the this File is on, rather than the file itself. For instance the amount of space available and the type of the filesystem.The
attributesvalue is a string that specifies the attributes that should be gathered. It is not an error if it's not possible to read a particular requested attribute from a file - it just won't be set.attributesshould be a comma-separated list of attributes or attribute wildcards. The wildcard "*" means all attributes, and a wildcard like "filesystem::*" means all attributes in the filesystem namespace. The standard namespace for filesystem attributes is "filesystem". Common attributes of interest areG_FILE_ATTRIBUTE_FILESYSTEM_SIZE(the total size of the filesystem in bytes),G_FILE_ATTRIBUTE_FILESYSTEM_FREE(number of bytes available), andG_FILE_ATTRIBUTE_FILESYSTEM_TYPE(type of the filesystem).If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If the file does not exist, the
IOErrorEnum.NOT_FOUNDerror will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
attributes- an attribute query stringcancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileInfoornullif there was an error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
queryFilesystemInfoAsync
default void queryFilesystemInfoAsync(String attributes, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about the filesystem that the specified this File is on. The result is aGFileInfoobject that contains key-value attributes (such as type or size for the file).For more details, see g_file_query_filesystem_info() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_query_info_finish() to get the result of the operation.- Parameters:
attributes- an attribute query stringioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
queryFilesystemInfoFinish
Finishes an asynchronous filesystem info query. See g_file_query_filesystem_info_async().- Parameters:
res- aGAsyncResult- Returns:
GFileInfofor given this File ornullon error. Free the returned object with g_object_unref().- Throws:
GErrorException- seeGError
-
queryInfo
default FileInfo queryInfo(String attributes, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Gets the requested information about specifiedfile.The result is a
FileInfoobject that contains key-value attributes (such as the type or size of the file).The
attributesvalue is a string that specifies the file attributes that should be gathered. It is not an error if it’s not possible to read a particular requested attribute from a file — it just won't be set. In particular this means that if a file is inaccessible (due to being in a folder with restrictive permissions), for example, you can expect the returnedFileInfoto have very few attributes set. You should check whether an attribute is set usingFileInfo.hasAttribute(java.lang.String)before trying to retrieve its value.It is guaranteed that if any of the following attributes are listed in
attributes,they will always be set in the returnedFileInfo, even if the user doesn’t have permissions to access the file:Gio.FILE_ATTRIBUTE_STANDARD_NAMEGio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
attributesshould be a comma-separated list of attributes or attribute wildcards. The wildcard"*"means all attributes, and a wildcard like"standard::*"means all attributes in the standard namespace. An example attribute query might be"standard::*,owner::user". The standard attributes are available as defines, likeGio.FILE_ATTRIBUTE_STANDARD_NAME.If
cancellableis notNULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorGio.IOErrorEnum.CANCELLEDwill be returned.For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKSinflagsthe information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned.If the file does not exist, the
Gio.IOErrorEnum.NOT_FOUNDerror will be returned. Other errors are possible too, and depend on what kind of file system the file is on.- Parameters:
attributes- an attribute query stringflags- flags to affect the query operationcancellable- optional cancellable object- Returns:
- a
FileInfofor the given this File - Throws:
GErrorException- seeGError
-
queryInfo
default FileInfo queryInfo(String attributes, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Gets the requested information about specifiedfile.The result is a
FileInfoobject that contains key-value attributes (such as the type or size of the file).The
attributesvalue is a string that specifies the file attributes that should be gathered. It is not an error if it’s not possible to read a particular requested attribute from a file — it just won't be set. In particular this means that if a file is inaccessible (due to being in a folder with restrictive permissions), for example, you can expect the returnedFileInfoto have very few attributes set. You should check whether an attribute is set usingFileInfo.hasAttribute(java.lang.String)before trying to retrieve its value.It is guaranteed that if any of the following attributes are listed in
attributes,they will always be set in the returnedFileInfo, even if the user doesn’t have permissions to access the file:Gio.FILE_ATTRIBUTE_STANDARD_NAMEGio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME
attributesshould be a comma-separated list of attributes or attribute wildcards. The wildcard"*"means all attributes, and a wildcard like"standard::*"means all attributes in the standard namespace. An example attribute query might be"standard::*,owner::user". The standard attributes are available as defines, likeGio.FILE_ATTRIBUTE_STANDARD_NAME.If
cancellableis notNULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorGio.IOErrorEnum.CANCELLEDwill be returned.For symlinks, normally the information about the target of the symlink is returned, rather than information about the symlink itself. However if you pass
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKSinflagsthe information about the symlink itself will be returned. Also, for symlinks that point to non-existing files the information about the symlink itself will be returned.If the file does not exist, the
Gio.IOErrorEnum.NOT_FOUNDerror will be returned. Other errors are possible too, and depend on what kind of file system the file is on.- Parameters:
attributes- an attribute query stringflags- flags to affect the query operationcancellable- optional cancellable object- Returns:
- a
FileInfofor the given this File - Throws:
GErrorException- seeGError
-
queryInfoAsync
default void queryInfoAsync(String attributes, Set<FileQueryInfoFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about specifiedfile.The result is aGFileInfoobject that contains key-value attributes (such as type or size for the file).For more details, see g_file_query_info() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_query_info_finish() to get the result of the operation.- Parameters:
attributes- an attribute query stringflags- a set ofGFileQueryInfoFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
queryInfoAsync
default void queryInfoAsync(String attributes, FileQueryInfoFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously gets the requested information about specifiedfile.The result is aGFileInfoobject that contains key-value attributes (such as type or size for the file).For more details, see g_file_query_info() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_query_info_finish() to get the result of the operation.- Parameters:
attributes- an attribute query stringflags- a set ofGFileQueryInfoFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
queryInfoFinish
Finishes an asynchronous file info query. See g_file_query_info_async().- Parameters:
res- aGAsyncResult- Returns:
GFileInfofor given this File ornullon error. Free the returned object with g_object_unref().- Throws:
GErrorException- seeGError
-
querySettableAttributes
default FileAttributeInfoList querySettableAttributes(@Nullable Cancellable cancellable) throws GErrorException Obtain the list of settable attributes for the file.Returns the type and full attribute name of all the attributes that can be set on this file. This doesn't mean setting it will always succeed though, you might get an access failure, or some specific file may not support a specific attribute.
If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileAttributeInfoListdescribing the settable attributes. When you are done with it, release it with g_file_attribute_info_list_unref() - Throws:
GErrorException- seeGError
-
queryWritableNamespaces
default FileAttributeInfoList queryWritableNamespaces(@Nullable Cancellable cancellable) throws GErrorException Obtain the list of attribute namespaces where new attributes can be created by a user. An example of this is extended attributes (in the "xattr" namespace).If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileAttributeInfoListdescribing the writable namespaces. When you are done with it, release it with g_file_attribute_info_list_unref() - Throws:
GErrorException- seeGError
-
read
Opens a file for reading. The result is aGFileInputStreamthat can be used to read the contents of the file.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If the file does not exist, the
IOErrorEnum.NOT_FOUNDerror will be returned. If the file is a directory, theIOErrorEnum.IS_DIRECTORYerror will be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
cancellable- aGCancellable- Returns:
GFileInputStreamornullon error. Free the returned object with g_object_unref().- Throws:
GErrorException- seeGError
-
readAsync
default void readAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously opens this File for reading.For more details, see g_file_read() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_read_finish() to get the result of the operation.- Parameters:
ioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
readFinish
Finishes an asynchronous file read operation started with g_file_read_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileInputStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
replace
default FileOutputStream replace(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Returns an output stream for overwriting the file, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created.This will try to replace the file in the safest way possible so that any errors during the writing will not affect an already existing copy of the file. For instance, for local files it may write to a temporary file and then atomically rename over the destination when the stream is closed.
By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If you pass in a non-
nulletagvalue and this File already exists, then this value is compared to the current entity tag of the file, and if they differ anIOErrorEnum.WRONG_ETAGerror is returned. This generally means that the file has been changed since you last read it. You can get the new etag from g_file_output_stream_get_etag() after you've finished writing and closed theGFileOutputStream. When you load a new file you can use g_file_input_stream_query_info() to get the etag of the file.If
makeBackupistrue, this function will attempt to make a backup of the current file before overwriting it. If this fails aIOErrorEnum.CANT_CREATE_BACKUPerror will be returned. If you want to replace anyway, try again withmakeBackupset tofalse.If the file is a directory the
IOErrorEnum.IS_DIRECTORYerror will be returned, and if the file is some other form of non-regular file then aIOErrorEnum.NOT_REGULAR_FILEerror will be returned. Some file systems don't allow all file names, and may return anIOErrorEnum.INVALID_FILENAMEerror, and if the name is to longIOErrorEnum.FILENAME_TOO_LONGwill be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
etag- an optional entity tag for the currentGFile, orNULLto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileOutputStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
replace
default FileOutputStream replace(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException Returns an output stream for overwriting the file, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created.This will try to replace the file in the safest way possible so that any errors during the writing will not affect an already existing copy of the file. For instance, for local files it may write to a temporary file and then atomically rename over the destination when the stream is closed.
By default files created are generally readable by everyone, but if you pass
FileCreateFlags.PRIVATEinflagsthe file will be made readable only to the current user, to the level that is supported on the target filesystem.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If you pass in a non-
nulletagvalue and this File already exists, then this value is compared to the current entity tag of the file, and if they differ anIOErrorEnum.WRONG_ETAGerror is returned. This generally means that the file has been changed since you last read it. You can get the new etag from g_file_output_stream_get_etag() after you've finished writing and closed theGFileOutputStream. When you load a new file you can use g_file_input_stream_query_info() to get the etag of the file.If
makeBackupistrue, this function will attempt to make a backup of the current file before overwriting it. If this fails aIOErrorEnum.CANT_CREATE_BACKUPerror will be returned. If you want to replace anyway, try again withmakeBackupset tofalse.If the file is a directory the
IOErrorEnum.IS_DIRECTORYerror will be returned, and if the file is some other form of non-regular file then aIOErrorEnum.NOT_REGULAR_FILEerror will be returned. Some file systems don't allow all file names, and may return anIOErrorEnum.INVALID_FILENAMEerror, and if the name is to longIOErrorEnum.FILENAME_TOO_LONGwill be returned. Other errors are possible too, and depend on what kind of filesystem the file is on.- Parameters:
etag- an optional entity tag for the currentGFile, orNULLto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileOutputStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
replaceAsync
default void replaceAsync(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.For more details, see g_file_replace() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_replace_finish() to get the result of the operation.- Parameters:
etag- an entity tag for the currentGFile, ornullto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
replaceAsync
default void replaceAsync(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.For more details, see g_file_replace() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_replace_finish() to get the result of the operation.- Parameters:
etag- an entity tag for the currentGFile, ornullto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
replaceContents
default boolean replaceContents(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Out<String> newEtag, @Nullable Cancellable cancellable) throws GErrorException Replaces the contents of this File withcontentsoflengthbytes.If
etagis specified (notnull), any existing file must have that etag, or the errorIOErrorEnum.WRONG_ETAGwill be returned.If
makeBackupistrue, this function will attempt to make a backup offile.Internally, it uses g_file_replace(), so will try to replace the file contents in the safest way possible. For example, atomic renames are used when replacing local files’ contents.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.The returned
newEtagcan be used to verify that the file hasn't changed the next time it is saved over.- Parameters:
contents- a string containing the new contents for this Fileetag- the old entity-tag for the document, ornullmakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagsnewEtag- a location to a new entity tag for the document. This should be freed with g_free() when no longer needed, ornullcancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif successful. If an error has occurred, this function will returnfalseand seterrorappropriately if present.- Throws:
GErrorException- seeGError
-
replaceContents
default boolean replaceContents(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Out<String> newEtag, @Nullable Cancellable cancellable) throws GErrorException Replaces the contents of this File withcontentsoflengthbytes.If
etagis specified (notnull), any existing file must have that etag, or the errorIOErrorEnum.WRONG_ETAGwill be returned.If
makeBackupistrue, this function will attempt to make a backup offile.Internally, it uses g_file_replace(), so will try to replace the file contents in the safest way possible. For example, atomic renames are used when replacing local files’ contents.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.The returned
newEtagcan be used to verify that the file hasn't changed the next time it is saved over.- Parameters:
contents- a string containing the new contents for this Fileetag- the old entity-tag for the document, ornullmakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagsnewEtag- a location to a new entity tag for the document. This should be freed with g_free() when no longer needed, ornullcancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif successful. If an error has occurred, this function will returnfalseand seterrorappropriately if present.- Throws:
GErrorException- seeGError
-
replaceContentsAsync
default void replaceContentsAsync(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous replacement of this File with the givencontentsoflengthbytes.etagwill replace the document's current entity tag.When this operation has completed,
callbackwill be called withuserUserdata, and the operation can be finalized with g_file_replace_contents_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
makeBackupistrue, this function will attempt to make a backup offile.Note that no copy of
contentswill be made, so it must stay valid untilcallbackis called. See g_file_replace_contents_bytes_async() for aGBytesversion that will automatically hold a reference to the contents (without copying) for the duration of the call.- Parameters:
contents- string of contents to replace the file withetag- a new entity tag for thefile,ornullmakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
replaceContentsAsync
default void replaceContentsAsync(@org.jspecify.annotations.Nullable byte @Nullable [] contents, @Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts an asynchronous replacement of this File with the givencontentsoflengthbytes.etagwill replace the document's current entity tag.When this operation has completed,
callbackwill be called withuserUserdata, and the operation can be finalized with g_file_replace_contents_finish().If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.If
makeBackupistrue, this function will attempt to make a backup offile.Note that no copy of
contentswill be made, so it must stay valid untilcallbackis called. See g_file_replace_contents_bytes_async() for aGBytesversion that will automatically hold a reference to the contents (without copying) for the duration of the call.- Parameters:
contents- string of contents to replace the file withetag- a new entity tag for thefile,ornullmakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
replaceContentsBytesAsync
default void replaceContentsBytesAsync(byte[] contents, @Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Same as g_file_replace_contents_async() but takes aGBytesinput instead. This function will keep a ref oncontentsuntil the operation is done. Unlike g_file_replace_contents_async() this allows forgetting about the content without waiting for the callback.When this operation has completed,
callbackwill be called withuserUserdata, and the operation can be finalized with g_file_replace_contents_finish().- Parameters:
contents- aGBytesetag- a new entity tag for thefile,ornullmakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.40
-
replaceContentsBytesAsync
default void replaceContentsBytesAsync(byte[] contents, @Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Same as g_file_replace_contents_async() but takes aGBytesinput instead. This function will keep a ref oncontentsuntil the operation is done. Unlike g_file_replace_contents_async() this allows forgetting about the content without waiting for the callback.When this operation has completed,
callbackwill be called withuserUserdata, and the operation can be finalized with g_file_replace_contents_finish().- Parameters:
contents- aGBytesetag- a new entity tag for thefile,ornullmakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.40
-
replaceContentsFinish
default boolean replaceContentsFinish(AsyncResult res, @Nullable Out<String> newEtag) throws GErrorException Finishes an asynchronous replace of the givenfile.See g_file_replace_contents_async(). SetsnewEtagto the new entity tag for the document, if present.- Parameters:
res- aGAsyncResultnewEtag- a location of a new entity tag for the document. This should be freed with g_free() when it is no longer needed, ornull- Returns:
trueon success,falseon failure.- Throws:
GErrorException- seeGError
-
replaceFinish
Finishes an asynchronous file replace operation started with g_file_replace_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileOutputStream, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
replaceReadwrite
default FileIOStream replaceReadwrite(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created.For details about the behaviour, see g_file_replace() which does the same thing but returns an output stream only.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
- Parameters:
etag- an optional entity tag for the currentGFile, orNULLto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileIOStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.22
-
replaceReadwrite
default FileIOStream replaceReadwrite(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException Returns an output stream for overwriting the file in readwrite mode, possibly creating a backup copy of the file first. If the file doesn't exist, it will be created.For details about the behaviour, see g_file_replace() which does the same thing but returns an output stream only.
Note that in many non-local file cases read and write streams are not supported, so make sure you really need to do read and write streaming, rather than just opening for reading or writing.
- Parameters:
etag- an optional entity tag for the currentGFile, orNULLto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFileIOStreamornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.22
-
replaceReadwriteAsync
default void replaceReadwriteAsync(@Nullable String etag, boolean makeBackup, Set<FileCreateFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.For more details, see g_file_replace_readwrite() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_replace_readwrite_finish() to get the result of the operation.- Parameters:
etag- an entity tag for the currentGFile, ornullto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
replaceReadwriteAsync
default void replaceReadwriteAsync(@Nullable String etag, boolean makeBackup, FileCreateFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously overwrites the file in read-write mode, replacing the contents, possibly creating a backup copy of the file first.For more details, see g_file_replace_readwrite() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_replace_readwrite_finish() to get the result of the operation.- Parameters:
etag- an entity tag for the currentGFile, ornullto ignoremakeBackup-trueif a backup should be createdflags- a set ofGFileCreateFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
replaceReadwriteFinish
Finishes an asynchronous file replace operation started with g_file_replace_readwrite_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileIOStream, ornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError- Since:
- 2.22
-
resolveRelativePath
Resolves a relative path for this File to an absolute path.This call does no blocking I/O.
If the
relativePathis an absolute path name, the resolution is done absolutely (without taking this File path as base).- Parameters:
relativePath- a given relative path string- Returns:
- a
GFilefor the resolved path.
-
setAttribute
default boolean setAttribute(String attribute, FileAttributeType type, @Nullable MemorySegment valueP, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Sets an attribute in the file with attribute nameattributetovalueP.Some attributes can be unset by setting
typetoFileAttributeType.INVALIDandvaluePtonull.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's nametype- The type of the attributevalueP- a pointer to the value (or the pointer itself if the type is a pointer type)flags- a set ofGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif the attribute was set,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttribute
default boolean setAttribute(String attribute, FileAttributeType type, @Nullable MemorySegment valueP, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Sets an attribute in the file with attribute nameattributetovalueP.Some attributes can be unset by setting
typetoFileAttributeType.INVALIDandvaluePtonull.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's nametype- The type of the attributevalueP- a pointer to the value (or the pointer itself if the type is a pointer type)flags- a set ofGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif the attribute was set,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeByteString
default boolean setAttributeByteString(String attribute, String value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.BYTE_STRINGtovalue.Ifattributeis of a different type, this operation will fail, returningfalse.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- a string containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeByteString
default boolean setAttributeByteString(String attribute, String value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.BYTE_STRINGtovalue.Ifattributeis of a different type, this operation will fail, returningfalse.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- a string containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeInt32
default boolean setAttributeInt32(String attribute, int value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.INT32tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- agint32containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeInt32
default boolean setAttributeInt32(String attribute, int value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.INT32tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- agint32containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeInt64
default boolean setAttributeInt64(String attribute, long value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.INT64tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- aguint64containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeInt64
default boolean setAttributeInt64(String attribute, long value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.INT64tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- aguint64containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeString
default boolean setAttributeString(String attribute, String value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.STRINGtovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- a string containing the attribute's valueflags-GFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeString
default boolean setAttributeString(String attribute, String value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.STRINGtovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- a string containing the attribute's valueflags-GFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeUint32
default boolean setAttributeUint32(String attribute, int value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.UINT32tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- aguint32containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeUint32
default boolean setAttributeUint32(String attribute, int value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.UINT32tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- aguint32containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeUint64
default boolean setAttributeUint64(String attribute, long value, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.UINT64tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- aguint64containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributeUint64
default boolean setAttributeUint64(String attribute, long value, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Setsattributeof typeFileAttributeType.UINT64tovalue.Ifattributeis of a different type, this operation will fail.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
attribute- a string containing the attribute's namevalue- aguint64containing the attribute's new valueflags- aGFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
trueif theattributewas successfully set tovaluein thefile,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributesAsync
default void setAttributesAsync(FileInfo info, Set<FileQueryInfoFlags> flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sets the attributes of this File withinfo.For more details, see g_file_set_attributes_from_info(), which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_set_attributes_finish() to get the result of the operation.- Parameters:
info- aGFileInfoflags- aGFileQueryInfoFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
setAttributesAsync
default void setAttributesAsync(FileInfo info, FileQueryInfoFlags flags, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sets the attributes of this File withinfo.For more details, see g_file_set_attributes_from_info(), which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_set_attributes_finish() to get the result of the operation.- Parameters:
info- aGFileInfoflags- aGFileQueryInfoFlagsioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
setAttributesFinish
Finishes setting an attribute started in g_file_set_attributes_async().- Parameters:
result- aGAsyncResultinfo- aGFileInfo- Returns:
trueif the attributes were set correctly,falseotherwise.- Throws:
GErrorException- seeGError
-
setAttributesFromInfo
default boolean setAttributesFromInfo(FileInfo info, Set<FileQueryInfoFlags> flags, @Nullable Cancellable cancellable) throws GErrorException Tries to set all attributes in theGFileInfoon the target values, not stopping on the first error.If there is any error during this operation then
errorwill be set to the first error. Error on particular fields are flagged by setting the "status" field in the attribute value toFileAttributeStatus.ERROR_SETTING, which means you can also detect further errors.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
info- aGFileInfoflags-GFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
falseif there was any error,trueotherwise.- Throws:
GErrorException- seeGError
-
setAttributesFromInfo
default boolean setAttributesFromInfo(FileInfo info, FileQueryInfoFlags flags, @Nullable Cancellable cancellable) throws GErrorException Tries to set all attributes in theGFileInfoon the target values, not stopping on the first error.If there is any error during this operation then
errorwill be set to the first error. Error on particular fields are flagged by setting the "status" field in the attribute value toFileAttributeStatus.ERROR_SETTING, which means you can also detect further errors.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
info- aGFileInfoflags-GFileQueryInfoFlagscancellable- optionalGCancellableobject,nullto ignore- Returns:
falseif there was any error,trueotherwise.- Throws:
GErrorException- seeGError
-
setDisplayName
default File setDisplayName(String displayName, @Nullable Cancellable cancellable) throws GErrorException Renames this File to the specified display name.The display name is converted from UTF-8 to the correct encoding for the target filesystem if possible and the this File is renamed to this.
If you want to implement a rename operation in the user interface the edit name (
G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the initial value in the rename widget, and then the result after editing should be passed to g_file_set_display_name().On success the resulting converted filename is returned.
If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
displayName- a stringcancellable- optionalGCancellableobject,nullto ignore- Returns:
- a
GFilespecifying what this File was renamed to, ornullif there was an error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
setDisplayNameAsync
default void setDisplayNameAsync(String displayName, int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sets the display name for a givenGFile.For more details, see g_file_set_display_name() which is the synchronous version of this call.
When the operation is finished,
callbackwill be called. You can then call g_file_set_display_name_finish() to get the result of the operation.- Parameters:
displayName- a stringioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
setDisplayNameFinish
Finishes setting a display name started with g_file_set_display_name_async().- Parameters:
res- aGAsyncResult- Returns:
- a
GFileornullon error. Free the returned object with g_object_unref(). - Throws:
GErrorException- seeGError
-
startMountable
default void startMountable(Set<DriveStartFlags> flags, @Nullable MountOperation startOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts a file of typeFileType.MOUNTABLE. UsingstartOperation,you can request callbacks when, for instance, passwords are needed during authentication.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationstartOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied, ornull- Since:
- 2.22
-
startMountable
default void startMountable(DriveStartFlags flags, @Nullable MountOperation startOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Starts a file of typeFileType.MOUNTABLE. UsingstartOperation,you can request callbacks when, for instance, passwords are needed during authentication.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_mount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationstartOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied, ornull- Since:
- 2.22
-
startMountableFinish
Finishes a start operation. See g_file_start_mountable() for details.Finish an asynchronous start operation that was started with g_file_start_mountable().
- Parameters:
result- aGAsyncResult- Returns:
trueif the operation finished successfully.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.22
-
stopMountable
default void stopMountable(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Stops a file of typeFileType.MOUNTABLE.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_stop_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied, ornull- Since:
- 2.22
-
stopMountable
default void stopMountable(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Stops a file of typeFileType.MOUNTABLE.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_stop_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interaction.cancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied, ornull- Since:
- 2.22
-
stopMountableFinish
Finishes a stop operation, see g_file_stop_mountable() for details.Finish an asynchronous stop operation that was started with g_file_stop_mountable().
- Parameters:
result- aGAsyncResult- Returns:
trueif the operation finished successfully.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.22
-
supportsThreadContexts
default boolean supportsThreadContexts()Checks if this File supports thread-default main contexts (seeMainContext.pushThreadDefault()) If this returnsfalse, you cannot perform asynchronous operations on this File in a thread that has a thread-default context.- Returns:
- Whether or not this File supports thread-default contexts.
- Since:
- 2.22
-
trash
Sends this File to the "Trashcan", if possible. This is similar to deleting it, but the user can recover it before emptying the trashcan. Trashing is disabled for system mounts by default (see g_unix_mount_entry_is_system_internal()), so this call can return theIOErrorEnum.NOT_SUPPORTEDerror. Since GLib 2.66, thex-gvfs-notrashunix mount option can be used to disable g_file_trash() support for particular mounts, theIOErrorEnum.NOT_SUPPORTEDerror will be returned in that case. Since 2.82, thex-gvfs-trashunix mount option can be used to enable g_file_trash() support for particular system mounts.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.- Parameters:
cancellable- optionalGCancellableobject,nullto ignore- Returns:
trueon successful trash,falseotherwise.- Throws:
GErrorException- seeGError
-
trashAsync
default void trashAsync(int ioPriority, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously sends this File to the Trash location, if possible.- Parameters:
ioPriority- the I/O priority of the requestcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.38
-
trashFinish
Finishes an asynchronous file trashing operation, started with g_file_trash_async().- Parameters:
result- aGAsyncResult- Returns:
trueon successful trash,falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.38
-
unmountMountable
@Deprecated default void unmountMountable(Set<MountUnmountFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_unmount_mountable_with_operation() instead.Unmounts a file of type G_FILE_TYPE_MOUNTABLE.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_unmount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
unmountMountable
@Deprecated default void unmountMountable(MountUnmountFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Deprecated.Use g_file_unmount_mountable_with_operation() instead.Unmounts a file of type G_FILE_TYPE_MOUNTABLE.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_unmount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationcancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied
-
unmountMountableFinish
Deprecated.Use g_file_unmount_mountable_with_operation_finish() instead.Finishes an unmount operation, see g_file_unmount_mountable() for details.Finish an asynchronous unmount operation that was started with g_file_unmount_mountable().
- Parameters:
result- aGAsyncResult- Returns:
trueif the operation finished successfully.falseotherwise.- Throws:
GErrorException- seeGError
-
unmountMountableWithOperation
default void unmountMountableWithOperation(Set<MountUnmountFlags> flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a file of typeFileType.MOUNTABLE.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_unmount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
unmountMountableWithOperation
default void unmountMountableWithOperation(MountUnmountFlags flags, @Nullable MountOperation mountOperation, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Unmounts a file of typeFileType.MOUNTABLE.If
cancellableis notnull, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the errorIOErrorEnum.CANCELLEDwill be returned.When the operation is finished,
callbackwill be called. You can then call g_file_unmount_mountable_finish() to get the result of the operation.- Parameters:
flags- flags affecting the operationmountOperation- aGMountOperation, ornullto avoid user interactioncancellable- optionalGCancellableobject,nullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.22
-
unmountMountableWithOperationFinish
Finishes an unmount operation, see g_file_unmount_mountable_with_operation() for details.Finish an asynchronous unmount operation that was started with g_file_unmount_mountable_with_operation().
- Parameters:
result- aGAsyncResult- Returns:
trueif the operation finished successfully.falseotherwise.- Throws:
GErrorException- seeGError- Since:
- 2.22
-