1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
|
\alias{GFile}
\alias{GFileProgressCallback}
\alias{GFileReadMoreCallback}
\alias{GFileQueryInfoFlags}
\alias{GFileCreateFlags}
\alias{GFileCopyFlags}
\alias{GFileMonitorFlags}
\name{GFile}
\title{GFile}
\description{File and Directory Handling}
\section{Methods and Functions}{
\code{\link{gFileNewForPath}(path)}\cr
\code{\link{gFileNewForUri}(uri)}\cr
\code{\link{gFileNewForCommandlineArg}(arg)}\cr
\code{\link{gFileParseName}(parse.name)}\cr
\code{\link{gFileDup}(object)}\cr
\code{\link{gFileHash}(file)}\cr
\code{\link{gFileEqual}(object, file2)}\cr
\code{\link{gFileGetBasename}(object)}\cr
\code{\link{gFileGetPath}(object)}\cr
\code{\link{gFileGetUri}(object)}\cr
\code{\link{gFileGetParseName}(object)}\cr
\code{\link{gFileGetParent}(object)}\cr
\code{\link{gFileGetChild}(object, name)}\cr
\code{\link{gFileGetChildForDisplayName}(object, display.name, .errwarn = TRUE)}\cr
\code{\link{gFileHasPrefix}(object, descendant)}\cr
\code{\link{gFileGetRelativePath}(object, descendant)}\cr
\code{\link{gFileResolveRelativePath}(object, relative.path)}\cr
\code{\link{gFileIsNative}(object)}\cr
\code{\link{gFileHasUriScheme}(object, uri.scheme)}\cr
\code{\link{gFileGetUriScheme}(object)}\cr
\code{\link{gFileRead}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileReadAsync}(object, io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileReadFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileAppendTo}(object, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileCreate}(object, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileReplace}(object, etag, make.backup, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileAppendToAsync}(object, flags = "G_FILE_CREATE_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileAppendToFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileCreateAsync}(object, flags = "G_FILE_CREATE_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileCreateFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileReplaceAsync}(object, etag, make.backup, flags = "G_FILE_CREATE_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileReplaceFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileQueryInfo}(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileQueryInfoAsync}(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileQueryInfoFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileQueryExists}(object, cancellable = NULL)}\cr
\code{\link{gFileQueryFileType}(object, flags, cancellable = NULL)}\cr
\code{\link{gFileQueryFilesystemInfo}(object, attributes, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileQueryFilesystemInfoAsync}(object, attributes, io.priority, cancellable, callback, user.data = NULL)}\cr
\code{\link{gFileQueryFilesystemInfoFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileQueryDefaultHandler}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileFindEnclosingMount}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileFindEnclosingMountAsync}(object, io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileFindEnclosingMountFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileEnumerateChildren}(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileEnumerateChildrenAsync}(object, attributes, flags = "G_FILE_QUERY_INFO_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileEnumerateChildrenFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileSetDisplayName}(object, display.name, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetDisplayNameAsync}(object, display.name, io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileSetDisplayNameFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileDelete}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileTrash}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileCopy}(object, destination, flags = "G_FILE_COPY_NONE", cancellable = NULL, progress.callback, progress.callback.data, .errwarn = TRUE)}\cr
\code{\link{gFileCopyAsync}(object, destination, flags = "G_FILE_COPY_NONE", io.priority = 0, cancellable = NULL, progress.callback, progress.callback.data, callback, user.data = NULL)}\cr
\code{\link{gFileCopyFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileMove}(object, destination, flags = "G_FILE_COPY_NONE", cancellable = NULL, progress.callback, progress.callback.data, .errwarn = TRUE)}\cr
\code{\link{gFileMakeDirectory}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileMakeDirectoryWithParents}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileMakeSymbolicLink}(object, symlink.value, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileQuerySettableAttributes}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileQueryWritableNamespaces}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttribute}(object, attribute, type, value.p, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributesFromInfo}(object, info, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributesAsync}(object, info, flags = "G_FILE_QUERY_INFO_NONE", io.priority = 0, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileSetAttributesFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributeString}(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributeByteString}(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributeUint32}(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributeInt32}(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributeUint64}(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileSetAttributeInt64}(object, attribute, value, flags = "G_FILE_QUERY_INFO_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileMountMountable}(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileMountMountableFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileUnmountMountable}(object, flags = "G_MOUNT_UNMOUNT_NONE", cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileUnmountMountableFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileUnmountMountableWithOperation}(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileUnmountMountableWithOperationFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileEjectMountable}(object, flags = "G_MOUNT_UNMOUNT_NONE", cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileEjectMountableFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileEjectMountableWithOperation}(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileEjectMountableWithOperationFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileStartMountable}(object, flags, start.operation, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileStartMountableFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileStopMountable}(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileStopMountableFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFilePollMountable}(object, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFilePollMountableFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileMountEnclosingVolume}(object, flags, mount.operation, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileMountEnclosingVolumeFinish}(object, result, .errwarn = TRUE)}\cr
\code{\link{gFileMonitorDirectory}(object, flags = "G_FILE_MONITOR_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileMonitorFile}(object, flags = "G_FILE_MONITOR_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileMonitor}(object, flags = "G_FILE_MONITOR_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileLoadContents}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileLoadContentsAsync}(object, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileLoadContentsFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileLoadPartialContentsFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileReplaceContents}(object, contents, length, etag, make.backup, flags = "G_FILE_CREATE_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileReplaceContentsAsync}(object, contents, length, etag, make.backup, flags = "G_FILE_CREATE_NONE", cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileReplaceContentsFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileCopyAttributes}(object, destination, flags = "G_FILE_COPY_NONE", cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileCreateReadwrite}(object, flags, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileCreateReadwriteAsync}(object, flags, io.priority, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileCreateReadwriteFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileOpenReadwrite}(object, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileOpenReadwriteAsync}(object, io.priority, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileOpenReadwriteFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileReplaceReadwrite}(object, etag, make.backup, flags, cancellable = NULL, .errwarn = TRUE)}\cr
\code{\link{gFileReplaceReadwriteAsync}(object, etag, make.backup, flags, io.priority, cancellable = NULL, callback, user.data = NULL)}\cr
\code{\link{gFileReplaceReadwriteFinish}(object, res, .errwarn = TRUE)}\cr
\code{\link{gFileSupportsThreadContexts}(object)}\cr
}
\section{Hierarchy}{\preformatted{
GInterface
+----GFile
GFlags
+----GFileQueryInfoFlags
GFlags
+----GFileCreateFlags
GFlags
+----GFileCopyFlags
GFlags
+----GFileMonitorFlags
GEnum
+----GFilesystemPreviewType
}}
\section{Detailed Description}{\code{\link{GFile}} is a high level abstraction for manipulating files on a
virtual file system. \code{\link{GFile}}s are lightweight, immutable
objects that do no I/O upon creation. It is necessary to understand that
\code{\link{GFile}} objects do not represent files, merely an identifier for a file. All
file content I/O is implemented as streaming operations (see \code{\link{GInputStream}} and
\code{\link{GOutputStream}}).
To construct a \code{\link{GFile}}, you can use:
\code{\link{gFileNewForPath}} if you have a path.
\code{\link{gFileNewForUri}} if you have a URI.
\code{\link{gFileNewForCommandlineArg}} for a command line argument.
\code{\link{gFileParseName}} from a utf8 string gotten from \code{\link{gFileGetParseName}}.
One way to think of a \code{\link{GFile}} is as an abstraction of a pathname. For normal
files the system pathname is what is stored internally, but as \code{\link{GFile}}s
are extensible it could also be something else that corresponds to a pathname
in a userspace implementation of a filesystem.
\code{\link{GFile}}s make up hierarchies of directories and files that correspond to the
files on a filesystem. You can move through the file system with \code{\link{GFile}} using
\code{\link{gFileGetParent}} to get an identifier for the parent directory, \code{\link{gFileGetChild}}
to get a child within a directory, \code{\link{gFileResolveRelativePath}} to resolve a relative
path between two \code{\link{GFile}}s. There can be multiple hierarchies, so you may not
end up at the same root if you repeatedly call \code{\link{gFileGetParent}} on two different
files.
All \code{\link{GFile}}s have a basename (get with \code{\link{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
\code{G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME} attribute with \code{\link{gFileQueryInfo}}.
This is guaranteed to be in utf8 and can be used in a user interface. But always
store the real basename or the \code{\link{GFile}} to use to actually access the file, because
there is no way to go from a display name to the actual name.
Using \code{\link{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 \code{\link{GFile}}s 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 \code{\link{GFile}}s point to the same file you can query for the
\code{G_FILE_ATTRIBUTE_ID_FILE} attribute. Note that \code{\link{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 \code{\link{GFile}}s.
Many \code{\link{GFile}} operations have both synchronous and asynchronous versions
to suit your application. Asynchronous versions of synchronous functions
simply have \code{async()} appended to their function names. The asynchronous
I/O functions call a \code{\link{GAsyncReadyCallback}} which is then used to finalize
the operation, producing a GAsyncResult which is then passed to the
function's matching \code{finish()} operation.
Some \code{\link{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:
\code{\link{gFileMountMountable}} to mount a mountable file.
\code{\link{gFileUnmountMountableWithOperation}} to unmount a mountable file.
\code{\link{gFileEjectMountableWithOperation}} to eject a mountable file.
One notable feature of \code{\link{GFile}}s 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 (\url{http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html})
for HTTP Etag headers, which are a very similar concept.}
\section{Structures}{\describe{\item{\verb{GFile}}{
A handle to an object implementing the \verb{GFileIface} interface.
Generally stores a location within the file system. Handles do not
necessarily represent files or directories that currently exist.
}}}
\section{Enums and Flags}{\describe{
\item{\verb{GFileQueryInfoFlags}}{
Flags used when querying a \code{\link{GFileInfo}}.
\describe{
\item{\verb{ne}}{No flags set.}
\item{\verb{follow-symlinks}}{Don't follow symlinks.}
}
}
\item{\verb{GFileCreateFlags}}{
Flags used when an operation may create a file.
\describe{
\item{\verb{none}}{No flags set.}
\item{\verb{private}}{Create a file that can only be
accessed by the current user.}
}
}
\item{\verb{GFileCopyFlags}}{
Flags used when copying or moving files.
\describe{
\item{\verb{none}}{No flags set.}
\item{\verb{overwrite}}{Overwrite any existing files}
\item{\verb{backup}}{Make a backup of any existing files.}
\item{\verb{nofollow-symlinks}}{Don't follow symlinks.}
\item{\verb{all-metadata}}{Copy all file metadata instead of just default set used for copy (see \code{\link{GFileInfo}}).}
\item{\verb{no-fallback-for-move}}{Don't use copy and delete fallback if native move not supported.}
}
}
\item{\verb{GFileMonitorFlags}}{
Flags used to set what a \code{\link{GFileMonitor}} will watch for.
\describe{
\item{\verb{none}}{No flags set.}
\item{\verb{watch-mounts}}{Watch for mount events.}
}
}
}}
\section{User Functions}{\describe{
\item{\code{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.
\describe{
\item{\code{current.num.bytes}}{the current number of bytes in the operation.}
\item{\code{total.num.bytes}}{the total number of bytes in the operation.}
\item{\code{user.data}}{user data passed to the callback.}
}
}
\item{\code{GFileReadMoreCallback(file.contents, file.size, callback.data)}}{
When loading the partial contents of a file with \code{gFileLoadPartialContentsAsync()},
it may become necessary to determine if any more data from the file should be loaded.
A \code{\link{GFileReadMoreCallback}} function facilitates this by returning \code{TRUE} if more data
should be read, or \code{FALSE} otherwise.
\describe{
\item{\code{file.contents}}{the data as currently read.}
\item{\code{file.size}}{the size of the data currently read.}
\item{\code{callback.data}}{data passed to the callback.}
}
\emph{Returns:} [logical] \code{TRUE} if more data should be read back. \code{FALSE} otherwise.
}
}}
\references{\url{https://developer.gnome.org/gio/stable/GFile.html}}
\author{Derived by RGtkGen from GTK+ documentation}
\keyword{internal}
|