#include "config.h"
#ifdef HAVE_SPLICE
-#define _GNU_SOURCE
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include "gappinfo.h"
#include "gfileinputstream.h"
#include "gfileoutputstream.h"
+#include "glocalfileoutputstream.h"
+#include "glocalfileiostream.h"
#include "gcancellable.h"
#include "gasyncresult.h"
#include "gioerror.h"
* g_file_new_for_path() if you have a path.
* g_file_new_for_uri() if you have a URI.
* g_file_new_for_commandline_arg() for a command line argument.
+ * g_file_new_tmp() to create a temporary file from a template.
* g_file_parse_name() from a utf8 string gotten from g_file_get_parse_name().
*
* One way to think of a #GFile is as an abstraction of a pathname. For normal
/**
* g_file_hash:
- * @file: #gconstpointer to a #GFile.
+ * @file: (type GFile): #gconstpointer to a #GFile.
*
* Creates a hash value for a #GFile.
*
* @prefix: input #GFile.
*
* Checks whether @file has the prefix specified by @prefix. In other word,
- * if the names of inital elements of @file<!-- -->s pathname match @prefix.
+ * if the names of initial elements of @file<!-- -->s pathname match @prefix.
* Only full pathname elements are matched, so a path like /foo is not
* considered a prefix of /foobar, only of /foo/bar.
*
* @file: input #GFile.
* @attributes: an attribute query string.
* @flags: a set of #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: #GError for error reporting.
*
* Gets the requested information about the files in a directory. The result
* @flags: a set of #GFileQueryInfoFlags.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the
+ * request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously gets the requested information about the files in a directory. The result
* is a #GFileEnumerator object that will give out #GFileInfo objects for
/**
* g_file_query_exists:
* @file: input #GFile.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
*
* Utility function to check if a particular file exists. This is
* implemented using g_file_query_info() and as such does blocking I/O.
* g_file_query_file_type:
* @file: input #GFile.
* @flags: a set of #GFileQueryInfoFlags passed to g_file_query_info().
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
*
* Utility function to inspect the #GFileType of a file. This is
* implemented using g_file_query_info() and as such does blocking I/O.
* @file: input #GFile.
* @attributes: an attribute query string.
* @flags: a set of #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError.
*
* Gets the requested information about specified @file. The result
* @flags: a set of #GFileQueryInfoFlags.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously gets the requested information about specified @file. The result
* is a #GFileInfo object that contains key-value attributes (such as type or size
* g_file_query_filesystem_info:
* @file: input #GFile.
* @attributes: an attribute query string.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError.
*
* Similar to g_file_query_info(), but obtains information
* 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. @attributes should
* be a comma-separated list of attributes or attribute wildcards. The wildcard "*"
- * means all attributes, and a wildcard like "fs:*" means all attributes in the fs
- * namespace. The standard namespace for filesystem attributes is "fs".
+ * 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 are #G_FILE_ATTRIBUTE_FILESYSTEM_SIZE
* (the total size of the filesystem in bytes), #G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of
* bytes available), and #G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem).
* @attributes: an attribute query string.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously gets the requested information about the filesystem
* that the specified @file is on. The result is a #GFileInfo object
/**
* g_file_find_enclosing_mount:
* @file: input #GFile.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError.
*
* Gets a #GMount for the #GFile.
* @file: a #GFile
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously gets the mount for the file.
*
/**
* g_file_read:
* @file: #GFile to read.
- * @cancellable: a #GCancellable
+ * @cancellable: (allow-none): a #GCancellable
* @error: a #GError, or %NULL
*
* Opens a file for reading. The result is a #GFileInputStream that
* g_file_append_to:
* @file: input #GFile.
* @flags: a set of #GFileCreateFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Gets an output stream for appending data to the file. If
* g_file_create:
* @file: input #GFile.
* @flags: a set of #GFileCreateFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Creates a new file and returns an output stream for writing to it.
* current #GFile, or #NULL to ignore.
* @make_backup: %TRUE if a backup should be created.
* @flags: a set of #GFileCreateFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Returns an output stream for overwriting the file, possibly
/**
* g_file_open_readwrite:
* @file: #GFile to open
- * @cancellable: a #GCancellable
+ * @cancellable: (allow-none): a #GCancellable
* @error: a #GError, or %NULL
*
* Opens an existing file for reading and writing. The result is
* g_file_create_readwrite:
* @file: a #GFile
* @flags: a set of #GFileCreateFlags
- * @cancellable: optional #GCancellable object, %NULL to ignore
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
* @error: return location for a #GError, or %NULL
*
* Creates a new file and returns a stream for reading and writing to it.
* current #GFile, or #NULL to ignore
* @make_backup: %TRUE if a backup should be created
* @flags: a set of #GFileCreateFlags
- * @cancellable: optional #GCancellable object, %NULL to ignore
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
* @error: return location for a #GError, or %NULL
*
* Returns an output stream for overwriting the file in readwrite mode,
* @file: input #GFile
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously opens @file for reading.
*
* @flags: a set of #GFileCreateFlags.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously opens @file for appending.
*
* @flags: a set of #GFileCreateFlags.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously creates a new file and returns an output stream for writing to it.
* The file must not already exist.
* @flags: a set of #GFileCreateFlags.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously overwrites the file, replacing the contents, possibly
* creating a backup copy of the file first.
* @file: input #GFile.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously opens @file for reading and writing.
*
* @flags: a set of #GFileCreateFlags
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request
- * @cancellable: optional #GCancellable object, %NULL to ignore
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously creates a new file and returns a stream for reading and
* writing to it. The file must not already exist.
* @flags: a set of #GFileCreateFlags.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously overwrites the file in read-write mode, replacing the
* contents, possibly creating a backup copy of the file first.
* @source: a #GFile with attributes.
* @destination: a #GFile to copy attributes to.
* @flags: a set of #GFileCopyFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, %NULL to ignore.
*
* Copies the file attributes from @source to @destination.
* @source: input #GFile.
* @destination: destination #GFile
* @flags: set of #GFileCopyFlags
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @progress_callback: function to callback with progress information
- * @progress_callback_data: user data to pass to @progress_callback
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
+ * @progress_callback: (allow-none) (scope call): function to callback with
+ * progress information, or %NULL if progress information is not needed
+ * @progress_callback_data: (closure): user data to pass to @progress_callback
* @error: #GError to set on error, or %NULL
*
* Copies the file @source to the location specified by @destination.
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
- * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
- *
+ * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
+ *
* If @progress_callback is not %NULL, then the operation can be monitored by
* setting this to a #GFileProgressCallback function. @progress_callback_data
* will 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 @source file does not exist then the G_IO_ERROR_NOT_FOUND
* error is returned, independent on the status of the @destination.
*
* error is returned. If trying to overwrite a directory with a directory the
* G_IO_ERROR_WOULD_MERGE error is returned.
*
- * If the source is a directory and the target does not exist, or #G_FILE_COPY_OVERWRITE is
- * specified and the target is a file, then the G_IO_ERROR_WOULD_RECURSE error
- * is returned.
+ * If the source is a directory and the target does not exist, or
+ * #G_FILE_COPY_OVERWRITE is specified and the target is a file, then the
+ * G_IO_ERROR_WOULD_RECURSE error is returned.
*
* If you are interested in copying the #GFile object itself (not the on-disk
* file), see g_file_dup().
}
/**
- * g_file_copy_async:
+ * g_file_copy_async: (skip)
* @source: input #GFile.
* @destination: destination #GFile
* @flags: set of #GFileCopyFlags
- * @io_priority: the <link linkend="io-priority">I/O priority</link>
- * of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @progress_callback: function to callback with progress information
- * @progress_callback_data: user data to pass to @progress_callback
+ * @io_priority: the <link linkend="io-priority">I/O priority</link>
+ * of the request
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
+ * @progress_callback: (allow-none): function to callback with progress
+ * information, or %NULL if progress information is not needed
+ * @progress_callback_data: (closure): user data to pass to @progress_callback
* @callback: a #GAsyncReadyCallback to call when the request is satisfied
* @user_data: the data to pass to callback function
*
- * Copies the file @source to the location specified by @destination
+ * Copies the file @source to the location specified by @destination
* asynchronously. For details of the behaviour, see g_file_copy().
*
* If @progress_callback is not %NULL, then that function that will be called
* @source: #GFile pointing to the source location.
* @destination: #GFile pointing to the destination location.
* @flags: set of #GFileCopyFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @progress_callback: #GFileProgressCallback function for updates.
- * @progress_callback_data: gpointer to user data for the callback function.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @progress_callback: (scope call): #GFileProgressCallback function for updates.
+ * @progress_callback_data: (closure): gpointer to user data for the callback function.
* @error: #GError for returning error conditions, or %NULL
*
*
/**
* g_file_make_directory
* @file: input #GFile.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Creates a directory. Note that this will only create a child directory of
/**
* g_file_make_directory_with_parents:
* @file: input #GFile.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* 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, setting @error to %G_IO_ERROR_NOT_SUPPORTED.
+ * function will fail, setting @error to %G_IO_ERROR_NOT_SUPPORTED. If the
+ * directory itself already exists, this function will fail setting @error
+ * to %G_IO_ERROR_EXISTS, unlike the similar g_mkdir_with_parents().
*
* For a local #GFile the newly created directories will have the default
* (current) ownership and permissions of the current process.
* g_file_make_symbolic_link:
* @file: a #GFile with the name of the symlink to create
* @symlink_value: a string with the path for the target of the new symlink
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError.
*
* Creates a symbolic link named @file which contains the string
/**
* g_file_delete:
* @file: input #GFile.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Deletes a file. If the @file is a directory, it will only be deleted if it
/**
* g_file_trash:
* @file: #GFile to send to trash.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sends @file to the "Trashcan", if possible. This is similar to
* g_file_set_display_name:
* @file: input #GFile.
* @display_name: a string.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Renames @file to the specified display name.
* @display_name: a string.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data: (closure): the data to pass to callback function
*
* Asynchronously sets the display name for a given #GFile.
*
/**
* g_file_query_settable_attributes:
* @file: input #GFile.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Obtain the list of settable attributes for the file.
/**
* g_file_query_writable_namespaces:
* @file: input #GFile.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Obtain the list of attribute namespaces where new attributes
* @file: input #GFile.
* @attribute: a string containing the attribute's name.
* @type: The type of the attribute
- * @value_p: a pointer to the value (or the pointer itself if the type is a pointer type)
+ * @value_p: (allow-none): a pointer to the value (or the pointer itself if the type is a pointer type)
* @flags: a set of #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sets an attribute in the file with attribute name @attribute to @value.
+ *
+ * Some attributes can be unset by setting @attribute to
+ * %G_FILE_ATTRIBUTE_TYPE_INVALID and @value_p to %NULL.
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* @file: input #GFile.
* @info: a #GFileInfo.
* @flags: #GFileQueryInfoFlags
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Tries to set all attributes in the #GFileInfo on the target values,
* @flags: a #GFileQueryInfoFlags.
* @io_priority: the <link linkend="io-priority">I/O priority</link>
* of the request.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback.
- * @user_data: a #gpointer.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback.
+ * @user_data: (closure): a #gpointer.
*
* Asynchronously sets the attributes of @file with @info.
*
* @attribute: a string containing the attribute's name.
* @value: a string containing the attribute's value.
* @flags: #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_STRING to @value.
* @attribute: a string containing the attribute's name.
* @value: a string containing the attribute's new value.
* @flags: a #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to @value.
* @attribute: a string containing the attribute's name.
* @value: a #guint32 containing the attribute's new value.
* @flags: a #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT32 to @value.
* @attribute: a string containing the attribute's name.
* @value: a #gint32 containing the attribute's new value.
* @flags: a #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT32 to @value.
* @attribute: a string containing the attribute's name.
* @value: a #guint64 containing the attribute's new value.
* @flags: a #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT64 to @value.
* @attribute: a string containing the attribute's name.
* @value: a #guint64 containing the attribute's new value.
* @flags: a #GFileQueryInfoFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL
*
* Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT64 to @value.
* @file: input #GFile.
* @flags: flags affecting the operation
* @mount_operation: a #GMountOperation, or %NULL to avoid user interaction.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
+ * @user_data: (closure): the data to pass to callback function
*
* Mounts a file of type G_FILE_TYPE_MOUNTABLE.
* Using @mount_operation, you can request callbacks when, for instance,
* g_file_unmount_mountable:
* @file: input #GFile.
* @flags: flags affecting the operation
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
+ * @user_data: (closure): the data to pass to callback function
*
* Unmounts a file of type G_FILE_TYPE_MOUNTABLE.
*
* @file: input #GFile.
* @flags: flags affecting the operation
* @mount_operation: a #GMountOperation, or %NULL to avoid user interaction.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
+ * @user_data: (closure): the data to pass to callback function
*
* Unmounts a file of type G_FILE_TYPE_MOUNTABLE.
*
* g_file_eject_mountable:
* @file: input #GFile.
* @flags: flags affecting the operation
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
+ * @user_data: (closure): the data to pass to callback function
*
* Starts an asynchronous eject on a mountable.
* When this operation has completed, @callback will be called with
* @file: input #GFile.
* @flags: flags affecting the operation
* @mount_operation: a #GMountOperation, or %NULL to avoid user interaction.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
- * @callback: a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
- * @user_data: the data to pass to callback function
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
+ * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied, or %NULL.
+ * @user_data: (closure): the data to pass to callback function
*
* Starts an asynchronous eject on a mountable.
* When this operation has completed, @callback will be called with
* g_file_monitor_directory:
* @file: input #GFile.
* @flags: a set of #GFileMonitorFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL.
*
* Obtains a directory monitor for the given file.
* g_file_monitor_file:
* @file: input #GFile.
* @flags: a set of #GFileMonitorFlags.
- * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
* @error: a #GError, or %NULL.
*
* Obtains a file monitor for the given file. If no file notification
* g_file_monitor:
* @file: input #GFile
* @flags: a set of #GFileMonitorFlags
- * @cancellable: optional #GCancellable object, %NULL to ignore
+ * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
* @error: a #GError, or %NULL
*
* Obtains a file or directory monitor for the given file, depending
info = g_file_query_info (G_FILE (object), data->attributes, data->flags, cancellable, &error);
if (info == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
data->info = info;
}
info = g_file_query_filesystem_info (G_FILE (object), data->attributes, cancellable, &error);
if (info == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
data->info = info;
}
enumerator = g_file_enumerate_children (G_FILE (object), data->attributes, data->flags, cancellable, &error);
if (enumerator == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
data->enumerator = enumerator;
}
G_IO_ERROR_NOT_SUPPORTED,
_("Operation not supported"));
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
+ g_simple_async_result_take_error (res, error);
return;
}
stream = iface->read_fn (G_FILE (object), cancellable, &error);
if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
stream = iface->append_to (G_FILE (object), *data, cancellable, &error);
if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
stream = iface->create (G_FILE (object), *data, cancellable, &error);
if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
&error);
if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
data->stream = stream;
}
G_IO_ERROR_NOT_SUPPORTED,
_("Operation not supported"));
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
+ g_simple_async_result_take_error (res, error);
return;
}
stream = iface->open_readwrite (G_FILE (object), cancellable, &error);
if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
G_IO_ERROR_NOT_SUPPORTED,
_("Operation not supported"));
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
+ g_simple_async_result_take_error (res, error);
return;
}
stream = iface->create_readwrite (G_FILE (object), *data, cancellable, &error);
if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
}
&error);
if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
data->stream = stream;
}
file = g_file_set_display_name (G_FILE (object), data->name, cancellable, &error);
if (file == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
data->file = file;
}
mount = g_file_find_enclosing_mount (G_FILE (object), cancellable, &error);
if (mount == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
else
g_simple_async_result_set_op_res_gpointer (res, mount, (GDestroyNotify)g_object_unref);
}
NULL, NULL);
if (!result)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
+ g_simple_async_result_take_error (res, error);
g_simple_async_result_complete_in_idle (res);
* fails, but the returned object might not support any I/O
* operation if @path is malformed.
*
- * Returns: (transfer full): a new #GFile for the given @path.
+ * Returns: (transfer full): a new #GFile for the given @path.
+ * Free the returned object with g_object_unref().
**/
GFile *
g_file_new_for_path (const char *path)
* operation if @uri is malformed or if the uri type is
* not supported.
*
- * Returns: (transfer full): a #GFile for the given @uri.
+ * Returns: (transfer full): a new #GFile for the given @uri.
+ * Free the returned object with g_object_unref().
**/
GFile *
g_file_new_for_uri (const char *uri)
return g_vfs_get_file_for_uri (g_vfs_get_default (), uri);
}
-
+
+/**
+ * g_file_new_tmp:
+ * @tmpl: (type filename) (allow-none): Template for the file
+ * name, as in g_file_open_tmp(), or %NULL for a default template.
+ * @iostream: (out): on return, a #GFileIOStream for the created file.
+ * @error: a #GError, or %NULL
+ *
+ * Opens a file in the preferred directory for temporary files (as
+ * returned by g_get_tmp_dir()) and returns a #GFile and
+ * #GFileIOStream pointing to it.
+ *
+ * @template should be a string in the GLib file name encoding
+ * containing a sequence of six 'X' characters, and containing no
+ * directory components. If it is %NULL, a default template is used.
+ *
+ * Unlike the other #GFile constructors, this will return %NULL if
+ * a temporary file could not be created.
+ *
+ * Returns: (transfer full): a new #GFile.
+ * Free the returned object with g_object_unref().
+ **/
+GFile *
+g_file_new_tmp (const char *tmpl,
+ GFileIOStream **iostream,
+ GError **error)
+{
+ gint fd;
+ gchar *path;
+ GFile *file;
+ GFileOutputStream *output;
+
+ g_return_val_if_fail (tmpl != NULL, NULL);
+ g_return_val_if_fail (iostream != NULL, NULL);
+
+ fd = g_file_open_tmp (tmpl, &path, error);
+ if (fd == -1)
+ return NULL;
+
+ file = g_file_new_for_path (path);
+
+ output = _g_local_file_output_stream_new (fd);
+ *iostream = _g_local_file_io_stream_new (G_LOCAL_FILE_OUTPUT_STREAM (output));
+
+ g_object_unref (output);
+ g_free (path);
+
+ return file;
+}
+
/**
* g_file_parse_name:
* @parse_name: a file name or path to be parsed.
* This operation never fails, but the returned object might not support any
* I/O operation if @arg points to a malformed path.
*
- * Returns: (transfer full): a new #GFile.
+ * Returns: (transfer full): a new #GFile.
+ * Free the returned object with g_object_unref().
**/
GFile *
g_file_new_for_commandline_arg (const char *arg)
content_type = g_file_info_get_content_type (info);
if (content_type)
{
- /* Don't use is_native(), as we want to support fuse paths if availible */
+ /* Don't use is_native(), as we want to support fuse paths if available */
path = g_file_get_path (file);
appinfo = g_app_info_get_default_for_type (content_type,
path == NULL);
* g_file_load_contents:
* @file: input #GFile.
* @cancellable: optional #GCancellable object, %NULL to ignore.
- * @contents: (out) (transfer full): a location to place the contents of the file.
+ * @contents: (out) (transfer full) (element-type guint8) (array length=length): a location to place the contents of the file.
* @length: (out) (allow-none): a location to place the length of the contents of the file,
* or %NULL if the length is not needed
* @etag_out: (out) (allow-none): a location to place the current entity tag for the file,
}
else
{
- res = g_simple_async_result_new_from_error (G_OBJECT (data->file),
+ res = g_simple_async_result_new_take_error (G_OBJECT (data->file),
data->callback,
data->user_data,
error);
g_simple_async_result_complete (res);
- g_error_free (error);
load_contents_data_free (data);
g_object_unref (res);
}
}
/**
- * g_file_load_partial_contents_async:
+ * g_file_load_partial_contents_async: (skip)
* @file: input #GFile.
* @cancellable: optional #GCancellable object, %NULL to ignore.
* @read_more_callback: a #GFileReadMoreCallback to receive partial data and to specify whether further data should be read.
* g_file_load_partial_contents_finish:
* @file: input #GFile.
* @res: a #GAsyncResult.
- * @contents: (out) (transfer full): a location to place the contents of the file.
+ * @contents: (out) (transfer full) (element-type guint8) (array length=length): a location to place the contents of the file.
* @length: (out) (allow-none): a location to place the length of the contents of the file,
* or %NULL if the length is not needed
* @etag_out: (out) (allow-none): a location to place the current entity tag for the file,
* g_file_load_contents_finish:
* @file: input #GFile.
* @res: a #GAsyncResult.
- * @contents: (out) (transfer full): a location to place the contents of the file.
+ * @contents: (out) (transfer full) (element-type guint8) (array length=length): a location to place the contents of the file.
* @length: (out) (allow-none): a location to place the length of the contents of the file,
* or %NULL if the length is not needed
* @etag_out: (out) (allow-none): a location to place the current entity tag for the file,
/**
* g_file_replace_contents:
* @file: input #GFile.
- * @contents: a string containing the new contents for @file.
+ * @contents: (element-type guint8) (array length=length): a string containing the new contents for @file.
* @length: the length of @contents in bytes.
* @etag: (allow-none): the old <link linkend="gfile-etag">entity tag</link>
* for the document, or %NULL
}
else
{
- res = g_simple_async_result_new_from_error (G_OBJECT (data->file),
+ res = g_simple_async_result_new_take_error (G_OBJECT (data->file),
data->callback,
data->user_data,
error);
g_simple_async_result_complete (res);
- g_error_free (error);
replace_contents_data_free (data);
g_object_unref (res);
}
/**
* g_file_replace_contents_async:
* @file: input #GFile.
- * @contents: string of contents to replace the file with.
+ * @contents: (element-type guint8) (array length=length): string of contents to replace the file with.
* @length: the length of @contents in bytes.
* @etag: (allow-none): a new <link linkend="gfile-etag">entity tag</link> for the @file, or %NULL
* @make_backup: %TRUE if a backup should be created.