Learn R Programming

RGtk2 (version 2.20.31)

GFile: GFile

Description

File and Directory Handling

Arguments

Methods and Functions

gFileNewForPath(path) gFileNewForUri(uri) gFileNewForCommandlineArg(arg) gFileParseName(parse.name) gFileDup(object) gFileHash(file) gFileEqual(object, file2) gFileGetBasename(object) gFileGetPath(object) gFileGetUri(object) gFileGetParseName(object) gFileGetParent(object) gFileGetChild(object, name) gFileGetChildForDisplayName(object, display.name, .errwarn = TRUE) gFileHasPrefix(object, descendant) gFileGetRelativePath(object, descendant) gFileResolveRelativePath(object, relative.path) gFileIsNative(object) gFileHasUriScheme(object, uri.scheme) gFileGetUriScheme(object) gFileRead(object, cancellable = NULL, .errwarn = TRUE) gFileReadAsync(object, io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileReadFinish(object, res, .errwarn = TRUE) gFileAppendTo(object, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE) gFileCreate(object, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE) gFileReplace(object, etag, make.backup, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE) gFileAppendToAsync(object, flags = "G_FILE_CREATE_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileAppendToFinish(object, res, .errwarn = TRUE) gFileCreateAsync(object, flags = "G_FILE_CREATE_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileCreateFinish(object, res, .errwarn = TRUE) gFileReplaceAsync(object, etag, make.backup, flags = "G_FILE_CREATE_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileReplaceFinish(object, res, .errwarn = TRUE) gFileQueryInfo(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileQueryInfoAsync(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileQueryInfoFinish(object, res, .errwarn = TRUE) gFileQueryExists(object, cancellable = NULL) gFileQueryFileType(object, flags, cancellable = NULL) gFileQueryFilesystemInfo(object, attributes, cancellable = NULL, .errwarn = TRUE) gFileQueryFilesystemInfoAsync(object, attributes, io.priority, cancellable, callback, user.data = NULL) gFileQueryFilesystemInfoFinish(object, res, .errwarn = TRUE) gFileQueryDefaultHandler(object, cancellable = NULL, .errwarn = TRUE) gFileFindEnclosingMount(object, cancellable = NULL, .errwarn = TRUE) gFileFindEnclosingMountAsync(object, io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileFindEnclosingMountFinish(object, res, .errwarn = TRUE) gFileEnumerateChildren(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileEnumerateChildrenAsync(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileEnumerateChildrenFinish(object, res, .errwarn = TRUE) gFileSetDisplayName(object, display.name, cancellable = NULL, .errwarn = TRUE) gFileSetDisplayNameAsync(object, display.name, io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileSetDisplayNameFinish(object, res, .errwarn = TRUE) gFileDelete(object, cancellable = NULL, .errwarn = TRUE) gFileTrash(object, cancellable = NULL, .errwarn = TRUE) gFileCopy(object, destination, flags = "G_FILE_COPY_NONE", cancellable = NULL, progress.callback, progress.callback.data, .errwarn = TRUE) gFileCopyAsync(object, destination, flags = "G_FILE_COPY_NONE", io.priority = 0, cancellable = NULL, progress.callback, progress.callback.data, callback, user.data = NULL) gFileCopyFinish(object, res, .errwarn = TRUE) gFileMove(object, destination, flags = "G_FILE_COPY_NONE", cancellable = NULL, progress.callback, progress.callback.data, .errwarn = TRUE) gFileMakeDirectory(object, cancellable = NULL, .errwarn = TRUE) gFileMakeDirectoryWithParents(object, cancellable = NULL, .errwarn = TRUE) gFileMakeSymbolicLink(object, symlink.value, cancellable = NULL, .errwarn = TRUE) gFileQuerySettableAttributes(object, cancellable = NULL, .errwarn = TRUE) gFileQueryWritableNamespaces(object, cancellable = NULL, .errwarn = TRUE) gFileSetAttribute(object, attribute, type, value.p, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileSetAttributesFromInfo(object, info, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileSetAttributesAsync(object, info, flags = "G_FILE_QUERY_INFO_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL) gFileSetAttributesFinish(object, result, .errwarn = TRUE) gFileSetAttributeString(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileSetAttributeByteString(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileSetAttributeUint32(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileSetAttributeInt32(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileSetAttributeUint64(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileSetAttributeInt64(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE) gFileMountMountable(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL) gFileMountMountableFinish(object, result, .errwarn = TRUE) gFileUnmountMountable(object, flags = "G_MOUNT_UNMOUNT_NONE", cancellable = NULL, callback, user.data = NULL) gFileUnmountMountableFinish(object, result, .errwarn = TRUE) gFileUnmountMountableWithOperation(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL) gFileUnmountMountableWithOperationFinish(object, result, .errwarn = TRUE) gFileEjectMountable(object, flags = "G_MOUNT_UNMOUNT_NONE", cancellable = NULL, callback, user.data = NULL) gFileEjectMountableFinish(object, result, .errwarn = TRUE) gFileEjectMountableWithOperation(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL) gFileEjectMountableWithOperationFinish(object, result, .errwarn = TRUE) gFileStartMountable(object, flags, start.operation, cancellable = NULL, callback, user.data = NULL) gFileStartMountableFinish(object, result, .errwarn = TRUE) gFileStopMountable(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL) gFileStopMountableFinish(object, result, .errwarn = TRUE) gFilePollMountable(object, cancellable = NULL, callback, user.data = NULL) gFilePollMountableFinish(object, result, .errwarn = TRUE) gFileMountEnclosingVolume(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL) gFileMountEnclosingVolumeFinish(object, result, .errwarn = TRUE) gFileMonitorDirectory(object, flags = "G_FILE_MONITOR_NONE", cancellable = NULL, .errwarn = TRUE) gFileMonitorFile(object, flags = "G_FILE_MONITOR_NONE", cancellable = NULL, .errwarn = TRUE) gFileMonitor(object, flags = "G_FILE_MONITOR_NONE", cancellable = NULL, .errwarn = TRUE) gFileLoadContents(object, cancellable = NULL, .errwarn = TRUE) gFileLoadContentsAsync(object, cancellable = NULL, callback, user.data = NULL) gFileLoadContentsFinish(object, res, .errwarn = TRUE) gFileLoadPartialContentsFinish(object, res, .errwarn = TRUE) gFileReplaceContents(object, contents, length, etag, make.backup, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE) gFileReplaceContentsAsync(object, contents, length, etag, make.backup, flags = "G_FILE_CREATE_NONE", cancellable = NULL, callback, user.data = NULL) gFileReplaceContentsFinish(object, res, .errwarn = TRUE) gFileCopyAttributes(object, destination, flags = "G_FILE_COPY_NONE", cancellable = NULL, .errwarn = TRUE) gFileCreateReadwrite(object, flags, cancellable = NULL, .errwarn = TRUE) gFileCreateReadwriteAsync(object, flags, io.priority, cancellable = NULL, callback, user.data = NULL) gFileCreateReadwriteFinish(object, res, .errwarn = TRUE) gFileOpenReadwrite(object, cancellable = NULL, .errwarn = TRUE) gFileOpenReadwriteAsync(object, io.priority, cancellable = NULL, callback, user.data = NULL) gFileOpenReadwriteFinish(object, res, .errwarn = TRUE) gFileReplaceReadwrite(object, etag, make.backup, flags, cancellable = NULL, .errwarn = TRUE) gFileReplaceReadwriteAsync(object, etag, make.backup, flags, io.priority, cancellable = NULL, callback, user.data = NULL) gFileReplaceReadwriteFinish(object, res, .errwarn = TRUE) gFileSupportsThreadContexts(object)

Hierarchy

GInterface
   +----GFile
GFlags
   +----GFileQueryInfoFlags
GFlags
   +----GFileCreateFlags
GFlags
   +----GFileCopyFlags
GFlags
   +----GFileMonitorFlags
GEnum
   +----GFilesystemPreviewType

Detailed Description

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 GInputStream and GOutputStream). To construct a GFile, you can use: gFileNewForPath if you have a path. gFileNewForUri if you have a URI. gFileNewForCommandlineArg for a command line argument. gFileParseName from a utf8 string gotten from gFileGetParseName. 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 gFileGetParent to get an identifier for the parent directory, gFileGetChild to get a child within a directory, gFileResolveRelativePath 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 gFileGetParent on two different files. All GFiles have a basename (get with gFileGetBasename). 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 gFileQueryInfo. This is guaranteed to be in utf8 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 GAsyncReadyCallback which is then used to finalize the operation, producing a GAsyncResult which is then passed to the function's matching finish() operation. Some GFile operations do not have synchronous analogs, as they may take a very long time to finish, and blocking may leave an application unusable. Notable cases include: gFileMountMountable to mount a mountable file. gFileUnmountMountableWithOperation to unmount a mountable file. gFileEjectMountableWithOperation to eject a mountable file. 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 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) for HTTP Etag headers, which are a very similar concept.

Structures

Enums and Flags

GFileQueryInfoFlags
Flags used when querying a GFileInfo.
ne
No flags set.
follow-symlinks
Don't follow symlinks.
GFileCreateFlags
Flags used when an operation may create a file.
none
No flags set.
private
Create a file that can only be accessed by the current user.
GFileCopyFlags
Flags used when copying or moving files.
none
No flags set.
overwrite
Overwrite any existing files
backup
Make a backup of any existing files.
nofollow-symlinks
Don't follow symlinks.
all-metadata
Copy all file metadata instead of just default set used for copy (see GFileInfo).
no-fallback-for-move
Don't use copy and delete fallback if native move not supported.
GFileMonitorFlags
Flags used to set what a GFileMonitor will watch for.
none
No flags set.
watch-mounts
Watch for mount events.

User Functions

GFileProgressCallback(current.num.bytes, total.num.bytes, user.data)
When doing file operations that may take a while, such as moving a file or copying a file, a progress callback is used to pass how far along that operation is to the application.
current.num.bytes
the current number of bytes in the operation.
total.num.bytes
the total number of bytes in the operation.
user.data
user data passed to the callback.
GFileReadMoreCallback(file.contents, file.size, callback.data)
When loading the partial contents of a file with gFileLoadPartialContentsAsync(), it may become necessary to determine if any more data from the file should be loaded. A GFileReadMoreCallback function facilitates this by returning TRUE if more data should be read, or FALSE otherwise.
file.contents
the data as currently read.
file.size
the size of the data currently read.
callback.data
data passed to the callback.
Returns: [logical] TRUE if more data should be read back. FALSE otherwise.

References

http://library.gnome.org/devel//gio/GFile.html