glibmm r522 - in trunk: . gio/src tools/m4
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glibmm r522 - in trunk: . gio/src tools/m4
- Date: Fri, 18 Jan 2008 09:46:47 +0000 (GMT)
Author: murrayc
Date: Fri Jan 18 09:46:46 2008
New Revision: 522
URL: http://svn.gnome.org/viewvc/glibmm?rev=522&view=rev
Log:
2008-01-18 Murray Cumming <murrayc murrayc com>
* gio/src/drive.ccg:
* gio/src/drive.hg: poll_for_media(): Added documentation.
Wrapped 2 vfuncs (though the .defs still need to be written).
* gio/src/file.ccg:
* gio/src/file.hg: move(), copy(), replace(): Rearranged the parameters so we
can have default values, and added some documentation.
set_display_name(), set_display_name_async(): Take a ustring instead
of a std::string. Added documentation.
* gio/src/fileattribute.ccg:
* gio/src/fileattribute.hg: Added FileAttributeInfoList::add().
Added FileAttributeInfoList::empty().
* tools/m4/convert_gio.m4:
* gio/src/appinfo.hg:
* gio/src/fileenumerator.hg: Move the ListHandle conversions to the
.hg files because the ownership is specific to each use.
Modified:
trunk/ChangeLog
trunk/gio/src/appinfo.hg
trunk/gio/src/drive.ccg
trunk/gio/src/drive.hg
trunk/gio/src/file.ccg
trunk/gio/src/file.hg
trunk/gio/src/fileattribute.ccg
trunk/gio/src/fileattribute.hg
trunk/gio/src/fileenumerator.hg
trunk/tools/m4/convert_gio.m4
Modified: trunk/gio/src/appinfo.hg
==============================================================================
--- trunk/gio/src/appinfo.hg (original)
+++ trunk/gio/src/appinfo.hg Fri Jan 18 09:46:46 2008
@@ -54,8 +54,10 @@
public:
_WRAP_CREATE()
+#m4 _CONVERSION(`const Glib::ListHandle<std::string>&',`GList*',`$3.data()')
_WRAP_METHOD(std::string get_display(const Glib::RefPtr<AppInfo>& info, const Glib::ListHandle<std::string>& files),
g_app_launch_context_get_display)
+
_WRAP_METHOD(std::string get_startup_notify_id(const Glib::RefPtr<AppInfo>& info, const Glib::ListHandle<std::string>& files),
g_app_launch_context_get_startup_notify_id)
_WRAP_METHOD(void launch_failed(const std::string& startup_notify_id),
Modified: trunk/gio/src/drive.ccg
==============================================================================
--- trunk/gio/src/drive.ccg (original)
+++ trunk/gio/src/drive.ccg Fri Jan 18 09:46:46 2008
@@ -23,6 +23,7 @@
namespace {
+//A generic proxy for AsynReady callbacks, taking a SlotAsyncReady in the data:
static void
SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data)
{
Modified: trunk/gio/src/drive.hg
==============================================================================
--- trunk/gio/src/drive.hg (original)
+++ trunk/gio/src/drive.hg Fri Jan 18 09:46:46 2008
@@ -86,11 +86,19 @@
g_drive_eject_finish,
errthrow)
- //TODO: Documentation:
+ /** Polls drive to see if media has been inserted or removed.
+ * @param slot A callback which will be called when the poll is completed.
+ * @param cancellable A cancellable object which can be used to cancel the operation.
+ */
void poll_for_media(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
+ /** Polls drive to see if media has been inserted or removed.
+ * @param slot A callback which will be called when the poll is completed.
+ */
void poll_for_media(const SlotAsyncReady& slot);
+ /** Polls drive to see if media has been inserted or removed.
+ */
void poll_for_media();
_IGNORE(g_drive_poll_for_media)
@@ -100,9 +108,9 @@
/* vfuncs */
- _WRAP_VFUNC(Glib::ustring get_name() const, "get_name")
- // TODO: get_icon (when we wrap GIcon)
- _WRAP_VFUNC(bool has_volumes() const, "has_volumes")
+ _WRAP_VFUNC(Glib::ustring get_name() const, get_name)
+ //TODO: Careful of ref-countign: _WRAP_VFUNC(Glib::RefPtr<Icon> get_icon() const, get_icon)
+ _WRAP_VFUNC(bool has_volumes() const, has_volumes)
//TODO: finish
};
Modified: trunk/gio/src/file.ccg
==============================================================================
--- trunk/gio/src/file.ccg (original)
+++ trunk/gio/src/file.ccg Fri Jan 18 09:46:46 2008
@@ -73,10 +73,8 @@
delete the_slot;
}
-// TODO: here it is supposed that the callback is invoked multiple times.
-// If not, then it should be deleted here, not in async_packed_callback.
static gboolean
-SignalProxy_read_more_callback(const char* file_contents, goffset file_size, gpointer data)
+SignalProxy_load_partial_contents_read_more_callback(const char* file_contents, goffset file_size, gpointer data)
{
LoadPartialSlots* slot_pair = static_cast<LoadPartialSlots*>(data);
Gio::File::SlotReadMore* the_slot = slot_pair->first;
@@ -105,7 +103,7 @@
// the slot is packed in a pair. The operation is assumed to be finished
// after the callback is triggered, so we delete that pair here.
static void
-SignalProxy_async_packed_callback(GObject*, GAsyncResult* res, void* data)
+SignalProxy_load_partial_contents_ready_callback(GObject*, GAsyncResult* res, void* data)
{
LoadPartialSlots* slot_pair = static_cast<LoadPartialSlots*>(data);
Gio::SlotAsyncReady* the_slot = slot_pair->second;
@@ -367,8 +365,30 @@
slot_copy);
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<File> File::set_display_name(const Glib::ustring& display_name)
+#else
+Glib::RefPtr<File> File::set_display_name(const Glib::ustring& display_name, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<File> retvalue = Glib::wrap(g_file_set_display_name(gobj(), display_name.c_str(), NULL, &(gerror)));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+#else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ if(retvalue)
+ retvalue->reference(); //The function does not do a ref for us.
+ return retvalue;
+
+}
+
void
-File::set_display_name_async(const std::string& display_name, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority)
+File::set_display_name_async(const Glib::ustring& display_name, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority)
{
// Create a copy of the slot.
// A pointer to it will be passed through the callback's data parameter
@@ -384,7 +404,7 @@
}
void
-File::set_display_name_async(const std::string& display_name, const SlotAsyncReady& slot, int io_priority)
+File::set_display_name_async(const Glib::ustring& display_name, const SlotAsyncReady& slot, int io_priority)
{
// Create a copy of the slot.
// A pointer to it will be passed through the callback's data parameter
@@ -401,17 +421,10 @@
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool
-File::copy(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const Glib::RefPtr<Cancellable>& cancellable,
- const SlotFileProgress& slot)
+File::copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags)
#else
bool
-File::copy(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const Glib::RefPtr<Cancellable>& cancellable,
- const SlotFileProgress& slot,
- std::auto_ptr<Glib::Error>& error)
+File::copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error)
#endif // GLIBMM_EXCEPTIONS_ENABLED
{
GError* gerror = 0;
@@ -443,16 +456,11 @@
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool
-File::copy(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const SlotFileProgress& slot)
+File::copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags)
#else
bool
-File::copy(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const SlotFileProgress& slot,
- std::auto_ptr<Glib::Error>& error)
-#endif //GLIBMM_EXCEPTIONS_ENABLED
+File::copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif // GLIBMM_EXCEPTIONS_ENABLED
{
GError* gerror = 0;
bool res;
@@ -483,17 +491,38 @@
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool
-File::move(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const Glib::RefPtr<Cancellable>& cancellable,
- const SlotFileProgress& slot)
+File::copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags)
#else
bool
-File::move(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const Glib::RefPtr<Cancellable>& cancellable,
- const SlotFileProgress& slot,
- std::auto_ptr<Glib::Error>& error)
+File::copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ bool res = g_file_copy(gobj(),
+ destination->gobj(),
+ static_cast<GFileCopyFlags>(flags),
+ NULL,
+ NULL,
+ NULL,
+ &gerror);
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if (gerror)
+ ::Glib::Error::throw_exception(gerror);
+#else
+ if (gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ return res;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool
+File::move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags)
+#else
+bool
+File::move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error)
#endif // GLIBMM_EXCEPTIONS_ENABLED
{
GError* gerror = 0;
@@ -525,16 +554,11 @@
#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool
-File::move(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const SlotFileProgress& slot)
+File::move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags)
#else
bool
-File::move(const Glib::RefPtr<File>& destination,
- FileCopyFlags flags,
- const SlotFileProgress& slot,
- std::auto_ptr<Glib::Error>& error)
-#endif //GLIBMM_EXCEPTIONS_ENABLED
+File::move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif // GLIBMM_EXCEPTIONS_ENABLED
{
GError* gerror = 0;
bool res;
@@ -563,6 +587,36 @@
return res;
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+bool
+File::move(const Glib::RefPtr<File>& destination, FileCopyFlags flags)
+#else
+bool
+File::move(const Glib::RefPtr<File>& destination, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ bool res;
+
+ res = g_file_move(gobj(),
+ destination->gobj(),
+ static_cast<GFileCopyFlags>(flags),
+ NULL,
+ NULL,
+ NULL,
+ &gerror);
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if (gerror)
+ ::Glib::Error::throw_exception(gerror);
+#else
+ if (gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ return res;
+}
+
void
File::set_attributes_async(const Glib::RefPtr<FileInfo>& info, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, FileQueryInfoFlags flags, int io_priority)
{
@@ -782,6 +836,7 @@
File::load_partial_contents_async(const SlotReadMore& slot_read_more, const SlotAsyncReady& slot_async_ready, const Glib::RefPtr<Cancellable>& cancellable)
{
// Create a new pair which will hold copies of passed slots.
+ // This will be deleted in the SignalProxy_load_partial_contents_ready_callback() callback
LoadPartialSlots* slots = new LoadPartialSlots();
SlotReadMore* slot_read_more_copy = new SlotReadMore(slot_read_more);
SlotAsyncReady* slot_async_copy = new SlotAsyncReady(slot_async_ready);
@@ -791,8 +846,8 @@
g_file_load_partial_contents_async(gobj(),
cancellable->gobj(),
- &SignalProxy_read_more_callback,
- &SignalProxy_async_packed_callback,
+ &SignalProxy_load_partial_contents_read_more_callback,
+ &SignalProxy_load_partial_contents_ready_callback,
slots);
}
@@ -801,6 +856,7 @@
const SlotAsyncReady& slot_async_ready)
{
// Create a new pair which will hold copies of passed slots.
+ // This will be deleted in the SignalProxy_load_partial_contents_ready_callback() callback
LoadPartialSlots* slots = new LoadPartialSlots();
SlotReadMore* slot_read_more_copy = new SlotReadMore(slot_read_more);
SlotAsyncReady* slot_async_copy = new SlotAsyncReady(slot_async_ready);
@@ -810,8 +866,8 @@
g_file_load_partial_contents_async(gobj(),
NULL,
- &SignalProxy_read_more_callback,
- &SignalProxy_async_packed_callback,
+ &SignalProxy_load_partial_contents_read_more_callback,
+ &SignalProxy_load_partial_contents_ready_callback,
slots);
}
@@ -864,4 +920,46 @@
slot_copy);
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<FileOutputStream> File::replace(const Glib::RefPtr<Cancellable>& cancellable, const std::string& etag, bool make_backup, FileCreateFlags flags)
+#else
+Glib::RefPtr<FileOutputStream> File::replace(const Glib::RefPtr<Cancellable>& cancellable, const std::string& etag, bool make_backup, FileCreateFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<FileOutputStream> retvalue = Glib::wrap(g_file_replace(gobj(), etag.c_str(), static_cast<int>(make_backup), ((GFileCreateFlags)(flags)), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &(gerror)));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+#else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ if(retvalue)
+ retvalue->reference(); //The function does not do a ref for us.
+ return retvalue;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<FileOutputStream> File::replace(const std::string& etag, bool make_backup, FileCreateFlags flags)
+#else
+Glib::RefPtr<FileOutputStream> File::replace(const std::string& etag, bool make_backup, FileCreateFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<FileOutputStream> retvalue = Glib::wrap(g_file_replace(gobj(), etag.c_str(), static_cast<int>(make_backup), ((GFileCreateFlags)(flags)), NULL, &(gerror)));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+#else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ if(retvalue)
+ retvalue->reference(); //The function does not do a ref for us.
+ return retvalue;
+}
+
} // namespace Gio
Modified: trunk/gio/src/file.hg
==============================================================================
--- trunk/gio/src/file.hg (original)
+++ trunk/gio/src/file.hg Fri Jan 18 09:46:46 2008
@@ -79,8 +79,6 @@
_IGNORE(g_file_new_for_commandline_arg)
_IGNORE(g_file_parse_name)
-//TODO: Documentation for the methods.
-
// Although this is an interface, it is possible to create objects using
// its static create* members. In the implementation, these would lead
// to functions of the default GVfs implementation, which, in case of
@@ -169,9 +167,24 @@
g_file_read,
refreturn, constversion, errthrow)
- //TODO: Documentation:
- void read_async(const SlotAsyncReady& slot, int io_priority = G_PRIORITY_DEFAULT);
+ /** Asynchronously opens the file for reading.
+ * For more details, see read() which is the synchronous version of this call.
+ * When the operation is finished, @a slot will be called. You can then call read_finish() to get the result of the operation.
+ *
+ * @param slot A callback slot which will be called when the request is satisfied.
+ * @param cancellable A Cancellable object which can be used to cancel the operation.
+ * @param io_priority The I/O priority of the request.
+ */
void read_async(const SlotAsyncReady& slot, Glib::RefPtr<Cancellable>& cancellable, int io_priority = G_PRIORITY_DEFAULT);
+
+ /** Asynchronously opens the file for reading.
+ * For more details, see read() which is the synchronous version of this call.
+ * When the operation is finished, @a slot will be called. You can then call read_finish() to get the result of the operation.
+ *
+ * @param slot A callback slot which will be called when the request is satisfied.
+ * @param io_priority The I/O priority of the request.
+ */
+ void read_async(const SlotAsyncReady& slot, int io_priority = G_PRIORITY_DEFAULT);
_IGNORE(g_file_read_async)
_WRAP_METHOD(Glib::RefPtr<FileInputStream> read_finish(const Glib::RefPtr<AsyncResult>& result),
@@ -187,13 +200,87 @@
g_file_create,
refreturn, errthrow)
- // TODO: see what etags are for. It seems that it can be null.
- _WRAP_METHOD(Glib::RefPtr<FileOutputStream> replace(const std::string& etag, bool make_backup, FileCreateFlags flags, const Glib::RefPtr<Cancellable>& cancellable),
- g_file_replace,
- refreturn, errthrow)
+
+ //TODO: Rephrase this documentation in terms of _throwing_ exceptions instead of returning errors. And what exception is thrown?
+
+ /** Returns an output stream for overwriting the file, possibly creating a backup copy of the file first.
+ * 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 FILE_CREATE_PRIVATE in
+ * @a flags the file will be made readable only to the current user, to the level that is supported on the
+ * target filesystem.
+ *
+ * The operation can be cancelled by triggering the cancellable object from another thread.
+ * If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.
+ *
+ * If you pass in an etag value, then this value is compared to the current entity tag of the file,
+ * and if they differ an IO_ERROR_WRONG_ETAG error is returned. This generally means that the file has
+ * been changed since you last read it. You can get the new etag from FileOutputStream::get_etag()
+ * after you've finished writing and closed the FileOutputStream. When you load a new file you can
+ * use FileInputStream::query_info() to get the etag of the file.
+ *
+ * If @a make_backup is true, this function will attempt to make a backup of the current file before
+ * overwriting it. If this fails a IO_ERROR_CANT_CREATE_BACKUP error will be returned. If you want to replace
+ * anyway, try again with @a make_backup set to false.
+ *
+ * If the file is a directory the IO_ERROR_IS_DIRECTORY error will be returned, and if the file is some
+ * other form of non-regular file then a IO_ERROR_NOT_REGULAR_FILE error will be returned. Some file
+ * systems don't allow all file names, and may return an IO_ERROR_INVALID_FILENAME error, and if the
+ * name is to long IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are possible too, and
+ * depend on what kind of filesystem the file is on.
+ *
+ * @param etag An optional entity tag for the current Glib::File.
+ * @param make_backup <tt>true</tt> if a backup should be created.
+ * @param flags A set of FileCreateFlags.
+ * @return A FileOutputStream.
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<FileOutputStream> replace(const Glib::RefPtr<Cancellable>& cancellable, const std::string& etag = std::string(), bool make_backup = false, FileCreateFlags flags = FILE_CREATE_NONE);
+#else
+ Glib::RefPtr<FileOutputStream> replace(const Glib::RefPtr<Cancellable>& cancellable, const std::string& etag, bool make_backup, FileCreateFlags flags, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
- //TODO: Rearrange the parameters (and in all the other similar functions) so we can have default paramter values?
+ /** Returns an output stream for overwriting the file, possibly creating a backup copy of the file first.
+ * 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 FILE_CREATE_PRIVATE in
+ * @a flags the file will be made readable only to the current user, to the level that is supported on the
+ * target filesystem.
+ *
+ * If you pass in an etag value, then this value is compared to the current entity tag of the file,
+ * and if they differ an IO_ERROR_WRONG_ETAG error is returned. This generally means that the file has
+ * been changed since you last read it. You can get the new etag from FileOutputStream::get_etag()
+ * after you've finished writing and closed the FileOutputStream. When you load a new file you can
+ * use FileInputStream::query_info() to get the etag of the file.
+ *
+ * If @a make_backup is true, this function will attempt to make a backup of the current file before
+ * overwriting it. If this fails a IO_ERROR_CANT_CREATE_BACKUP error will be returned. If you want to replace
+ * anyway, try again with @a make_backup set to false.
+ *
+ * If the file is a directory the IO_ERROR_IS_DIRECTORY error will be returned, and if the file is some
+ * other form of non-regular file then a IO_ERROR_NOT_REGULAR_FILE error will be returned. Some file
+ * systems don't allow all file names, and may return an IO_ERROR_INVALID_FILENAME error, and if the
+ * name is to long IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are possible too, and
+ * depend on what kind of filesystem the file is on.
+ *
+ * @param etag An optional entity tag for the current Glib::File.
+ * @param make_backup <tt>true</tt> if a backup should be created.
+ * @param flags A set of FileCreateFlags.
+ * @return A FileOutputStream.
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<FileOutputStream> replace(const std::string& etag = std::string(), bool make_backup = false, FileCreateFlags flags = FILE_CREATE_NONE);
+#else
+ Glib::RefPtr<FileOutputStream> replace(const std::string& etag, bool make_backup, FileCreateFlags flags, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ _IGNORE(g_file_replace)
+
/** Asynchronously opens the file for appending.
* For more details, see append_to() which is the synchronous version of this call.
@@ -253,8 +340,6 @@
g_file_create_finish,
refreturn, errthrow)
- //TODO: The etag parameter in g_file_replace_sync() can be NULL (documented in g_file_replace()).
-
/** Asyncronously overwrites the file, replacing the contents, possibly creating a backup copy of the file first.
* For more details, see replace() which is the synchronous version of this call.
* When the operation is finished, @a slot will be called. You can then call replace_finish() to get the result of the operation.
@@ -364,10 +449,33 @@
g_file_enumerate_children_finish,
errthrow)
- _WRAP_METHOD(Glib::RefPtr<File> set_display_name(const std::string& display_name, const Glib::RefPtr<Cancellable>& cancellable),
+ _WRAP_METHOD(Glib::RefPtr<File> set_display_name(const Glib::ustring& display_name, const Glib::RefPtr<Cancellable>& cancellable),
g_file_set_display_name,
refreturn, errthrow)
+ /** Renames the file to the specified display name.
+ *
+ * The display name is converted from UTF8 to the correct encoding for the target
+ * filesystem if possible and the 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 set_display_name().
+ *
+ * On success the resulting converted filename is returned.
+ *
+ * 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.
+ *
+ * @param display_name A string.
+ * @return A Glib::File specifying what @a file was renamed to, or an empty RefPtr if there was an error.
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<File> set_display_name(const Glib::ustring& display_name);
+#else
+ Glib::RefPtr<File> set_display_name(const Glib::ustring& display_name, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
//TODO: Use ustring for the display name?
@@ -379,7 +487,7 @@
* @param cancellable A Cancellable object which can be used to cancel the operation.
* @param io_priority The I/O priority of the request.
*/
- void set_display_name_async(const std::string& display_name, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority = G_PRIORITY_DEFAULT);
+ void set_display_name_async(const Glib::ustring& display_name, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority = G_PRIORITY_DEFAULT);
/** Asynchronously sets the display name for a given Gio::File. For the synchronous version of this function, see set_display_name().
* When the operation is finished, @a slot will be called. You can then call set_display_name_finish() to get the result of the operation.
@@ -388,7 +496,7 @@
* @param slot A callback slot which will be called when the request is satisfied.
* @param io_priority The I/O priority of the request.
*/
- void set_display_name_async(const std::string& display_name, const SlotAsyncReady& slot, int io_priority = G_PRIORITY_DEFAULT);
+ void set_display_name_async(const Glib::ustring& display_name, const SlotAsyncReady& slot, int io_priority = G_PRIORITY_DEFAULT);
_IGNORE(g_file_set_display_name_async)
_WRAP_METHOD(Glib::RefPtr<File> set_display_name_finish(const Glib::RefPtr<AsyncResult>& result),
@@ -410,29 +518,84 @@
*/
typedef sigc::slot<void, goffset, goffset> SlotFileProgress;
- //TODO: Documentation:
+ //TODO: Rephrase this in terms of exceptions rather than errors. And what exceptions are thrown?
+ /** Copies the file source to the location specified by destination. Can not handle recursive copies of directories.
+ * If the flag FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten.
+ * If the flag FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.
+ *
+ * The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.
+ *
+ * The operation can be monitored via the @a slot callback.
+ *
+ * If the source file does not exist then the IO_ERROR_NOT_FOUND error is returned, independent on the status of the destination.
+ *
+ * If FILE_COPY_OVERWRITE is not specified and the target exists, then the error IO_ERROR_EXISTS is returned.
+ *
+ * If trying to overwrite a file over a directory the IO_ERROR_IS_DIRECTORY error is returned.
+ * If trying to overwrite a directory with a directory the IO_ERROR_WOULD_MERGE error is returned.
+ *
+ * If the source is a directory and the target does not exist, or FILE_COPY_OVERWRITE is specified and the target is a file,
+ * then the IO_ERROR_WOULD_RECURSE error is returned.
+ *
+ * If you are interested in copying the Gio::File object itself (not the on-disk file), see File::dup().
+ */
#ifdef GLIBMM_EXCEPTIONS_ENABLED
- bool copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotFileProgress& slot);
+ bool copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags = FILE_COPY_NONE);
+#else
+ bool copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags = FILE_COPY_NONE, std::auto_ptr<Glib::Error>& error);
+#endif
- bool copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const SlotFileProgress& slot);
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ bool copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags = FILE_COPY_NONE);
#else
- bool copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotFileProgress& slot, std::auto_ptr<Glib::Error>& error);
+ bool copy(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error);
+#endif
- bool copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const SlotFileProgress& slot, std::auto_ptr<Glib::Error>& error);
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ bool copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags = FILE_COPY_NONE);
+#else
+ bool copy(const Glib::RefPtr<File>& destination, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error);
#endif // GLIBMM_EXCEPTIONS_ENABLED
_IGNORE(g_file_copy)
-
- //TODO: Documentation:
+ //TODO: Rephrase this in terms of exceptions rather than errors. And what exceptions are thrown?
+ /** Tries to move the file or directory source to the location specified by destination. If native move operations are supported then this is
+ * used, otherwise a copy and 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 FILE_COPY_OVERWRITE is specified an already existing destination file is overwritten.
+ *
+ * If the flag FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks will be copied as symlinks, otherwise the target of the source symlink will be copied.
+ *
+ * The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_ERROR_CANCELLED will be returned.
+ *
+ * The operation can be monitored via the @a slot callback.
+ * If the source file does not exist then the IO_ERROR_NOT_FOUND error is returned, independent on the status of the destination.
+ *
+ * If G_FILE_COPY_OVERWRITE is not specified and the target exists, then the error G_IO_ERROR_EXISTS is returned.
+ *
+ * If trying to overwrite a file over a directory the IO_ERROR_IS_DIRECTORY error is returned.
+ * If trying to overwrite a directory with a directory the IO_ERROR_WOULD_MERGE error is returned.
+ *
+ * If the source is a directory and the target does not exist, or FILE_COPY_OVERWRITE is specified and the target is a file, then the IO_ERROR_WOULD_RECURSE error may be returned (if the native move operation isn't available).
+ */
#ifdef GLIBMM_EXCEPTIONS_ENABLED
- bool move(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotFileProgress& slot);
+ bool move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags = FILE_COPY_NONE);
+#else
+ bool move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, const Glib::RefPtr<Cancellable>& cancellable, FileCopyFlags flags = FILE_COPY_NONE, std::auto_ptr<Glib::Error>& error);
+#endif
- bool move(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const SlotFileProgress& slot);
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ bool move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags = FILE_COPY_NONE);
#else
- bool move(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const Glib::RefPtr<Cancellable>& cancellable, const SlotFileProgress& slot, std::auto_ptr<Glib::Error>& error);
+ bool move(const Glib::RefPtr<File>& destination, const SlotFileProgress& slot, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error);
+#endif
- bool move(const Glib::RefPtr<File>& destination, FileCopyFlags flags, const SlotFileProgress& slot, std::auto_ptr<Glib::Error>& error);
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ bool move(const Glib::RefPtr<File>& destination, FileCopyFlags flags = FILE_COPY_NONE);
+#else
+ bool move(const Glib::RefPtr<File>& destination, FileCopyFlags flags, std::auto_ptr<Glib::Error>& error);
#endif // GLIBMM_EXCEPTIONS_ENABLED
_IGNORE(g_file_move)
Modified: trunk/gio/src/fileattribute.ccg
==============================================================================
--- trunk/gio/src/fileattribute.ccg (original)
+++ trunk/gio/src/fileattribute.ccg Fri Jan 18 09:46:46 2008
@@ -69,6 +69,11 @@
// FileAttributeInfoList
+bool FileAttributeInfoList::empty() const
+{
+ return gobj() == 0;
+}
+
FileAttributeInfo
FileAttributeInfoList::lookup(const std::string& name) const
{
Modified: trunk/gio/src/fileattribute.hg
==============================================================================
--- trunk/gio/src/fileattribute.hg (original)
+++ trunk/gio/src/fileattribute.hg Fri Jan 18 09:46:46 2008
@@ -86,19 +86,22 @@
g_file_attribute_info_list_new,
g_file_attribute_info_list_ref,
g_file_attribute_info_list_unref)
+ _IGNORE(g_file_attribute_info_list_new, g_file_attribute_info_list_ref, g_file_attribute_info_list_unref)
public:
- //TODO: Add FileAttributeInfo::empty() or similar so we can represent a NULL GFileAttributeInfo*.
+ /** Whether the FileAttributeInfoList is empty or invalid.
+ * @result true if this FileAttributeInfoList is empty.
+ */
+ bool empty() const;
+
/** Gets the file attribute with the name name from list.
* @param name The name of the attribute to lookup.
* @result A FileAttributeInfo for the name.
*/
FileAttributeInfo lookup(const std::string& name) const;
+ _IGNORE(g_file_attribute_info_list_lookup)
- /*TODO: conversion missing
- _WRAP_METHOD(void add(const std::string& name, FileAttributeType type, FileAttributeInfoFlags flags),
- g_file_attribute_info_list_add)
- */
+ _WRAP_METHOD(void add(const std::string& name, FileAttributeType type, FileAttributeInfoFlags flags = FILE_ATTRIBUTE_INFO_NONE), g_file_attribute_info_list_add)
};
} // namespace Gio
Modified: trunk/gio/src/fileenumerator.hg
==============================================================================
--- trunk/gio/src/fileenumerator.hg (original)
+++ trunk/gio/src/fileenumerator.hg Fri Jan 18 09:46:46 2008
@@ -97,11 +97,10 @@
void next_files_async(const SlotAsyncReady& slot, int num_files = 1, int io_priority = G_PRIORITY_DEFAULT);
_IGNORE(g_file_enumerator_next_files_async)
+#m4 _CONVERSION(`GList*',`Glib::ListHandle< Glib::RefPtr<FileInfo> >',__FL2H_SHALLOW)
_WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<FileInfo> > next_files_finish(const Glib::RefPtr<AsyncResult>& result),
g_file_enumerator_next_files_finish,
errthrow)
- //TODO: next_files_finish: what does the resulting list contain?
- // FileInfo
Modified: trunk/tools/m4/convert_gio.m4
==============================================================================
--- trunk/tools/m4/convert_gio.m4 (original)
+++ trunk/tools/m4/convert_gio.m4 Fri Jan 18 09:46:46 2008
@@ -15,7 +15,6 @@
# AppInfo
_CONVERSION(`GAppInfo*',`Glib::RefPtr<AppInfo>',`Glib::wrap($3)')
-_CONVERSION(`const Glib::ListHandle<std::string>&',`GList*',`$3.data()')
_CONVERSION(`const Glib::RefPtr<AppLaunchContext>&',`GAppLaunchContext*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<AppInfo>&',`GAppInfo*',__CONVERT_REFPTR_TO_P)
@@ -55,7 +54,6 @@
_CONVERSION(`Glib::TimeVal&', `GTimeVal*', static_cast<$2>(&$3))
_CONVERSION(`const Glib::TimeVal&', `GTimeVal*', const_cast<GTimeVal*>(static_cast<const GTimeVal*>(&$3)))
_CONVERSION(`const Glib::RefPtr<FileAttributeMatcher>&',`GFileAttributeMatcher*',__CONVERT_CONST_REFPTR_TO_P)
-_CONVERSION(`GList*',`Glib::ListHandle< Glib::RefPtr<FileInfo> >',__FL2H_SHALLOW)
# FileInputStream
_CONVERSION(`GFileInputStream*',`Glib::RefPtr<FileInputStream>',`Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]