summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@src.gnome.org>2007-09-13 15:05:52 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-13 15:05:52 +0000
commit0e870e06f5176b9d390ae1baa5c31d6b710b2656 (patch)
tree7126a34ccfc2242f38147b95752fc0da4f3a5443
parent2a99e6df916c84e8eecd5df02e7b69210cf0edfc (diff)
downloadgvfs-0e870e06f5176b9d390ae1baa5c31d6b710b2656.tar.gz
Split out gio into its own module
Original git commit by Alexander Larsson <alexl@redhat.com> at 1188826453 +0200 svn path=/trunk/; revision=888
-rw-r--r--Makefile.am14
-rwxr-xr-xautogen.sh2
-rw-r--r--client/Makefile.am3
-rw-r--r--client/gdaemonvfs.c3
-rw-r--r--common/gvfsdaemonprotocol.c4
-rw-r--r--configure.ac201
-rw-r--r--daemon/Makefile.am1
-rw-r--r--daemon/gvfsbackendtest.c6
-rw-r--r--gio/.gitignore13
-rw-r--r--gio/Makefile.am230
-rw-r--r--gio/fam/Makefile.am13
-rw-r--r--gio/fam/fam-helper.c218
-rw-r--r--gio/fam/fam-helper.h12
-rw-r--r--gio/gappinfo.c175
-rw-r--r--gio/gappinfo.h84
-rw-r--r--gio/gasynchelper.c141
-rw-r--r--gio/gasynchelper.h31
-rw-r--r--gio/gasyncresult.c68
-rw-r--r--gio/gasyncresult.h37
-rw-r--r--gio/gbufferedinputstream.c396
-rw-r--r--gio/gbufferedinputstream.h40
-rw-r--r--gio/gbufferedoutputstream.c613
-rw-r--r--gio/gbufferedoutputstream.h40
-rw-r--r--gio/gcancellable.c225
-rw-r--r--gio/gcancellable.h45
-rw-r--r--gio/gcontenttype.c739
-rw-r--r--gio/gcontenttype.h28
-rw-r--r--gio/gcontenttypeprivate.h14
-rw-r--r--gio/gdesktopappinfo.c1678
-rw-r--r--gio/gdesktopappinfo.h30
-rw-r--r--gio/gdirectorymonitor.c403
-rw-r--r--gio/gdirectorymonitor.h52
-rw-r--r--gio/gdirectorymonitorpriv.h15
-rw-r--r--gio/gdrive.c209
-rw-r--r--gio/gdrive.h71
-rw-r--r--gio/gdrivepriv.h12
-rw-r--r--gio/gdummyfile.c561
-rw-r--r--gio/gdummyfile.h29
-rw-r--r--gio/gfile.c2551
-rw-r--r--gio/gfile.h485
-rw-r--r--gio/gfileattribute.c469
-rw-r--r--gio/gfileattribute.h111
-rw-r--r--gio/gfileenumerator.c596
-rw-r--r--gio/gfileenumerator.h113
-rw-r--r--gio/gfileicon.c214
-rw-r--r--gio/gfileicon.h32
-rw-r--r--gio/gfileinfo.c1307
-rw-r--r--gio/gfileinfo.h244
-rw-r--r--gio/gfileinputstream.c227
-rw-r--r--gio/gfileinputstream.h68
-rw-r--r--gio/gfilemonitor.c321
-rw-r--r--gio/gfilemonitor.h61
-rw-r--r--gio/gfilemonitorpriv.h15
-rw-r--r--gio/gfileoutputstream.c345
-rw-r--r--gio/gfileoutputstream.h85
-rw-r--r--gio/gfilterinputstream.c367
-rw-r--r--gio/gfilterinputstream.h38
-rw-r--r--gio/gfilteroutputstream.c347
-rw-r--r--gio/gfilteroutputstream.h38
-rw-r--r--gio/gicon.c75
-rw-r--r--gio/gicon.h36
-rw-r--r--gio/ginputstream.c1113
-rw-r--r--gio/ginputstream.h144
-rw-r--r--gio/gioerror.c127
-rw-r--r--gio/gioerror.h51
-rw-r--r--gio/giomodule.c208
-rw-r--r--gio/giomodule.h30
-rw-r--r--gio/gioscheduler.c312
-rw-r--r--gio/gioscheduler.h33
-rw-r--r--gio/giotypes.h12
-rw-r--r--gio/gloadableicon.c204
-rw-r--r--gio/gloadableicon.h61
-rw-r--r--gio/glocaldirectorymonitor.c213
-rw-r--r--gio/glocaldirectorymonitor.h29
-rw-r--r--gio/glocalfile.c1550
-rw-r--r--gio/glocalfile.h29
-rw-r--r--gio/glocalfileenumerator.c168
-rw-r--r--gio/glocalfileenumerator.h38
-rw-r--r--gio/glocalfileinfo.c1730
-rw-r--r--gio/glocalfileinfo.h45
-rw-r--r--gio/glocalfileinputstream.c291
-rw-r--r--gio/glocalfileinputstream.h38
-rw-r--r--gio/glocalfilemonitor.c161
-rw-r--r--gio/glocalfilemonitor.h29
-rw-r--r--gio/glocalfileoutputstream.c840
-rw-r--r--gio/glocalfileoutputstream.h48
-rw-r--r--gio/glocalvfs.c113
-rw-r--r--gio/glocalvfs.h25
-rw-r--r--gio/gmemoryinputstream.c369
-rw-r--r--gio/gmemoryinputstream.h40
-rw-r--r--gio/gmemoryoutputstream.c608
-rw-r--r--gio/gmemoryoutputstream.h41
-rw-r--r--gio/gmountoperation.c224
-rw-r--r--gio/gmountoperation.h92
-rw-r--r--gio/goutputstream.c883
-rw-r--r--gio/goutputstream.h139
-rw-r--r--gio/gpollfilemonitor.c198
-rw-r--r--gio/gpollfilemonitor.h28
-rw-r--r--gio/gseekable.c100
-rw-r--r--gio/gseekable.h61
-rw-r--r--gio/gsimpleasyncresult.c379
-rw-r--r--gio/gsimpleasyncresult.h98
-rw-r--r--gio/gsocketinputstream.c435
-rw-r--r--gio/gsocketinputstream.h39
-rw-r--r--gio/gsocketoutputstream.c391
-rw-r--r--gio/gsocketoutputstream.h39
-rw-r--r--gio/gthemedicon.c121
-rw-r--r--gio/gthemedicon.h32
-rw-r--r--gio/guniondrive.c274
-rw-r--r--gio/guniondrive.h35
-rw-r--r--gio/gunionvolume.c431
-rw-r--r--gio/gunionvolume.h42
-rw-r--r--gio/gunionvolumemonitor.c468
-rw-r--r--gio/gunionvolumemonitor.h32
-rw-r--r--gio/gunixdrive.c264
-rw-r--r--gio/gunixdrive.h37
-rw-r--r--gio/gunixmounts.c1035
-rw-r--r--gio/gunixmounts.h65
-rw-r--r--gio/gunixvolume.c374
-rw-r--r--gio/gunixvolume.h35
-rw-r--r--gio/gunixvolumemonitor.c307
-rw-r--r--gio/gunixvolumemonitor.h35
-rw-r--r--gio/gvfs-marshal.list4
-rw-r--r--gio/gvfs.c137
-rw-r--r--gio/gvfs.h55
-rw-r--r--gio/gvolume.c214
-rw-r--r--gio/gvolume.h74
-rw-r--r--gio/gvolumemonitor.c104
-rw-r--r--gio/gvolumemonitor.h55
-rw-r--r--gio/gvolumepriv.h12
-rw-r--r--gio/gwin32appinfo.c590
-rw-r--r--gio/gwin32appinfo.h28
-rw-r--r--gio/inotify/Makefile.am25
-rw-r--r--gio/inotify/inotify-diag.c72
-rw-r--r--gio/inotify/inotify-diag.h29
-rw-r--r--gio/inotify/inotify-helper.c262
-rw-r--r--gio/inotify/inotify-helper.h33
-rw-r--r--gio/inotify/inotify-kernel.c676
-rw-r--r--gio/inotify/inotify-kernel.h55
-rw-r--r--gio/inotify/inotify-missing.c167
-rw-r--r--gio/inotify/inotify-missing.h35
-rw-r--r--gio/inotify/inotify-path.c418
-rw-r--r--gio/inotify/inotify-path.h33
-rw-r--r--gio/inotify/inotify-sub.c70
-rw-r--r--gio/inotify/inotify-sub.h38
-rw-r--r--gio/inotify/local_inotify.h113
-rw-r--r--gio/inotify/local_inotify_syscalls.h85
-rwxr-xr-xgio/test-gio.c595
-rw-r--r--gio/test-streams.c370
-rw-r--r--gio/xdgmime/.gitignore1
-rw-r--r--gio/xdgmime/Makefile.am24
-rw-r--r--gio/xdgmime/test-mime.c142
-rw-r--r--gio/xdgmime/xdgmime.c864
-rw-r--r--gio/xdgmime/xdgmime.h120
-rw-r--r--gio/xdgmime/xdgmimealias.c184
-rw-r--r--gio/xdgmime/xdgmimealias.h51
-rw-r--r--gio/xdgmime/xdgmimecache.c909
-rw-r--r--gio/xdgmime/xdgmimecache.h76
-rw-r--r--gio/xdgmime/xdgmimeglob.c547
-rw-r--r--gio/xdgmime/xdgmimeglob.h67
-rw-r--r--gio/xdgmime/xdgmimeint.c154
-rw-r--r--gio/xdgmime/xdgmimeint.h73
-rw-r--r--gio/xdgmime/xdgmimemagic.c813
-rw-r--r--gio/xdgmime/xdgmimemagic.h57
-rw-r--r--gio/xdgmime/xdgmimeparent.c219
-rw-r--r--gio/xdgmime/xdgmimeparent.h51
-rw-r--r--programs/.gitignore16
-rw-r--r--programs/Makefile.am58
-rw-r--r--programs/gvfs-cat.c105
-rw-r--r--programs/gvfs-copy.c158
-rw-r--r--programs/gvfs-info.c326
-rw-r--r--programs/gvfs-ls.c185
-rw-r--r--programs/gvfs-monitor-dir.c84
-rw-r--r--programs/gvfs-monitor-file.c84
-rw-r--r--programs/gvfs-mount.c184
-rw-r--r--programs/gvfs-move.c149
-rw-r--r--programs/gvfs-rm.c47
-rw-r--r--programs/gvfs-save.c147
-rw-r--r--programs/gvfs-trash.c47
-rw-r--r--test/Makefile.am1
180 files changed, 19 insertions, 40267 deletions
diff --git a/Makefile.am b/Makefile.am
index 263cb853..933ffeb1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,23 +1,11 @@
NULL =
-if OS_UNIX
-unix_dirs = \
+SUBDIRS = \
common \
client \
daemon \
- $(NULL)
-
-endif
-
-SUBDIRS = \
- gio \
- $(unix_dirs) \
po \
- programs \
test \
$(NULL)
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = gio-standalone.pc
diff --git a/autogen.sh b/autogen.sh
index 3b0b9c46..dd7a3ff1 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -8,7 +8,7 @@ ORIGDIR=`pwd`
cd $srcdir
PROJECT=GVfs
TEST_TYPE=-f
-FILE=gio/gfile.h
+FILE=client/gdaemonvfs.h
DIE=0
diff --git a/client/Makefile.am b/client/Makefile.am
index 0923fad5..51a68b85 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -24,7 +24,6 @@ vfssources = \
$(NULL)
vfslibs = \
- $(top_builddir)/gio/libgio.la \
$(top_builddir)/common/libgvfscommon.la \
$(DBUS_LIBS) \
$(GLIB_LIBS) \
@@ -49,7 +48,6 @@ libsmb_la_SOURCES = \
$(NULL)
libsmb_la_LIBADD = \
- $(top_builddir)/gio/libgio.la \
$(top_builddir)/common/libgvfscommon.la \
$(GLIB_LIBS) \
$(NULL)
@@ -79,7 +77,6 @@ gvfs_fuse_daemon_CFLAGS = \
-DDBUS_API_SUBJECT_TO_CHANGE
gvfs_fuse_daemon_LDADD = \
- $(top_builddir)/gio/libgio.la \
$(top_builddir)/common/libgvfscommon.la \
$(top_builddir)/client/libgvfsdbusfuse.la \
$(GLIB_LIBS) $(DBUS_LIBS) $(FUSE_LIBS)
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index c2aa4c1c..54ba8849 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -4,7 +4,6 @@
#include "gdaemonvfs.h"
#include "gvfsuriutils.h"
#include "gdaemonfile.h"
-#include <gio/glocalvfs.h>
#include <gio/giomodule.h>
#include <gio/gdummyfile.h>
#include <gvfsdaemonprotocol.h>
@@ -141,7 +140,7 @@ g_daemon_vfs_init (GDaemonVfs *vfs)
g_assert (the_vfs == NULL);
the_vfs = vfs;
- vfs->wrapped_vfs = g_local_vfs_new ();
+ vfs->wrapped_vfs = g_vfs_get_local ();
if (g_thread_supported ())
dbus_threads_init_default ();
diff --git a/common/gvfsdaemonprotocol.c b/common/gvfsdaemonprotocol.c
index 01e41486..06c01b8d 100644
--- a/common/gvfsdaemonprotocol.c
+++ b/common/gvfsdaemonprotocol.c
@@ -7,7 +7,6 @@
#include <gdbusutils.h>
#include <gio/gthemedicon.h>
#include <gio/gfileicon.h>
-#include <gio/glocalfile.h>
gchar *
_g_dbus_type_from_file_attribute_type (GFileAttributeType type)
@@ -116,7 +115,8 @@ _g_dbus_append_file_attribute (DBusMessageIter *iter,
file = g_file_icon_get_file (G_FILE_ICON (obj));
- if (G_IS_LOCAL_FILE (file))
+ path = g_file_get_path (file);
+ if (path)
{
if (!dbus_message_iter_open_container (&variant_iter,
DBUS_TYPE_STRUCT,
diff --git a/configure.ac b/configure.ac
index 65eac242..404e20d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(gio/gfile.h)
+AC_INIT(client/gdaemonvfs.h)
AM_INIT_AUTOMAKE(gvfs, 0.0.1)
AM_CONFIG_HEADER(config.h)
@@ -30,100 +30,26 @@ AH_VERBATIM([_GNU_SOURCE],
saved_CFLAGS=$CFLAGS
AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec, struct stat.st_atimensec, struct stat.st_atim.tv_nsec, struct stat.st_ctimensec, struct stat.st_ctim.tv_nsec])
-AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks])
CFLAGS=$saved_CFLAGS
-AC_CHECK_HEADERS([pwd.h])
-
-AC_CHECK_FUNCS(getc_unlocked readlink symlink chown lchown fchmod fchown link statvfs statfs utimes)
-
-AC_CHECK_HEADERS(sys/vfs.h sys/mount.h sys/statfs.h sys/statvfs.h sys/param.h)
-
-dnl
-dnl if statfs() takes 2 arguments or 4 (Solaris)
-dnl
-if test "$ac_cv_func_statfs" = yes ; then
- AC_MSG_CHECKING([number of arguments to statfs()])
- AC_TRY_COMPILE([#include <unistd.h>
- #ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
- #endif
- #ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
- #endif
- #ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
- #endif
- #ifdef HAVE_SYS_STATFS_H
- #include <sys/statfs.h>
- #endif], [struct statfs st;
- statfs(NULL, &st);],[
- AC_MSG_RESULT([2])
- AC_DEFINE(STATFS_ARGS, 2, [Number of arguments to statfs()])],[
- AC_TRY_COMPILE([#include <unistd.h>
- #ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h>
- #endif
- #ifdef HAVE_SYS_VFS_H
- #include <sys/vfs.h>
- #endif
- #ifdef HAVE_SYS_MOUNT_H
- #include <sys/mount.h>
- #endif
- #ifdef HAVE_SYS_STATFS_H
- #include <sys/statfs.h>
- #endif], [struct statfs st;
- statfs(NULL, &st, sizeof (st), 0);],[
- AC_MSG_RESULT([4])
- AC_DEFINE(STATFS_ARGS, 4, [Number of arguments to statfs()])],[
- AC_MSG_RESULT(unknown)
- AC_MSG_ERROR([unable to determine number of arguments to statfs()])])])
-fi
-
-dnl Volume monitor stuff
-AC_CHECK_FUNCS(setmntent endmntent hasmntopt getmntinfo)
-AC_CHECK_HEADERS(mntent.h sys/mnttab.h sys/vfstab.h sys/cdio.h sys/mount.h sys/mntctl.h sys/vfs.h sys/vmount.h sys/sysctl.h fstab.h fnmatch.h util.h sys/sysmacros.h)
-
-AC_MSG_CHECKING([for Win32])
-case "$host" in
- *-*-mingw*)
- glib_native_win32=yes
- ;;
- *)
- glib_native_win32=no
- ;;
-esac
-
-AC_MSG_RESULT([$glib_native_win32])
-AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"])
-AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"])
-
-if test "$glib_native_win32" != yes; then
- # libtool option to control which symbols are exported
- # right now, symbols starting with _ are not exported
- LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
-else
- # We currently use .def files on Windows
- LIBTOOL_EXPORT_OPTIONS=
-fi
+LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
GTK_DOC_CHECK
DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.13.8 gthread-2.0 gobject-2.0 gmodule-no-export-2.0)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.13.8 gthread-2.0 gobject-2.0 gmodule-no-export-2.0 gio-standalone)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
-if test "$glib_native_win32" != yes; then
- PKG_CHECK_MODULES(DBUS, dbus-1)
- AC_SUBST(DBUS_CFLAGS)
- AC_SUBST(DBUS_LIBS)
- AC_ARG_WITH(dbus_service_dir, [ --with-dbus-service-dir=PATH choose directory for dbus service files, [default=PREFIX/share/dbus-1/services]], with_dbus_service_dir="$withval", with_dbus_service_dir=$datadir/dbus-1/services)
- DBUS_SERVICE_DIR=$with_dbus_service_dir
- AC_SUBST(DBUS_SERVICE_DIR)
-fi
+PKG_CHECK_MODULES(DBUS, dbus-1)
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
+AC_ARG_WITH(dbus_service_dir, [ --with-dbus-service-dir=PATH choose directory for dbus service files, [default=PREFIX/share/dbus-1/services]], with_dbus_service_dir="$withval", with_dbus_service_dir=$datadir/dbus-1/services)
+DBUS_SERVICE_DIR=$with_dbus_service_dir
+AC_SUBST(DBUS_SERVICE_DIR)
GETTEXT_PACKAGE=gvfs
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [The gettext domain name])
@@ -131,103 +57,6 @@ AC_SUBST(GETTEXT_PACKAGE)
AM_GLIB_GNU_GETTEXT
-dnl ****************************
-dnl *** Check for libselinux ***
-dnl ****************************
-AC_ARG_ENABLE(selinux, [ --disable-selinux build without selinux support])
-msg_selinux=no
-SELINUX_LIBS=
-if test "x$enable_selinux" != "xno"; then
-
- AC_CHECK_LIB(selinux, is_selinux_enabled,
- [AC_CHECK_HEADERS(selinux/selinux.h,
- [AC_SEARCH_LIBS(lgetfilecon_raw, selinux,
- [AC_DEFINE(HAVE_SELINUX, 1, [Define to 1 if libselinux is available])
- SELINUX_LIBS="-lselinux"
- msg_selinux=yes])
- ])
- ])
-fi
-AC_SUBST(SELINUX_LIBS)
-
-dnl ***********************
-dnl ** Check for inotify **
-dnl ***********************
-inotify_support=no
-AC_CHECK_HEADERS([linux/inotify.h],
-[
- inotify_support=yes
-])
-AC_CHECK_HEADERS([sys/inotify.h],
-[
- inotify_support=yes
-])
-
-AM_CONDITIONAL(HAVE_INOTIFY, [test "$inotify_support" = "yes"])
-
-dnl **********************
-dnl *** Checks for FAM ***
-dnl **********************
-
-should_disable_fam=no
-
-AC_ARG_ENABLE(fam, [ --disable-fam build without enabling fam for file system monitoring],
- [
- if test "x$enable_fam" = "xno"; then
- should_disable_fam=yes
- echo "Not building FAM support"
- fi
- ]
- )
-fam_support=no
-FAM_LIBS=
-if test "x$should_disable_fam" = "xno"; then
-AC_CHECK_LIB(fam, FAMOpen,
- [AC_CHECK_HEADERS(fam.h,
- [AC_DEFINE(HAVE_FAM, [], [Define if we have FAM])
- AC_CHECK_LIB(fam, FAMNoExists,
- AC_DEFINE(HAVE_FAM_NO_EXISTS, [], [Define if we have FAMNoExists in fam]))
- FAM_LIBS="-lfam"]
- fam_support=yes,
- AC_MSG_WARN(*** FAM support will not be built (header files not found) ***))],
- AC_MSG_WARN(*** FAM support will not be built (FAM library not found) ***))
-AC_SUBST(FAM_LIBS)
-fi
-AM_CONDITIONAL(HAVE_FAM, [test "$fam_support" = "yes"])
-
-
-dnl ***********************
-dnl *** Check for xattr ***
-dnl ***********************
-AC_ARG_ENABLE(xattr, [ --disable-xattr build without xattr support])
-msg_xattr=no
-XATTR_LIBS=
-if test "x$enable_xattr" != "xno"; then
-
-dnl either glibc or libattr can provide xattr support
-
-dnl for both of them, we check for getxattr being in
-dnl the library and a valid xattr header.
-
-dnl try glibc
- AC_CHECK_LIB(c, getxattr,
- [AC_CHECK_HEADERS(sys/xattr.h,
- [AC_DEFINE(HAVE_XATTR, 1, [Define to 1 if xattr is available])
- msg_xattr=yes])
- ])
-
- if test "x$msg_xattr" != "xyes"; then
-dnl failure. try libattr
- AC_CHECK_LIB(attr, getxattr,
- [AC_CHECK_HEADERS(attr/xattr.h,
- [AC_DEFINE(HAVE_XATTR, 1, [Define to 1 if xattr is available])
- XATTR_LIBS="-lattr"
- msg_xattr=yes])
- ])
- fi
-fi
-AC_SUBST(XATTR_LIBS)
-
dnl **********************
dnl *** Check for FUSE ***
dnl **********************
@@ -375,14 +204,9 @@ fi
AC_OUTPUT([
Makefile
-gio/Makefile
-gio/xdgmime/Makefile
-gio/inotify/Makefile
-gio/fam/Makefile
common/Makefile
client/Makefile
daemon/Makefile
-programs/Makefile
test/Makefile
po/Makefile.in
gio-standalone.pc
@@ -391,11 +215,6 @@ gio-standalone.pc
echo
echo "gvfs configuration summary:"
echo "
- Win32 build: $glib_native_win32
- SELinux support: $msg_selinux
- xattr support: $msg_xattr
Samba support: $msg_samba
FUSE support: $msg_fuse
- inotify support: $inotify_support
- FAM support: $fam_support
"
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index b1e0d40b..3522924e 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -13,7 +13,6 @@ INCLUDES = \
noinst_LTLIBRARIES=libdaemon.la
libraries = \
- $(top_builddir)/gio/libgio.la \
libdaemon.la \
$(top_builddir)/common/libgvfscommon.la \
$(GLIB_LIBS) $(DBUS_LIBS)
diff --git a/daemon/gvfsbackendtest.c b/daemon/gvfsbackendtest.c
index f42c7ec3..7f04ec5f 100644
--- a/daemon/gvfsbackendtest.c
+++ b/daemon/gvfsbackendtest.c
@@ -11,7 +11,7 @@
#include <glib/gi18n.h>
#include <gio/gioerror.h>
#include <gio/gfile.h>
-#include <gio/glocalfile.h>
+#include <gio/gvfs.h>
#include "gvfsbackendtest.h"
#include "gvfsjobopenforread.h"
@@ -253,10 +253,12 @@ do_get_info (GVfsBackend *backend,
GFile *file;
GFileInfo *info2;
GError *error;
+ GVfs *local_vfs;
g_print ("do_get_file_info (%s)\n", filename);
- file = g_local_file_new (filename);
+ local_vfs = g_vfs_get_local ();
+ file = g_vfs_get_file_for_path (local_vfs, filename);
error = NULL;
info2 = g_file_get_info (file, NULL, flags,
diff --git a/gio/.gitignore b/gio/.gitignore
deleted file mode 100644
index a21e8ba3..00000000
--- a/gio/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-*~
-*.o
-*.lo
-*.la
-test
-.deps
-.libs
-Makefile
-Makefile.in
-gvfs-marshal.c
-gvfs-marshal.h
-test-gio
-test-streams
diff --git a/gio/Makefile.am b/gio/Makefile.am
deleted file mode 100644
index 7c5fe29e..00000000
--- a/gio/Makefile.am
+++ /dev/null
@@ -1,230 +0,0 @@
-NULL =
-
-SUBDIRS=
-
-if OS_UNIX
-SUBDIRS += xdgmime
-endif
-
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gvfs \
- -I$(top_srcdir)/daemon \
- -DGIO_MODULE_DIR=\"$(libdir)/gio/gvfs-modules\" \
- $(GLIB_CFLAGS) \
- -DG_LOG_DOMAIN=\"GVFS\" -DG_DISABLE_DEPRECATED \
- -DDBUS_API_SUBJECT_TO_CHANGE
-
-lib_LTLIBRARIES = libgio.la
-
-marshal_sources = \
- gvfs-marshal.h \
- gvfs-marshal.c \
- $(NULL)
-
-gvfs-marshal.h: gvfs-marshal.list $(GLIB_GENMARSHAL)
- $(GLIB_GENMARSHAL) --prefix=_gvfs_marshal $(srcdir)/gvfs-marshal.list --header > $@
-
-gvfs-marshal.c: gvfs-marshal.h gvfs-marshal.list $(GLIB_GENMARSHAL)
- (echo "#include \"gvfs-marshal.h\""; \
- $(GLIB_GENMARSHAL) --prefix=_gvfs_marshal $(srcdir)/gvfs-marshal.list --body) > $@
-
-local_sources = \
- glocaldirectorymonitor.c \
- glocaldirectorymonitor.h \
- glocalfilemonitor.c \
- glocalfilemonitor.h \
- glocalfileenumerator.c \
- glocalfileenumerator.h \
- glocalfileinfo.c \
- glocalfileinfo.h \
- glocalfile.c \
- glocalfile.h \
- glocalfileinputstream.c \
- glocalfileinputstream.h \
- glocalfileoutputstream.c \
- glocalfileoutputstream.h \
- glocalvfs.c \
- glocalvfs.h \
- $(NULL)
-
-platform_libadd =
-appinfo_sources =
-
-if HAVE_INOTIFY
-SUBDIRS += inotify
-platform_libadd += inotify/libinotify.la
-endif
-
-if HAVE_FAM
-SUBDIRS += fam
-platform_libadd += fam/libfam_helper.la
-endif
-
-if OS_UNIX
-appinfo_sources += gdesktopappinfo.c gdesktopappinfo.h
-platform_libadd += xdgmime/libxdgmime.la
-unix_sources = \
- gunixmounts.c \
- gunixmounts.h \
- gunixdrive.c \
- gunixdrive.h \
- gunixvolume.c \
- gunixvolume.h \
- gunixvolumemonitor.c \
- gunixvolumemonitor.h \
- gsocketinputstream.c \
- gsocketinputstream.h \
- gsocketoutputstream.c \
- gsocketoutputstream.h \
- $(NULL)
-endif
-
-if OS_WIN32
-appinfo_sources += gwin32appinfo.c gwin32appinfo.h
-platform_libadd += -lshlwapi
-endif
-
-libgio_la_SOURCES = \
- gappinfo.c \
- gasynchelper.c \
- gasynchelper.h \
- gasyncresult.c \
- gbufferedinputstream.c \
- gbufferedoutputstream.c \
- gcancellable.c \
- gcontenttype.c \
- gcontenttypeprivate.h \
- gdirectorymonitor.c \
- gdrive.c \
- gdrivepriv.h \
- gdummyfile.c \
- gfile.c \
- gfileenumerator.c \
- gfileicon.c \
- gfileattribute.c \
- gfileinfo.c \
- gfileinputstream.c \
- gfilemonitor.c \
- gfileoutputstream.c \
- gfilterinputstream.c \
- gfilteroutputstream.c \
- gicon.c \
- ginputstream.c \
- gioerror.c \
- giomodule.c \
- gioscheduler.c \
- gloadableicon.c \
- gmemoryinputstream.c \
- gmemoryoutputstream.c \
- gmountoperation.c \
- goutputstream.c \
- gpollfilemonitor.c \
- gpollfilemonitor.h \
- gseekable.c \
- gsimpleasyncresult.c \
- gsimpleasyncresult.h \
- gthemedicon.c \
- guniondrive.c \
- guniondrive.h \
- gunionvolume.c \
- gunionvolume.h \
- gunionvolumemonitor.c \
- gunionvolumemonitor.h \
- gvfs.c \
- gvolume.c \
- gvolumemonitor.c \
- gvolumepriv.h \
- $(appinfo_sources) \
- $(unix_sources) \
- $(local_sources) \
- $(daemon_sources) \
- $(marshal_sources) \
- $(NULL)
-
-$(libgio_la_OBJECTS): $(marshal_sources)
-
-libgio_la_LIBADD = \
- $(platform_libadd) \
- $(SELINUX_LIBS) \
- $(GLIB_LIBS) \
- $(XATTR_LIBS) \
- $(NULL)
-
-if OS_WIN32
-no_undefined = -no-undefined
-endif
-
-if HAVE_FAM
-fam_ldflags = $(FAM_LIBS)
-endif
-
-libgio_la_LDFLAGS= -export-dynamic $(no_undefined) $(fam_ldflags)
-
-gvfsincludedir=$(includedir)/gio/
-gvfsinclude_HEADERS = \
- gappinfo.h \
- gasyncresult.h \
- gbufferedinputstream.h \
- gbufferedoutputstream.h \
- gcancellable.h \
- gcontenttype.h \
- gdirectorymonitor.h \
- gdrive.h \
- gdummyfile.h \
- gfile.h \
- gfileenumerator.h \
- gfileicon.h \
- gfileattribute.h \
- gfileinfo.h \
- gfileinputstream.h \
- gfilemonitor.h \
- gfileoutputstream.h \
- gfilterinputstream.h \
- gfilteroutputstream.h \
- gicon.h \
- ginputstream.h \
- gioerror.h \
- giomodule.h \
- gioscheduler.h \
- giotypes.h \
- gloadableicon.h \
- gmemoryinputstream.h \
- gmemoryoutputstream.h \
- gmountoperation.h \
- goutputstream.h \
- gseekable.h \
- gthemedicon.h \
- gvfs.h \
- gvolume.h \
- gvolumemonitor.h \
- $(NULL)
-
-noinst_PROGRAMS= \
- test-gio \
- test-streams
-
-test_gio_SOURCES = \
- test-gio.c
-
-test_gio_LDADD = \
- libgio.la \
- $(GLIB_LIBS)
-
-test_streams_SOURCES = \
- test-streams.c
-
-test_streams_LDADD = \
- libgio.la \
- $(GLIB_LIBS)
-
-if OS_WIN32
-else
-export_symbols = $(LIBTOOL_EXPORT_OPTIONS)
-endif
-
-EXTRA_DIST = \
- gvfs-marshal.list \
- $(NULL)
-
-CLEANFILES = \
- $(marshal_sources) \
- $(NULL)
diff --git a/gio/fam/Makefile.am b/gio/fam/Makefile.am
deleted file mode 100644
index b812120b..00000000
--- a/gio/fam/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-NULL =
-
-INCLUDES = -I$(top_srcdir) \
- $(GLIB_CFLAGS) \
- -DG_DISABLE_DEPRECATED
-
-noinst_LTLIBRARIES = libfam_helper.la
-
-libfam_helper_la_SOURCES = \
- fam-helper.c \
- fam-helper.h \
- $(NULL)
-
diff --git a/gio/fam/fam-helper.c b/gio/fam/fam-helper.c
deleted file mode 100644
index 8550da4c..00000000
--- a/gio/fam/fam-helper.c
+++ /dev/null
@@ -1,218 +0,0 @@
-#include "config.h"
-#include <fam.h>
-#include <gio/gfilemonitor.h>
-#include <gio/gdirectorymonitor.h>
-#include <gio/gfilemonitorpriv.h>
-#include <gio/gdirectorymonitorpriv.h>
-
-#include "fam-helper.h"
-
-static FAMConnection* fam_connection = NULL;
-static gint fam_watch_id = 0;
-G_LOCK_DEFINE_STATIC(fam_connection);
-
-struct _fam_sub
-{
- gchar *pathname;
- gboolean directory;
- gpointer user_data;
- gboolean cancelled;
- FAMRequest request;
-};
-
-static GFileMonitorEvent
-fam_event_to_file_monitor_event (enum FAMCodes code)
-{
- switch (code)
- {
- case FAMChanged:
- return G_FILE_MONITOR_EVENT_CHANGED;
- break;
- case FAMDeleted:
- return G_FILE_MONITOR_EVENT_DELETED;
- break;
- case FAMCreated:
- return G_FILE_MONITOR_EVENT_CREATED;
- break;
- default:
- return -1;
- break;
- }
-}
-
-static gboolean
-fam_do_iter_unlocked (void)
-{
- while (fam_connection != NULL && FAMPending (fam_connection)) {
- FAMEvent ev;
- fam_sub* sub = NULL;
- gboolean cancelled;
-
- if (FAMNextEvent (fam_connection, &ev) != 1) {
- FAMClose (fam_connection);
- g_free (fam_connection);
- g_source_remove (fam_watch_id);
- fam_watch_id = 0;
- fam_connection = NULL;
- return FALSE;
- }
-
- sub = (fam_sub*)ev.userdata;
- cancelled = sub->cancelled;
- if (ev.code == FAMAcknowledge && cancelled)
- {
- g_free (sub);
- continue;
- }
-
- if (cancelled)
- continue;
-
- if (sub->directory)
- {
- GDirectoryMonitor* monitor = G_DIRECTORY_MONITOR (sub->user_data);
- GFileMonitorEvent eflags = fam_event_to_file_monitor_event (ev.code);
- gchar* path = NULL;
-
- /* unsupported event */
- if (eflags == -1)
- continue;
-
- if (ev.filename[0] == '/')
- path = g_strdup (ev.filename);
- else
- path = g_strdup_printf ("%s/%s", sub->pathname, ev.filename);
- GFile* child = g_file_new_for_path (path);
- GFile* parent = g_file_get_parent (child);
- g_directory_monitor_emit_event (monitor, child, NULL, eflags);
- g_free (path);
- g_object_unref (child);
- g_object_unref (parent);
- } else {
- GFileMonitor* monitor = G_FILE_MONITOR (sub->user_data);
- GFileMonitorEvent eflags = fam_event_to_file_monitor_event (ev.code);
- gchar* path = NULL;
-
- if (eflags == -1)
- continue;
- path = g_strdup (ev.filename);
- GFile* child = g_file_new_for_path (path);
- g_file_monitor_emit_event (monitor, child, NULL, eflags);
- g_free (path);
- g_object_unref (child);
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-fam_callback (GIOChannel *source,
- GIOCondition condition,
- gpointer data)
-{
- gboolean res;
- G_LOCK (fam_connection);
-
- res = fam_do_iter_unlocked ();
-
- G_UNLOCK (fam_connection);
- return res;
-}
-
-static gboolean
-fam_helper_startup (void)
-{
- GIOChannel *ioc;
-
- G_LOCK (fam_connection);
-
- if (fam_connection == NULL) {
- fam_connection = g_new0 (FAMConnection, 1);
- if (FAMOpen2 (fam_connection, "gvfs user") != 0) {
- g_warning ("FAMOpen failed, FAMErrno=%d\n", FAMErrno);
- g_free (fam_connection);
- fam_connection = NULL;
- G_UNLOCK (fam_connection);
- return FALSE;
- }
-#ifdef HAVE_FAM_NO_EXISTS
- /* This is a gamin extension that avoids sending all the Exists event for dir monitors */
- FAMNoExists (fam_connection);
-#endif
- ioc = g_io_channel_unix_new (FAMCONNECTION_GETFD(fam_connection));
- fam_watch_id = g_io_add_watch (ioc,
- G_IO_IN | G_IO_HUP | G_IO_ERR,
- fam_callback, fam_connection);
- g_io_channel_unref (ioc);
- }
-
- G_UNLOCK (fam_connection);
-
- return TRUE;
-}
-
-fam_sub*
-_fam_sub_add (const gchar* pathname,
- gboolean directory,
- gpointer user_data)
-{
- if (!fam_helper_startup ())
- return NULL;
-
- fam_sub* sub = g_new0 (fam_sub, 1);
- sub->pathname = g_strdup (pathname);
- sub->directory = directory;
- sub->user_data = user_data;
-
- G_LOCK (fam_connection);
- /* We need to queue up incoming messages to avoid blocking on write
- * if there are many monitors being canceled */
- fam_do_iter_unlocked ();
-
- if (fam_connection == NULL) {
- G_UNLOCK (fam_connection);
- return NULL;
- }
-
- if (directory)
- FAMMonitorDirectory (fam_connection, pathname, &sub->request, sub);
- else
- FAMMonitorFile (fam_connection, pathname, &sub->request, sub);
-
- G_UNLOCK (fam_connection);
- return sub;
-}
-
-gboolean
-_fam_sub_cancel (fam_sub* sub)
-{
- if (sub->cancelled)
- return TRUE;
-
- sub->cancelled = TRUE;
-
- G_LOCK (fam_connection);
- /* We need to queue up incoming messages to avoid blocking on write
- * if there are many monitors being canceled */
- fam_do_iter_unlocked ();
-
- if (fam_connection == NULL) {
- G_UNLOCK (fam_connection);
- return FALSE;
- }
-
- FAMCancelMonitor (fam_connection, &sub->request);
-
- G_UNLOCK (fam_connection);
-
- return TRUE;
-}
-
-void
-_fam_sub_free (fam_sub* sub)
-{
- g_free (sub->pathname);
- g_free (sub);
-}
-
diff --git a/gio/fam/fam-helper.h b/gio/fam/fam-helper.h
deleted file mode 100644
index 8b6276a7..00000000
--- a/gio/fam/fam-helper.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __FAM_HELPER_H__
-#define __FAM_HELPER_H__
-
-typedef struct _fam_sub fam_sub;
-
-fam_sub* _fam_sub_add (const gchar* pathname,
- gboolean directory,
- gpointer user_data);
-gboolean _fam_sub_cancel (fam_sub* sub);
-void _fam_sub_free (fam_sub* sub);
-
-#endif /* __FAM_HELPER_H__ */
diff --git a/gio/gappinfo.c b/gio/gappinfo.c
deleted file mode 100644
index a41e207f..00000000
--- a/gio/gappinfo.c
+++ /dev/null
@@ -1,175 +0,0 @@
-#include <config.h>
-#include "gappinfo.h"
-#include <glib/gi18n-lib.h>
-
-#include <giotypes.h>
-
-static void g_app_info_base_init (gpointer g_class);
-static void g_app_info_class_init (gpointer g_class,
- gpointer class_data);
-
-
-GType
-g_app_info_get_type (void)
-{
- static GType app_info_type = 0;
-
- if (! app_info_type)
- {
- static const GTypeInfo app_info_info =
- {
- sizeof (GAppInfoIface), /* class_size */
- g_app_info_base_init, /* base_init */
- NULL, /* base_finalize */
- g_app_info_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- app_info_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GAppInfo"),
- &app_info_info, 0);
-
- g_type_interface_add_prerequisite (app_info_type, G_TYPE_OBJECT);
- }
-
- return app_info_type;
-}
-
-static void
-g_app_info_class_init (gpointer g_class,
- gpointer class_data)
-{
-}
-
-static void
-g_app_info_base_init (gpointer g_class)
-{
-}
-
-GAppInfo *
-g_app_info_dup (GAppInfo *appinfo)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->dup) (appinfo);
-}
-
-gboolean
-g_app_info_equal (GAppInfo *appinfo1,
- GAppInfo *appinfo2)
-{
- GAppInfoIface *iface;
-
- if (G_TYPE_FROM_INSTANCE (appinfo1) != G_TYPE_FROM_INSTANCE (appinfo2))
- return FALSE;
-
- iface = G_APP_INFO_GET_IFACE (appinfo1);
-
- return (* iface->equal) (appinfo1, appinfo2);
-}
-
-char *
-g_app_info_get_name (GAppInfo *appinfo)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->get_name) (appinfo);
-}
-
-char *
-g_app_info_get_description (GAppInfo *appinfo)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->get_description) (appinfo);
-}
-
-gboolean
-g_app_info_set_as_default_for_type (GAppInfo *appinfo,
- const char *content_type,
- GError **error)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->set_as_default_for_type) (appinfo, content_type, error);
-}
-
-GIcon *
-g_app_info_get_icon (GAppInfo *appinfo)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->get_icon) (appinfo);
-}
-
-gboolean
-g_app_info_launch (GAppInfo *appinfo,
- GList *filenames,
- char **envp,
- GError **error)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->launch) (appinfo, filenames, envp, error);
-}
-
-gboolean
-g_app_info_supports_uris (GAppInfo *appinfo)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->supports_uris) (appinfo);
-}
-
-gboolean
-g_app_info_supports_xdg_startup_notify (GAppInfo *appinfo)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->supports_xdg_startup_notify) (appinfo);
-}
-
-gboolean
-g_app_info_launch_uris (GAppInfo *appinfo,
- GList *uris,
- char **envp,
- GError **error)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->launch) (appinfo, uris, envp, error);
-}
-
-gboolean
-g_app_info_should_show (GAppInfo *appinfo,
- const char *desktop_env)
-{
- GAppInfoIface *iface;
-
- iface = G_APP_INFO_GET_IFACE (appinfo);
-
- return (* iface->should_show) (appinfo, desktop_env);
-}
-
diff --git a/gio/gappinfo.h b/gio/gappinfo.h
deleted file mode 100644
index 53e537cd..00000000
--- a/gio/gappinfo.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef __G_APP_INFO_H__
-#define __G_APP_INFO_H__
-
-#include <glib-object.h>
-#include <gio/gicon.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_APP_INFO (g_app_info_get_type ())
-#define G_APP_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_APP_INFO, GAppInfo))
-#define G_IS_APP_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_APP_INFO))
-#define G_APP_INFO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_APP_INFO, GAppInfoIface))
-
-typedef struct _GAppInfo GAppInfo; /* Dummy typedef */
-typedef struct _GAppInfoIface GAppInfoIface;
-
-struct _GAppInfoIface
-{
- GTypeInterface g_iface;
-
- /* Virtual Table */
-
- GAppInfo * (*dup) (GAppInfo *appinfo);
- gboolean (*equal) (GAppInfo *appinfo1,
- GAppInfo *appinfo2);
- char * (*get_name) (GAppInfo *appinfo);
- char * (*get_description) (GAppInfo *appinfo);
- GIcon * (*get_icon) (GAppInfo *appinfo);
- gboolean (*launch) (GAppInfo *appinfo,
- GList *filenames,
- char **envp,
- GError **error);
- gboolean (*supports_uris) (GAppInfo *appinfo);
- gboolean (*launch_uris) (GAppInfo *appinfo,
- GList *uris,
- char **envp,
- GError **error);
- gboolean (*should_show) (GAppInfo *appinfo,
- const char *desktop_env);
- gboolean (*supports_xdg_startup_notify) (GAppInfo *appinfo);
- gboolean (*set_as_default_for_type) (GAppInfo *appinfo,
- const char *content_type,
- GError **error);
-};
-
-GType g_app_info_get_type (void) G_GNUC_CONST;
-
-GAppInfo *g_app_info_create_from_commandline (const char *commandline,
- const char *application_name,
- GError **error);
-GAppInfo *g_app_info_dup (GAppInfo *appinfo);
-gboolean g_app_info_equal (GAppInfo *appinfo1,
- GAppInfo *appinfo2);
-char * g_app_info_get_name (GAppInfo *appinfo);
-char * g_app_info_get_description (GAppInfo *appinfo);
-GIcon * g_app_info_get_icon (GAppInfo *appinfo);
-gboolean g_app_info_launch (GAppInfo *appinfo,
- GList *filenames,
- char **envp,
- GError **error);
-gboolean g_app_info_supports_uris (GAppInfo *appinfo);
-gboolean g_app_info_supports_xdg_startup_notify (GAppInfo *appinfo);
-gboolean g_app_info_launch_uris (GAppInfo *appinfo,
- GList *uris,
- char **envp,
- GError **error);
-gboolean g_app_info_should_show (GAppInfo *appinfo,
- const char *desktop_env);
-gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo,
- const char *content_type,
- GError **error);
-
-GList * g_get_all_app_info (void);
-GList * g_get_all_app_info_for_type (const char *content_type);
-GAppInfo *g_get_default_app_info_for_type (const char *content_type);
-
-/* TODO: Possibly missing operations:
- create new content type from extension
-*/
-
-
-G_END_DECLS
-
-#endif /* __G_APP_INFO_H__ */
diff --git a/gio/gasynchelper.c b/gio/gasynchelper.c
deleted file mode 100644
index 0670f595..00000000
--- a/gio/gasynchelper.c
+++ /dev/null
@@ -1,141 +0,0 @@
-#include <config.h>
-
-#include "gasynchelper.h"
-
-static void
-async_result_free (gpointer data)
-{
- GAsyncResultData *res = data;
-
- if (res->error)
- g_error_free (res->error);
-
- g_object_unref (res->async_object);
-
- g_free (res);
-}
-
-void
-_g_queue_async_result (GAsyncResultData *result,
- gpointer async_object,
- GError *error,
- gpointer user_data,
- GSourceFunc source_func)
-{
- GSource *source;
-
- g_return_if_fail (G_IS_OBJECT (async_object));
-
- result->async_object = g_object_ref (async_object);
- result->user_data = user_data;
- result->error = error;
-
- source = g_idle_source_new ();
- g_source_set_priority (source, G_PRIORITY_DEFAULT);
- g_source_set_callback (source, source_func, result, async_result_free);
- g_source_attach (source, NULL);
- g_source_unref (source);
-}
-
-/*************************************************************************
- * fd source *
- ************************************************************************/
-
-typedef struct
-{
- GSource source;
- GPollFD pollfd;
- GCancellable *cancellable;
- gulong cancelled_tag;
-} FDSource;
-
-static gboolean
-fd_source_prepare (GSource *source,
- gint *timeout)
-{
- FDSource *fd_source = (FDSource *)source;
- *timeout = -1;
-
- return g_cancellable_is_cancelled (fd_source->cancellable);
-}
-
-static gboolean
-fd_source_check (GSource *source)
-{
- FDSource *fd_source = (FDSource *)source;
-
- return
- g_cancellable_is_cancelled (fd_source->cancellable) ||
- fd_source->pollfd.revents != 0;
-}
-
-static gboolean
-fd_source_dispatch (GSource *source,
- GSourceFunc callback,
- gpointer user_data)
-
-{
- GFDSourceFunc func = (GFDSourceFunc)callback;
- FDSource *fd_source = (FDSource *)source;
-
- g_assert (func != NULL);
-
- return (*func) (user_data, fd_source->pollfd.revents, fd_source->pollfd.fd);
-}
-
-static void
-fd_source_finalize (GSource *source)
-{
- FDSource *fd_source = (FDSource *)source;
-
- if (fd_source->cancelled_tag)
- g_signal_handler_disconnect (fd_source->cancellable,
- fd_source->cancelled_tag);
-
- if (fd_source->cancellable)
- g_object_unref (fd_source->cancellable);
-}
-
-static GSourceFuncs fd_source_funcs = {
- fd_source_prepare,
- fd_source_check,
- fd_source_dispatch,
- fd_source_finalize
-};
-
-/* Might be called on another thread */
-static void
-fd_source_cancelled_cb (GCancellable *cancellable,
- gpointer data)
-{
- /* Wake up the mainloop in case we're waiting on async calls with FDSource */
- g_main_context_wakeup (NULL);
-}
-
-GSource *
-_g_fd_source_new (int fd,
- gushort events,
- GCancellable *cancellable)
-{
- GSource *source;
- FDSource *fd_source;
-
- source = g_source_new (&fd_source_funcs, sizeof (FDSource));
- fd_source = (FDSource *)source;
-
- if (cancellable)
- fd_source->cancellable = g_object_ref (cancellable);
-
- fd_source->pollfd.fd = fd;
- fd_source->pollfd.events = events;
- g_source_add_poll (source, &fd_source->pollfd);
-
- if (cancellable)
- fd_source->cancelled_tag =
- g_signal_connect_data (cancellable, "cancelled",
- (GCallback)fd_source_cancelled_cb,
- NULL, NULL,
- 0);
-
- return source;
-}
diff --git a/gio/gasynchelper.h b/gio/gasynchelper.h
deleted file mode 100644
index a3343850..00000000
--- a/gio/gasynchelper.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __G_ASYNC_HELPER_H__
-#define __G_ASYNC_HELPER_H__
-
-#include <glib-object.h>
-#include "gcancellable.h"
-
-G_BEGIN_DECLS
-
-typedef struct {
- gpointer async_object;
- GError * error;
- gpointer user_data;
-} GAsyncResultData;
-
-typedef gboolean (*GFDSourceFunc) (gpointer user_data,
- GIOCondition condition,
- int fd);
-
-void _g_queue_async_result (GAsyncResultData *result,
- gpointer async_object,
- GError *error,
- gpointer user_data,
- GSourceFunc source_func);
-
-GSource *_g_fd_source_new (int fd,
- gushort events,
- GCancellable *cancellable);
-
-G_END_DECLS
-
-#endif /* __G_ASYNC_HELPER_H__ */
diff --git a/gio/gasyncresult.c b/gio/gasyncresult.c
deleted file mode 100644
index 6dd4a6f8..00000000
--- a/gio/gasyncresult.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <config.h>
-#include "giotypes.h"
-#include "gasyncresult.h"
-
-static void g_async_result_base_init (gpointer g_class);
-static void g_async_result_class_init (gpointer g_class,
- gpointer class_data);
-
-GType
-g_async_result_get_type (void)
-{
- static GType async_result_type = 0;
-
- if (! async_result_type)
- {
- static const GTypeInfo async_result_info =
- {
- sizeof (GAsyncResultIface), /* class_size */
- g_async_result_base_init, /* base_init */
- NULL, /* base_finalize */
- g_async_result_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- async_result_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GAsyncResult"),
- &async_result_info, 0);
-
- g_type_interface_add_prerequisite (async_result_type, G_TYPE_OBJECT);
- }
-
- return async_result_type;
-}
-
-static void
-g_async_result_class_init (gpointer g_class,
- gpointer class_data)
-{
-}
-
-static void
-g_async_result_base_init (gpointer g_class)
-{
-}
-
-gpointer
-g_async_result_get_user_data (GAsyncResult *res)
-{
- GAsyncResultIface *iface;
-
- iface = G_ASYNC_RESULT_GET_IFACE (res);
-
- return (* iface->get_user_data) (res);
-}
-
-GObject *
-g_async_result_get_source_object (GAsyncResult *res)
-{
- GAsyncResultIface *iface;
-
- iface = G_ASYNC_RESULT_GET_IFACE (res);
-
- return (* iface->get_source_object) (res);
-}
diff --git a/gio/gasyncresult.h b/gio/gasyncresult.h
deleted file mode 100644
index b9be3d29..00000000
--- a/gio/gasyncresult.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __G_ASYNC_RESULT_H__
-#define __G_ASYNC_RESULT_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_ASYNC_RESULT (g_async_result_get_type ())
-#define G_ASYNC_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ASYNC_RESULT, GAsyncResult))
-#define G_IS_ASYNC_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ASYNC_RESULT))
-#define G_ASYNC_RESULT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ASYNC_RESULT, GAsyncResultIface))
-
-typedef struct _GAsyncResult GAsyncResult; /* Dummy typedef */
-typedef struct _GAsyncResultIface GAsyncResultIface;
-
-typedef void (*GAsyncReadyCallback) (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
-
-struct _GAsyncResultIface
-{
- GTypeInterface g_iface;
-
- /* Virtual Table */
-
- gpointer (*get_user_data) (GAsyncResult *async_result);
- GObject * (*get_source_object) (GAsyncResult *async_result);
-};
-
-GType g_async_result_get_type (void) G_GNUC_CONST;
-
-gpointer g_async_result_get_user_data (GAsyncResult *res);
-GObject *g_async_result_get_source_object (GAsyncResult *res);
-
-G_END_DECLS
-
-#endif /* __G_ASYNC_RESULT_H__ */
diff --git a/gio/gbufferedinputstream.c b/gio/gbufferedinputstream.c
deleted file mode 100644
index 3f608a80..00000000
--- a/gio/gbufferedinputstream.c
+++ /dev/null
@@ -1,396 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-
-#include "gbufferedinputstream.h"
-#include "ginputstream.h"
-#include "gsimpleasyncresult.h"
-#include <string.h>
-
-/* TODO: Real P_() */
-#define P_(_x) (_x)
-
-#define DEFAULT_BUFFER_SIZE 4096
-
-struct _GBufferedInputStreamPrivate {
-
- guint8 *buffer;
- guint len;
- guint pos;
- guint end;
-
-};
-
-enum {
- PROP_0,
- PROP_BUFSIZE
-};
-
-static void g_buffered_input_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void g_buffered_input_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void g_buffered_input_stream_finalize (GObject *object);
-
-
-static gssize g_buffered_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static void g_buffered_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static gssize g_buffered_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-G_DEFINE_TYPE (GBufferedInputStream,
- g_buffered_input_stream,
- G_TYPE_FILTER_INPUT_STREAM)
-
-
-static void
-g_buffered_input_stream_class_init (GBufferedInputStreamClass *klass)
-{
- GObjectClass *object_class;
- GInputStreamClass *istream_class;
-
- g_type_class_add_private (klass, sizeof (GBufferedInputStreamPrivate));
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = g_buffered_input_stream_get_property;
- object_class->set_property = g_buffered_input_stream_set_property;
- object_class->finalize = g_buffered_input_stream_finalize;
-
- istream_class = G_INPUT_STREAM_CLASS (klass);
- istream_class->read = g_buffered_input_stream_read;
- istream_class->read_async = g_buffered_input_stream_read_async;
- istream_class->read_finish = g_buffered_input_stream_read_finish;
-
- g_object_class_install_property (object_class,
- PROP_BUFSIZE,
- g_param_spec_uint ("buffer-size",
- P_("Buffer Size"),
- P_("The size of the backend buffer"),
- 1,
- G_MAXUINT,
- DEFAULT_BUFFER_SIZE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
-
-
-}
-
-static void
-g_buffered_input_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GBufferedInputStreamPrivate *priv;
- GBufferedInputStream *bstream;
- gsize size;
-
- bstream = G_BUFFERED_INPUT_STREAM (object);
- priv = bstream->priv;
-
- switch (prop_id)
- {
- case PROP_BUFSIZE:
- size = g_value_get_uint (value);
- priv->len = size;
- priv->pos = 0;
- priv->buffer = g_malloc (priv->len);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_buffered_input_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GBufferedInputStreamPrivate *priv;
- GBufferedInputStream *bstream;
-
- bstream = G_BUFFERED_INPUT_STREAM (object);
- priv = bstream->priv;
-
- switch (prop_id)
- {
-
- case PROP_BUFSIZE:
- g_value_set_uint (value, priv->len);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_buffered_input_stream_finalize (GObject *object)
-{
- GBufferedInputStreamPrivate *priv;
- GBufferedInputStream *stream;
-
- stream = G_BUFFERED_INPUT_STREAM (object);
- priv = stream->priv;
-
- g_free (priv->buffer);
-
- if (G_OBJECT_CLASS (g_buffered_input_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_buffered_input_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_buffered_input_stream_init (GBufferedInputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_BUFFERED_INPUT_STREAM,
- GBufferedInputStreamPrivate);
-}
-
-
-GInputStream *
-g_buffered_input_stream_new (GInputStream *base_stream)
-{
- GInputStream *stream;
-
- g_assert (base_stream != NULL);
-
- stream = g_object_new (G_TYPE_BUFFERED_INPUT_STREAM,
- "base-stream", base_stream,
- NULL);
-
- return stream;
-}
-
-GInputStream *
-g_buffered_input_stream_new_sized (GInputStream *base_stream,
- guint size)
-{
- GInputStream *stream;
-
- g_assert (base_stream != NULL);
-
- stream = g_object_new (G_TYPE_BUFFERED_INPUT_STREAM,
- "base-stream", base_stream,
- "buffer-size", size,
- NULL);
-
- return stream;
-}
-
-static gboolean
-refill_buffer (GBufferedInputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GBufferedInputStreamPrivate *priv;
- GInputStream *base_stream;
- gboolean res;
- gsize len;
- gsize nread;
-
- priv = stream->priv;
- res = FALSE;
-
- if (priv->pos)
- {
- /* if we have data left move it to the front */
- len = priv->end - priv->pos;
-
- g_memmove (priv->buffer,
- priv->buffer + priv->pos,
- len);
-
- priv->pos = 0;
- priv->end = len;
- }
-
- len = priv->len - priv->end;
-
- base_stream = G_FILTER_INPUT_STREAM (stream)->base_stream;
-
- nread = g_input_stream_read (base_stream,
- priv->buffer + priv->end,
- len,
- cancellable,
- error);
-
-
- if (nread < 0) {
- return FALSE;
- }
-
- priv->end += nread;
-
- return TRUE;
-}
-
-static gssize
-g_buffered_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GBufferedInputStream *bstream;
- GBufferedInputStreamPrivate *priv;
- gboolean res;
- gsize n;
-
- bstream = G_BUFFERED_INPUT_STREAM (stream);
- priv = bstream->priv;
-
- n = priv->end - priv->pos;
-
- if (n == 0)
- {
- res = refill_buffer (bstream, cancellable, error);
-
- if (res == FALSE)
- return -1;
-
- n = priv->end - priv->pos;
- }
-
- count = MIN (count, n);
-
- memcpy (buffer, priv->buffer + priv->pos, count);
- priv->pos += count;
-
- return count;
-}
-
-/* ************************** */
-/* Async stuff implementation */
-/* ************************** */
-
-typedef struct {
-
- gsize count;
- void *buffer;
-
-} ReadData;
-
-static void
-free_read_data (gpointer data)
-{
- g_slice_free (ReadData, data);
-}
-
-static void
-fill_buffer_thread (GSimpleAsyncResult *result,
- GObject *object,
- GCancellable *cancellable)
-{
- GBufferedInputStream *stream;
- GError *error = NULL;
- gboolean res;
-
- stream = G_BUFFERED_INPUT_STREAM (object);
-
- res = refill_buffer (stream, cancellable, &error);
-
- if (res == FALSE)
- {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- }
-}
-
-static void
-g_buffered_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GBufferedInputStream *bstream;
- GBufferedInputStreamPrivate *priv;
- GSimpleAsyncResult *res;
- ReadData *rdata;
-
- bstream = G_BUFFERED_INPUT_STREAM (stream);
- priv = bstream->priv;
-
- rdata = g_slice_new (ReadData);
- rdata->count = count;
- rdata->buffer = buffer;
-
- res = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- rdata,
- g_buffered_input_stream_read_async);
-
- g_simple_async_result_set_op_res_gpointer (res, rdata, free_read_data);
-
- /* if we have data left in the buffer we direclty call
- * the callback in ilde and copy them to the buffer (should
- * be fast enough) otherwise we refill the buffer in a thread */
- if (priv->end - priv->pos > 0)
- {
- g_simple_async_result_complete_in_idle (res);
- }
- else
- {
- g_simple_async_result_run_in_thread (res,
- fill_buffer_thread,
- io_priority,
- cancellable);
- g_object_unref (res);
- }
-
-}
-
-static gssize
-g_buffered_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GBufferedInputStream *bstream;
- GBufferedInputStreamPrivate *priv;
- GSimpleAsyncResult *simple;
- ReadData *rdata;
- gsize count;
-
-
- bstream = G_BUFFERED_INPUT_STREAM (stream);
- priv = bstream->priv;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_assert (g_simple_async_result_get_source_tag (simple)
- == g_buffered_input_stream_read_async);
-
- rdata = g_simple_async_result_get_op_res_gpointer (simple);
-
- count = MIN (rdata->count, priv->end - priv->pos);
- memcpy (rdata->buffer, priv->buffer + priv->pos, count);
- priv->pos += count;
-
- return count;
-}
-
-/* vim: ts=2 sw=2 et */
diff --git a/gio/gbufferedinputstream.h b/gio/gbufferedinputstream.h
deleted file mode 100644
index 26f2332c..00000000
--- a/gio/gbufferedinputstream.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __G_BUFFERED_INPUT_STREAM_H__
-#define __G_BUFFERED_INPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/gfilterinputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_BUFFERED_INPUT_STREAM (g_buffered_input_stream_get_type ())
-#define G_BUFFERED_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStream))
-#define G_BUFFERED_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStreamClass))
-#define G_IS_BUFFERED_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_BUFFERED_INPUT_STREAM))
-#define G_IS_BUFFERED_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_BUFFERED_INPUT_STREAM))
-#define G_BUFFERED_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStreamClass))
-
-typedef struct _GBufferedInputStream GBufferedInputStream;
-typedef struct _GBufferedInputStreamClass GBufferedInputStreamClass;
-typedef struct _GBufferedInputStreamPrivate GBufferedInputStreamPrivate;
-
-struct _GBufferedInputStream
-{
- GFilterInputStream parent;
-
- /*< private >*/
- GBufferedInputStreamPrivate *priv;
-};
-
-struct _GBufferedInputStreamClass
-{
- GInputStreamClass parent_class;
-};
-
-
-GType g_buffered_input_stream_get_type (void) G_GNUC_CONST;
-GInputStream* g_buffered_input_stream_new (GInputStream *base_stream);
-GInputStream* g_buffered_input_stream_new_sized (GInputStream *base_stream,
- guint size);
-G_END_DECLS
-
-#endif /* __G_BUFFERED_INPUT_STREAM_H__ */
diff --git a/gio/gbufferedoutputstream.c b/gio/gbufferedoutputstream.c
deleted file mode 100644
index 4cc73e00..00000000
--- a/gio/gbufferedoutputstream.c
+++ /dev/null
@@ -1,613 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-
-#include "gbufferedoutputstream.h"
-#include "goutputstream.h"
-#include "gsimpleasyncresult.h"
-#include "string.h"
-
-/* TODO: Real P_() */
-#define P_(_x) (_x)
-
-#define DEFAULT_BUFFER_SIZE 4096
-
-struct _GBufferedOutputStreamPrivate {
- guint8 *buffer;
- gsize len;
- goffset pos;
-};
-
-enum {
- PROP_0,
- PROP_BUFSIZE
-};
-
-static void g_buffered_output_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void g_buffered_output_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void g_buffered_output_stream_finalize (GObject *object);
-
-
-static gssize g_buffered_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_buffered_output_stream_flush (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_buffered_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-
-static void g_buffered_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_buffered_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_buffered_output_stream_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_buffered_output_stream_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_buffered_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_buffered_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-G_DEFINE_TYPE (GBufferedOutputStream,
- g_buffered_output_stream,
- G_TYPE_FILTER_OUTPUT_STREAM)
-
-
-static void
-g_buffered_output_stream_class_init (GBufferedOutputStreamClass *klass)
-{
- GObjectClass *object_class;
- GOutputStreamClass *ostream_class;
-
- g_type_class_add_private (klass, sizeof (GBufferedOutputStreamPrivate));
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = g_buffered_output_stream_get_property;
- object_class->set_property = g_buffered_output_stream_set_property;
- object_class->finalize = g_buffered_output_stream_finalize;
-
- ostream_class = G_OUTPUT_STREAM_CLASS (klass);
- ostream_class->write = g_buffered_output_stream_write;
- ostream_class->flush = g_buffered_output_stream_flush;
- ostream_class->close = g_buffered_output_stream_close;
- ostream_class->write_async = g_buffered_output_stream_write_async;
- ostream_class->write_finish = g_buffered_output_stream_write_finish;
- ostream_class->flush_async = g_buffered_output_stream_flush_async;
- ostream_class->flush_finish = g_buffered_output_stream_flush_finish;
- ostream_class->close_async = g_buffered_output_stream_close_async;
- ostream_class->close_finish = g_buffered_output_stream_close_finish;
-
- g_object_class_install_property (object_class,
- PROP_BUFSIZE,
- g_param_spec_uint ("buffer-size",
- P_("Buffer Size"),
- P_("The size of the backend buffer"),
- 1,
- G_MAXUINT,
- DEFAULT_BUFFER_SIZE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
-
-}
-
-static void
-g_buffered_output_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GBufferedOutputStream *buffered_stream;
- GBufferedOutputStreamPrivate *priv;
- guint size;
-
- buffered_stream = G_BUFFERED_OUTPUT_STREAM (object);
- priv = buffered_stream->priv;
-
- switch (prop_id)
- {
-
- case PROP_BUFSIZE:
- size = g_value_get_uint (value);
- priv->len = size;
- priv->pos = 0;
- priv->buffer = g_malloc (priv->len);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_buffered_output_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GBufferedOutputStream *buffered_stream;
- GBufferedOutputStreamPrivate *priv;
-
- buffered_stream = G_BUFFERED_OUTPUT_STREAM (object);
- priv = buffered_stream->priv;
-
- switch (prop_id)
- {
-
- case PROP_BUFSIZE:
- g_value_set_uint (value, priv->len);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_buffered_output_stream_finalize (GObject *object)
-{
- GBufferedOutputStream *stream;
- GBufferedOutputStreamPrivate *priv;
-
- stream = G_BUFFERED_OUTPUT_STREAM (object);
- priv = stream->priv;
-
- g_free (priv->buffer);
-
- if (G_OBJECT_CLASS (g_buffered_output_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_buffered_output_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_buffered_output_stream_init (GBufferedOutputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_BUFFERED_OUTPUT_STREAM,
- GBufferedOutputStreamPrivate);
-
-}
-
-GOutputStream *
-g_buffered_output_stream_new (GOutputStream *base_stream)
-{
- GOutputStream *stream;
-
- g_assert (base_stream != NULL);
-
- stream = g_object_new (G_TYPE_BUFFERED_OUTPUT_STREAM,
- "base-stream", base_stream,
- NULL);
-
- return stream;
-}
-
-GOutputStream *
-g_buffered_output_stream_new_sized (GOutputStream *base_stream,
- guint size)
-{
- GOutputStream *stream;
-
- g_assert (base_stream != NULL);
-
- stream = g_object_new (G_TYPE_BUFFERED_OUTPUT_STREAM,
- "base-stream", base_stream,
- "buffer-size", size,
- NULL);
-
- return stream;
-}
-
-static gboolean
-flush_buffer (GBufferedOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GBufferedOutputStreamPrivate *priv;
- GOutputStream *base_stream;
- gboolean res;
- gsize bytes_written;
- gsize count;
-
- priv = stream->priv;
- bytes_written = 0;
- base_stream = G_FILTER_OUTPUT_STREAM (stream)->base_stream;
-
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (base_stream), FALSE);
-
- res = g_output_stream_write_all (base_stream,
- priv->buffer,
- priv->pos,
- &bytes_written,
- cancellable,
- error);
-
- count = priv->pos - bytes_written;
-
- if (count > 0)
- g_memmove (priv->buffer, priv->buffer + bytes_written, count);
-
- priv->pos -= bytes_written;
-
- return res;
-}
-
-static gssize
-g_buffered_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GBufferedOutputStream *bstream;
- GBufferedOutputStreamPrivate *priv;
- gboolean res;
- gsize n;
-
- bstream = G_BUFFERED_OUTPUT_STREAM (stream);
- priv = bstream->priv;
-
- n = priv->len - priv->pos;
-
- if (n == 0)
- {
- res = flush_buffer (bstream, cancellable, error);
-
- if (res == FALSE)
- return -1;
-
-
- n = priv->len - priv->pos;
- }
-
- count = MIN (count, n);
- memcpy (priv->buffer + priv->pos, buffer, count);
- priv->pos += count;
-
- return count;
-}
-
-static gboolean
-g_buffered_output_stream_flush (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GBufferedOutputStream *bstream;
- GBufferedOutputStreamPrivate *priv;
- GOutputStream *base_stream;
- gboolean res;
-
- bstream = G_BUFFERED_OUTPUT_STREAM (stream);
- priv = bstream->priv;
- base_stream = G_FILTER_OUTPUT_STREAM (stream)->base_stream;
-
- res = flush_buffer (bstream, cancellable, error);
-
- if (res == FALSE) {
- return FALSE;
- }
-
- res = g_output_stream_flush (base_stream,
- cancellable,
- error);
- return res;
-}
-
-static gboolean
-g_buffered_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GBufferedOutputStream *bstream;
- GBufferedOutputStreamPrivate *priv;
- GOutputStream *base_stream;
- gboolean res;
-
- bstream = G_BUFFERED_OUTPUT_STREAM (stream);
- priv = bstream->priv;
- base_stream = G_FILTER_OUTPUT_STREAM (bstream)->base_stream;
-
- res = flush_buffer (bstream, cancellable, error);
-
- /* report the first error but still close the stream */
- if (res)
- {
- res = g_output_stream_close (base_stream,
- cancellable,
- error);
- }
- else
- {
- g_output_stream_close (base_stream,
- cancellable,
- NULL);
- }
-
- return res;
-}
-
-/* ************************** */
-/* Async stuff implementation */
-/* ************************** */
-typedef struct {
-
- guint flush_stream : 1;
- guint close_stream : 1;
-
-} FlushData;
-
-static void
-free_flush_data (gpointer data)
-{
- g_slice_free (FlushData, data);
-}
-
-/* This function is used by all three (i.e.
- * _write, _flush, _close) functions since
- * all of them will need to flush the buffer
- * and so closing and writing is just a special
- * case of flushing + some addition stuff */
-static void
-flush_buffer_thread (GSimpleAsyncResult *result,
- GObject *object,
- GCancellable *cancellable)
-{
- GBufferedOutputStream *stream;
- GOutputStream *base_stream;
- FlushData *fdata;
- gboolean res;
- GError *error = NULL;
-
- stream = G_BUFFERED_OUTPUT_STREAM (object);
- fdata = g_simple_async_result_get_op_res_gpointer (result);
- base_stream = G_FILTER_OUTPUT_STREAM (stream)->base_stream;
-
- res = flush_buffer (stream, cancellable, &error);
-
- /* if flushing the buffer didn't work don't even bother
- * to flush the stream but just report that error */
- if (res && fdata->flush_stream)
- {
- res = g_output_stream_flush (base_stream,
- cancellable,
- &error);
- }
-
- if (fdata->close_stream)
- {
-
- /* if flushing the buffer or the stream returned
- * an error report that first error but still try
- * close the stream */
- if (res == FALSE)
- {
- g_output_stream_close (base_stream,
- cancellable,
- NULL);
- }
- else
- {
- res = g_output_stream_close (base_stream,
- cancellable,
- &error);
- }
-
- }
-
- if (res == FALSE)
- {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- }
-}
-
-typedef struct {
-
- FlushData fdata;
-
- gsize count;
- const void *buffer;
-
-} WriteData;
-
-static void
-free_write_data (gpointer data)
-{
- g_slice_free (WriteData, data);
-}
-
-static void
-g_buffered_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GBufferedOutputStream *buffered_stream;
- GBufferedOutputStreamPrivate *priv;
- GSimpleAsyncResult *res;
- WriteData *wdata;
-
- buffered_stream = G_BUFFERED_OUTPUT_STREAM (stream);
- priv = buffered_stream->priv;
-
- wdata = g_slice_new (WriteData);
- wdata->count = count;
- wdata->buffer = buffer;
-
- res = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- data,
- g_buffered_output_stream_write_async);
-
- g_simple_async_result_set_op_res_gpointer (res, wdata, free_write_data);
-
- /* if we have space left directly call the
- * callback (from idle) otherwise schedule a buffer
- * flush in the thread. In both cases the actual
- * copying of the data to the buffer will be done in
- * the write_finish () func since that should
- * be fast enough */
- if (priv->len - priv->pos > 0)
- {
- g_simple_async_result_complete_in_idle (res);
- }
- else
- {
- wdata->fdata.flush_stream = FALSE;
- wdata->fdata.close_stream = FALSE;
- g_simple_async_result_run_in_thread (res,
- flush_buffer_thread,
- io_priority,
- cancellable);
- g_object_unref (res);
- }
-}
-
-static gssize
-g_buffered_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GBufferedOutputStreamPrivate *priv;
- GBufferedOutputStream *buffered_stream;
- GSimpleAsyncResult *simple;
- WriteData *wdata;
- gssize count;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- buffered_stream = G_BUFFERED_OUTPUT_STREAM (stream);
- priv = buffered_stream->priv;
-
- g_assert (g_simple_async_result_get_source_tag (simple) ==
- g_buffered_output_stream_write_async);
-
- wdata = g_simple_async_result_get_op_res_gpointer (simple);
-
- /* Now do the real copying of data to the buffer */
- count = priv->len - priv->pos;
- count = MIN (wdata->count, count);
-
- memcpy (priv->buffer + priv->pos, wdata->buffer, count);
-
- priv->pos += count;
-
- return count;
-}
-
-static void
-g_buffered_output_stream_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GSimpleAsyncResult *res;
- FlushData *fdata;
-
- fdata = g_slice_new (FlushData);
- fdata->flush_stream = TRUE;
- fdata->close_stream = FALSE;
-
- res = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- data,
- g_buffered_output_stream_flush_async);
-
- g_simple_async_result_set_op_res_gpointer (res, fdata, free_flush_data);
-
- g_simple_async_result_run_in_thread (res,
- flush_buffer_thread,
- io_priority,
- cancellable);
- g_object_unref (res);
-}
-
-static gboolean
-g_buffered_output_stream_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_assert (g_simple_async_result_get_source_tag (simple) ==
- g_buffered_output_stream_flush_async);
-
- return TRUE;
-}
-
-static void
-g_buffered_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GSimpleAsyncResult *res;
- FlushData *fdata;
-
- fdata = g_slice_new (FlushData);
- fdata->close_stream = TRUE;
-
- res = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- data,
- g_buffered_output_stream_close_async);
-
- g_simple_async_result_set_op_res_gpointer (res, fdata, free_flush_data);
-
- g_simple_async_result_run_in_thread (res,
- flush_buffer_thread,
- io_priority,
- cancellable);
- g_object_unref (res);
-}
-
-static gboolean
-g_buffered_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_assert (g_simple_async_result_get_source_tag (simple) ==
- g_buffered_output_stream_flush_async);
-
- return TRUE;
-}
-
-/* vim: ts=2 sw=2 et */
diff --git a/gio/gbufferedoutputstream.h b/gio/gbufferedoutputstream.h
deleted file mode 100644
index e9c1f442..00000000
--- a/gio/gbufferedoutputstream.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __G_BUFFERED_OUTPUT_STREAM_H__
-#define __G_BUFFERED_OUTPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/gfilteroutputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_BUFFERED_OUTPUT_STREAM (g_buffered_output_stream_get_type ())
-#define G_BUFFERED_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_BUFFERED_OUTPUT_STREAM, GBufferedOutputStream))
-#define G_BUFFERED_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_BUFFERED_OUTPUT_STREAM, GBufferedOutputStreamClass))
-#define G_IS_BUFFERED_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_BUFFERED_OUTPUT_STREAM))
-#define G_IS_BUFFERED_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_BUFFERED_OUTPUT_STREAM))
-#define G_BUFFERED_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_BUFFERED_OUTPUT_STREAM, GBufferedOutputStreamClass))
-
-typedef struct _GBufferedOutputStream GBufferedOutputStream;
-typedef struct _GBufferedOutputStreamClass GBufferedOutputStreamClass;
-typedef struct _GBufferedOutputStreamPrivate GBufferedOutputStreamPrivate;
-
-struct _GBufferedOutputStream
-{
- GFilterOutputStream parent;
-
- /*< protected >*/
- GBufferedOutputStreamPrivate *priv;
-};
-
-struct _GBufferedOutputStreamClass
-{
- GOutputStreamClass parent_class;
-};
-
-
-GType g_buffered_output_stream_get_type (void) G_GNUC_CONST;
-GOutputStream* g_buffered_output_stream_new (GOutputStream *base_stream);
-GOutputStream* g_buffered_output_stream_new_sized (GOutputStream *base_stream,
- guint size);
-G_END_DECLS
-
-#endif /* __G_BUFFERED_OUTPUT_STREAM_H__ */
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
deleted file mode 100644
index 3c34ae27..00000000
--- a/gio/gcancellable.c
+++ /dev/null
@@ -1,225 +0,0 @@
-#include <config.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <giotypes.h>
-#include <gioerror.h>
-#include <glib/gi18n-lib.h>
-
-#include "gcancellable.h"
-
-enum {
- CANCELLED,
- LAST_SIGNAL
-};
-
-struct _GCancellable
-{
- GObject parent_instance;
-
- guint cancelled : 1;
- guint allocated_pipe : 1;
- int cancel_pipe[2];
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (GCancellable, g_cancellable, G_TYPE_OBJECT);
-
-static GStaticPrivate current_cancellable = G_STATIC_PRIVATE_INIT;
-G_LOCK_DEFINE_STATIC(cancellable);
-
-static void
-g_cancellable_finalize (GObject *object)
-{
- GCancellable *cancellable = G_CANCELLABLE (object);
-
- if (cancellable->cancel_pipe[0] != -1)
- close (cancellable->cancel_pipe[0]);
-
- if (cancellable->cancel_pipe[1] != -1)
- close (cancellable->cancel_pipe[1]);
-
- if (G_OBJECT_CLASS (g_cancellable_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_cancellable_parent_class)->finalize) (object);
-}
-
-static void
-g_cancellable_class_init (GCancellableClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_cancellable_finalize;
-
- signals[CANCELLED] =
- g_signal_new (I_("cancelled"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GCancellableClass, cancelled),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
-}
-
-static void
-set_fd_nonblocking (int fd)
-{
-#ifdef F_GETFL
- glong fcntl_flags;
- fcntl_flags = fcntl (fd, F_GETFL);
-
-#ifdef O_NONBLOCK
- fcntl_flags |= O_NONBLOCK;
-#else
- fcntl_flags |= O_NDELAY;
-#endif
-
- fcntl (fd, F_SETFL, fcntl_flags);
-#endif
-}
-
-static void
-g_cancellable_open_pipe (GCancellable *cancellable)
-{
- if (pipe (cancellable->cancel_pipe) == 0)
- {
- /* Make them nonblocking, just to be sure we don't block
- * on errors and stuff
- */
- set_fd_nonblocking (cancellable->cancel_pipe[0]);
- set_fd_nonblocking (cancellable->cancel_pipe[1]);
- }
-}
-
-static void
-g_cancellable_init (GCancellable *cancellable)
-{
- cancellable->cancel_pipe[0] = -1;
- cancellable->cancel_pipe[1] = -1;
-}
-
-GCancellable *
-g_cancellable_new (void)
-{
- return g_object_new (G_TYPE_CANCELLABLE, NULL);
-}
-
-void
-g_push_current_cancellable (GCancellable *cancellable)
-{
- GSList *l;
-
- l = g_static_private_get (&current_cancellable);
- l = g_slist_prepend (l, cancellable);
- g_static_private_set (&current_cancellable, l, NULL);
-}
-
-void
-g_pop_current_cancellable (GCancellable *cancellable)
-{
- GSList *l;
-
- l = g_static_private_get (&current_cancellable);
-
- g_assert (l != NULL);
- g_assert (l->data == cancellable);
-
- l = g_slist_delete_link (l, l);
- g_static_private_set (&current_cancellable, l, NULL);
-}
-
-
-GCancellable *
-g_get_current_cancellable (void)
-{
- GSList *l;
-
- l = g_static_private_get (&current_cancellable);
- if (l == NULL)
- return NULL;
-
- return G_CANCELLABLE (l->data);
-}
-
-void
-g_cancellable_reset (GCancellable *cancellable)
-{
- G_LOCK(cancellable);
- /* Make sure we're not leaving old cancel state around */
- if (cancellable->cancelled)
- {
- char ch;
- if (cancellable->cancel_pipe[0] != -1)
- read (cancellable->cancel_pipe[0], &ch, 1);
- cancellable->cancelled = FALSE;
- }
- G_UNLOCK(cancellable);
-}
-
-/* Safe to call with NULL */
-gboolean
-g_cancellable_is_cancelled (GCancellable *cancellable)
-{
- return cancellable != NULL && cancellable->cancelled;
-}
-
-gboolean
-g_cancellable_set_error_if_cancelled (GCancellable *cancellable,
- GError **error)
-{
- if (g_cancellable_is_cancelled (cancellable))
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_CANCELLED,
- _("Operation was cancelled"));
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* May return -1 if fds not supported, or on errors */
-int
-g_cancellable_get_fd (GCancellable *cancellable)
-{
- int fd;
- if (cancellable == NULL)
- return -1;
-
- G_LOCK(cancellable);
- if (!cancellable->allocated_pipe)
- {
- cancellable->allocated_pipe = TRUE;
- g_cancellable_open_pipe (cancellable);
- }
-
- fd = cancellable->cancel_pipe[0];
- G_UNLOCK(cancellable);
-
- return fd;
-}
-
-/* This is safe to call from another thread */
-void
-g_cancellable_cancel (GCancellable *cancellable)
-{
- G_LOCK(cancellable);
- if (cancellable != NULL &&
- !cancellable->cancelled)
- {
- char ch = 'x';
- cancellable->cancelled = TRUE;
- if (cancellable->cancel_pipe[1] != -1)
- write (cancellable->cancel_pipe[1], &ch, 1);
- }
- G_UNLOCK(cancellable);
-
- g_object_ref (cancellable);
- g_signal_emit (cancellable, signals[CANCELLED], 0);
- g_object_unref (cancellable);
-}
-
-
diff --git a/gio/gcancellable.h b/gio/gcancellable.h
deleted file mode 100644
index 7cb8101f..00000000
--- a/gio/gcancellable.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __G_CANCELLABLE_H__
-#define __G_CANCELLABLE_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_CANCELLABLE (g_cancellable_get_type ())
-#define G_CANCELLABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_CANCELLABLE, GCancellable))
-#define G_CANCELLABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_CANCELLABLE, GCancellableClass))
-#define G_IS_CANCELLABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_CANCELLABLE))
-#define G_IS_CANCELLABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_CANCELLABLE))
-#define G_CANCELLABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_CANCELLABLE, GCancellableClass))
-
-typedef struct _GCancellable GCancellable;
-typedef struct _GCancellableClass GCancellableClass;
-
-struct _GCancellableClass
-{
- GObjectClass parent_class;
-
- void (* cancelled) (GCancellable *cancellable);
-};
-
-GType g_cancellable_get_type (void) G_GNUC_CONST;
-
-GCancellable *g_cancellable_new (void);
-
-/* These are only safe to call inside a cancellable op */
-gboolean g_cancellable_is_cancelled (GCancellable *cancellable);
-gboolean g_cancellable_set_error_if_cancelled (GCancellable *cancellable,
- GError **error);
-int g_cancellable_get_fd (GCancellable *cancellable);
-GCancellable *g_get_current_cancellable (void);
-void g_push_current_cancellable (GCancellable *cancellable);
-void g_pop_current_cancellable (GCancellable *cancellable);
-void g_cancellable_reset (GCancellable *cancellable);
-
-
-/* This is safe to call from another thread */
-void g_cancellable_cancel (GCancellable *cancellable);
-
-G_END_DECLS
-
-#endif /* __G_CANCELLABLE_H__ */
diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c
deleted file mode 100644
index 6b1046ff..00000000
--- a/gio/gcontenttype.c
+++ /dev/null
@@ -1,739 +0,0 @@
-#include <config.h>
-
-#include <glib/gi18n-lib.h>
-
-#include <sys/types.h>
-#include <dirent.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "gcontenttypeprivate.h"
-
-/* A content type is a platform specific string that defines the type
- of a file. On unix it is a mime type, on win32 it is an extension string
- like ".doc", ".txt" or a percieved string like "audio". Such strings
- can be looked up in the registry at HKEY_CLASSES_ROOT.
-*/
-
-#ifdef G_OS_WIN32
-
-#include <windows.h>
-
-static char *
-get_registry_classes_key (const char *subdir,
- const wchar_t *key_name)
-{
- wchar_t *wc_key;
- HKEY reg_key = NULL;
- DWORD key_type;
- DWORD nbytes;
- char *value_utf8;
-
- value_utf8 = NULL;
-
- nbytes = 0;
- wc_key = g_utf8_to_utf16 (subdir, -1, NULL, NULL, NULL);
- if (RegOpenKeyExW (HKEY_CLASSES_ROOT, wc_key, 0,
- KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS &&
- RegQueryValueExW (reg_key, key_name, 0,
- &key_type, NULL, &nbytes) == ERROR_SUCCESS &&
- key_type == REG_SZ)
- {
- wchar_t *wc_temp = g_new (wchar_t, (nbytes+1)/2 + 1);
- RegQueryValueExW (reg_key, key_name, 0,
- &key_type, (LPBYTE) wc_temp, &nbytes);
- wc_temp[nbytes/2] = '\0';
- value_utf8 = g_utf16_to_utf8 (wc_temp, -1, NULL, NULL, NULL);
- g_free (wc_temp);
- }
- g_free (wc_key);
-
- if (reg_key != NULL)
- RegCloseKey (reg_key);
-
- return value_utf8;
-}
-
-gboolean
-g_content_type_equals (const char *type1,
- const char *type2)
-{
- char *progid1, *progid2;
- gboolean res;
-
- g_return_val_if_fail (type1 != NULL, FALSE);
- g_return_val_if_fail (type2 != NULL, FALSE);
-
- if (g_ascii_strcasecmp (type1, type2) == 0)
- return TRUE;
-
- res = FALSE;
- progid1 = get_registry_classes_key (type1, NULL);
- progid2 = get_registry_classes_key (type2, NULL);
- if (progid1 != NULL && progid2 != NULL &&
- strcmp (progid1, progid2) == 0)
- res = TRUE;
- g_free (progid1);
- g_free (progid2);
-
- return res;
-}
-
-gboolean
-g_content_type_is_a (const char *type,
- const char *supertype)
-{
- gboolean res;
- char *value_utf8;
-
- g_return_val_if_fail (type != NULL, FALSE);
- g_return_val_if_fail (supertype != NULL, FALSE);
-
- if (g_content_type_equals (type, supertype))
- return TRUE;
-
- res = FALSE;
- value_utf8 = get_registry_classes_key (type, L"PerceivedType");
- if (value_utf8 && strcmp (value_utf8, supertype) == 0)
- res = TRUE;
- g_free (value_utf8);
-
- return res;
-}
-
-gboolean
-g_content_type_is_unknown (const char *type)
-{
- return strcmp ("*", type) == 0;
-}
-
-char *
-g_content_type_get_description (const char *type)
-{
- char *progid;
- char *description;
-
- progid = get_registry_classes_key (type, NULL);
- if (progid)
- {
- description = get_registry_classes_key (progid, NULL);
- g_free (progid);
-
- if (description)
- return description;
- }
-
- if (g_content_type_is_unknown (type))
- return g_strdup (_("Unknown type"));
- return g_strdup_printf (_("%s filetype"), type);
-}
-
-char *
-g_content_type_get_mime_type (const char *type)
-{
- char *mime;
-
- mime = get_registry_classes_key (type, L"Content Type");
- if (mime)
- return mime;
- else if (g_content_type_is_unknown (type))
- return g_strdup ("application/octet-stream");
- else if (*type == '.')
- return g_strdup_printf ("application/x-ext-%s", type+1);
- /* TODO: Map "image" to "image/ *", etc? */
-
- return g_strdup ("application/octet-stream");
-}
-
-GIcon *
-g_content_type_get_icon (const char *type)
-{
- /* TODO: How do we represent icons???
- In the registry they are the default value of
- HKEY_CLASSES_ROOT\<progid>\DefaultIcon with typical values like:
- <type>: <value>
- REG_EXPAND_SZ: %SystemRoot%\System32\Wscript.exe,3
- REG_SZ: shimgvw.dll,3
- */
- return NULL;
-}
-
-gboolean
-g_content_type_can_be_executable (const char *type)
-{
- if (strcmp (type, ".exe") == 0 ||
- strcmp (type, ".com") == 0 ||
- strcmp (type, ".bat") == 0)
- return TRUE;
- return FALSE;
-}
-
-static gboolean
-looks_like_text (const guchar *data, gsize data_size)
-{
- gsize i;
- for (i = 0; i < data_size; i++)
- {
- if g_ascii_iscntrl (data[i])
- return FALSE;
- }
- return TRUE;
-}
-
-char *
-g_content_type_guess (const char *filename,
- const guchar *data,
- gsize data_size,
- gboolean *result_uncertain)
-{
- char *basename;
- char *type;
- char *dot;
-
- type = NULL;
-
- if (filename)
- {
- basename = g_path_get_basename (filename);
- dot = strrchr (basename, '.');
- if (dot)
- type = g_strdup (dot);
- g_free (basename);
- }
-
- if (type)
- return type;
-
- if (data && looks_like_text (data, data_size))
- return g_strdup (".txt");
-
- return g_strdup ("*");
-}
-
-
-GList *
-g_get_registered_content_types (void)
-{
- DWORD index;
- wchar_t keyname[256];
- DWORD key_len;
- char *key_utf8;
- GList *types;
-
- types = NULL;
- index = 0;
- key_len = 256;
- while (RegEnumKeyExW(HKEY_CLASSES_ROOT,
- index,
- keyname,
- &key_len,
- NULL,
- NULL,
- NULL,
- NULL) == ERROR_SUCCESS)
- {
- key_utf8 = g_utf16_to_utf8 (keyname, -1, NULL, NULL, NULL);
- if (key_utf8)
- {
- if (*key_utf8 == '.')
- types = g_list_prepend (types, key_utf8);
- else
- g_free (key_utf8);
- }
- index++;
- key_len = 256;
- }
-
- return g_list_reverse (types);
-}
-
-#else /* !G_OS_WIN32 - Unix specific version */
-
-#define XDG_PREFIX _gio_xdg
-#include "xdgmime/xdgmime.h"
-
-/* We lock this mutex whenever we modify global state in this module. */
-G_LOCK_DEFINE_STATIC (gio_xdgmime);
-
-gsize
-_g_unix_content_type_get_sniff_len (void)
-{
- gsize size;
-
- G_LOCK (gio_xdgmime);
- size = xdg_mime_get_max_buffer_extents ();
- G_UNLOCK (gio_xdgmime);
-
- return size;
-}
-
-char *
-_g_unix_content_type_unalias (const char *type)
-{
- char *res;
-
- G_LOCK (gio_xdgmime);
- res = g_strdup (xdg_mime_unalias_mime_type (type));
- G_UNLOCK (gio_xdgmime);
-
- return res;
-}
-
-char **
-_g_unix_content_type_get_parents (const char *type)
-{
- const char *umime;
- const char **parents;
- GPtrArray *array;
- int i;
-
- array = g_ptr_array_new ();
-
- G_LOCK (gio_xdgmime);
-
- umime = xdg_mime_unalias_mime_type (type);
- g_ptr_array_add (array, g_strdup (umime));
-
- parents = xdg_mime_get_mime_parents (umime);
- for (i = 0; parents && parents[i] != NULL; i++)
- g_ptr_array_add (array, g_strdup (parents[i]));
-
- G_UNLOCK (gio_xdgmime);
-
- g_ptr_array_add (array, NULL);
-
- return (char **)g_ptr_array_free (array, FALSE);
-}
-
-gboolean
-g_content_type_equals (const char *type1,
- const char *type2)
-{
- gboolean res;
-
- g_return_val_if_fail (type1 != NULL, FALSE);
- g_return_val_if_fail (type2 != NULL, FALSE);
-
- G_LOCK (gio_xdgmime);
- res = xdg_mime_mime_type_equal (type1, type2);
- G_UNLOCK (gio_xdgmime);
-
- return res;
-}
-
-gboolean
-g_content_type_is_a (const char *type,
- const char *supertype)
-{
- gboolean res;
-
- g_return_val_if_fail (type != NULL, FALSE);
- g_return_val_if_fail (supertype != NULL, FALSE);
-
- G_LOCK (gio_xdgmime);
- res = xdg_mime_mime_type_subclass (type, supertype);
- G_UNLOCK (gio_xdgmime);
-
- return res;
-}
-
-gboolean
-g_content_type_is_unknown (const char *type)
-{
- return strcmp (XDG_MIME_TYPE_UNKNOWN, type) == 0;
-}
-
-
-typedef enum {
- MIME_TAG_TYPE_OTHER,
- MIME_TAG_TYPE_COMMENT,
-} MimeTagType;
-
-typedef struct {
- int current_type;
- int current_lang_level;
- int comment_lang_level;
- char *comment;
-} MimeParser;
-
-
-static int
-language_level (const char *lang)
-{
- const char * const *lang_list;
- int i;
-
- /* The returned list is sorted from most desirable to least
- desirable and always contains the default locale "C". */
- lang_list = g_get_language_names ();
-
- for (i = 0; lang_list[i]; i++)
- if (strcmp (lang_list[i], lang) == 0)
- return 1000-i;
-
- return 0;
-}
-
-static void
-mime_info_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
-{
- int i;
- const char *lang;
- MimeParser *parser = user_data;
-
- if (strcmp (element_name, "comment") == 0)
- {
- lang = "C";
- for (i = 0; attribute_names[i]; i++)
- if (strcmp (attribute_names[i], "xml:lang") == 0)
- {
- lang = attribute_values[i];
- break;
- }
-
- parser->current_lang_level = language_level (lang);
- parser->current_type = MIME_TAG_TYPE_COMMENT;
- }
- else
- parser->current_type = MIME_TAG_TYPE_OTHER;
-
-}
-
-static void
-mime_info_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
-{
- MimeParser *parser = user_data;
-
- parser->current_type = MIME_TAG_TYPE_OTHER;
-}
-
-static void
-mime_info_text (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error)
-{
- MimeParser *parser = user_data;
-
- if (parser->current_type == MIME_TAG_TYPE_COMMENT &&
- parser->current_lang_level > parser->comment_lang_level)
- {
- g_free (parser->comment);
- parser->comment = g_strndup (text, text_len);
- parser->comment_lang_level = parser->current_lang_level;
- }
-}
-
-static char *
-load_comment_for_mime_helper (const char *dir, const char *basename)
-{
- GMarkupParseContext *context;
- char *filename, *data;
- gsize len;
- gboolean res;
- MimeParser parse_data = {0};
- GMarkupParser parser = {
- mime_info_start_element,
- mime_info_end_element,
- mime_info_text,
- };
-
- filename = g_build_filename (dir, "mime", basename, NULL);
-
- res = g_file_get_contents (filename, &data, &len, NULL);
- g_free (filename);
- if (!res)
- return NULL;
-
- context = g_markup_parse_context_new (&parser, 0, &parse_data, NULL);
- res = g_markup_parse_context_parse (context, data, len, NULL);
- g_free (data);
- g_markup_parse_context_free (context);
-
- if (!res)
- return NULL;
-
- return parse_data.comment;
-}
-
-
-static char *
-load_comment_for_mime (const char *mimetype)
-{
- const char * const* dirs;
- char *basename;
- char *comment;
- int i;
-
- basename = g_strdup_printf ("%s.xml", mimetype);
-
- comment = load_comment_for_mime_helper (g_get_user_data_dir (), basename);
- if (comment)
- {
- g_free (basename);
- return comment;
- }
-
- dirs = g_get_system_data_dirs ();
-
- for (i = 0; dirs[i] != NULL; i++)
- {
- comment = load_comment_for_mime_helper (dirs[i], basename);
- if (comment)
- {
- g_free (basename);
- return comment;
- }
- }
- g_free (basename);
-
- return g_strdup_printf (_("%s type"), mimetype);
-}
-
-char *
-g_content_type_get_description (const char *type)
-{
- static GHashTable *type_comment_cache = NULL;
- char *comment;
-
- G_LOCK (gio_xdgmime);
- if (type_comment_cache == NULL)
- type_comment_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
- comment = g_hash_table_lookup (type_comment_cache, type);
- comment = g_strdup (comment);
- G_UNLOCK (gio_xdgmime);
-
- if (comment != NULL)
- return comment;
-
- comment = load_comment_for_mime (type);
-
- G_LOCK (gio_xdgmime);
- g_hash_table_insert (type_comment_cache,
- g_strdup (type),
- g_strdup (comment));
- G_UNLOCK (gio_xdgmime);
-
- return comment;
-}
-
-char *
-g_content_type_get_mime_type (const char *type)
-{
- return g_strdup (type);
-}
-
-GIcon *
-g_content_type_get_icon (const char *type)
-{
- /* TODO: Implement */
- return NULL;
-}
-
-gboolean
-g_content_type_can_be_executable (const char *type)
-{
- if (g_content_type_is_a (type, "application/x-executable") ||
- g_content_type_is_a (type, "text/plain"))
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-looks_like_text (const guchar *data, gsize data_size)
-{
- gsize i;
- for (i = 0; i < data_size; i++)
- {
- if g_ascii_iscntrl (data[i])
- return FALSE;
- }
- return TRUE;
-}
-
-char *
-g_content_type_guess (const char *filename,
- const guchar *data,
- gsize data_size,
- gboolean *result_uncertain)
-{
- char *basename;
- const char *name_mimetypes[10], *sniffed_mimetype;
- char *mimetype;
- int i;
- int n_name_mimetypes;
- int sniffed_prio;
-
- sniffed_prio = 0;
- n_name_mimetypes = 0;
- sniffed_mimetype = XDG_MIME_TYPE_UNKNOWN;
-
- if (result_uncertain)
- *result_uncertain = FALSE;
-
- G_LOCK (gio_xdgmime);
-
- if (filename)
- {
- basename = g_path_get_basename (filename);
- n_name_mimetypes = xdg_mime_get_mime_types_from_file_name (basename, name_mimetypes, 10);
- g_free (basename);
- }
-
- /* Got an extension match, and no conflicts. This is it. */
- if (n_name_mimetypes == 1)
- return g_strdup (name_mimetypes[0]);
-
- if (data)
- {
- sniffed_mimetype = xdg_mime_get_mime_type_for_data (data, data_size, &sniffed_prio);
- if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN &&
- data &&
- looks_like_text (data, data_size))
- sniffed_mimetype = "text/plain";
- }
-
- if (n_name_mimetypes == 0)
- {
- if (sniffed_mimetype == XDG_MIME_TYPE_UNKNOWN &&
- result_uncertain)
- *result_uncertain = TRUE;
-
- mimetype = g_strdup (sniffed_mimetype);
- }
- else
- {
- mimetype = NULL;
- if (sniffed_mimetype != XDG_MIME_TYPE_UNKNOWN)
- {
- if (sniffed_prio >= 80) /* High priority sniffing match, use that */
- mimetype = g_strdup (sniffed_mimetype);
- else
- {
- /* There are conflicts between the name matches and we have a sniffed
- type, use that as a tie breaker. */
-
- for (i = 0; i < n_name_mimetypes; i++)
- {
- if ( xdg_mime_mime_type_subclass (name_mimetypes[i], sniffed_mimetype))
- {
- /* This nametype match is derived from (or the same as) the sniffed type).
- This is probably it. */
- mimetype = g_strdup (name_mimetypes[i]);
- break;
- }
- }
- }
- }
-
- if (mimetype == NULL)
- {
- /* Conflicts, and sniffed type was no help or not there. guess on the first one */
- mimetype = g_strdup (name_mimetypes[0]);
- if (result_uncertain)
- *result_uncertain = TRUE;
- }
- }
-
- G_UNLOCK (gio_xdgmime);
-
- return mimetype;
-}
-
-static gboolean
-foreach_mimetype (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- GList **l = user_data;
-
- *l = g_list_prepend (*l, (char *)key);
- return TRUE;
-}
-
-static void
-enumerate_mimetypes_subdir (const char *dir, const char *prefix, GHashTable *mimetypes)
-{
- DIR *d;
- struct dirent *ent;
- char *mimetype;
-
- d = opendir (dir);
- if (d)
- {
- while ((ent = readdir (d)) != NULL)
- {
- if (g_str_has_suffix (ent->d_name, ".xml"))
- {
- mimetype = g_strdup_printf ("%s/%.*s", prefix, (int) strlen (ent->d_name) - 4, ent->d_name);
- g_hash_table_insert (mimetypes, mimetype, NULL);
- }
- }
- closedir (d);
- }
-}
-
-static void
-enumerate_mimetypes_dir (const char *dir, GHashTable *mimetypes)
-{
- DIR *d;
- struct dirent *ent;
- char *mimedir;
- char *name;
-
- mimedir = g_build_filename (dir, "mime", NULL);
-
- d = opendir (mimedir);
- if (d)
- {
- while ((ent = readdir (d)) != NULL)
- {
- if (strcmp (ent->d_name, "packages") != 0)
- {
- name = g_build_filename (mimedir, ent->d_name, NULL);
- if (g_file_test (name, G_FILE_TEST_IS_DIR))
- enumerate_mimetypes_subdir (name, ent->d_name, mimetypes);
- g_free (name);
- }
- }
- closedir (d);
- }
-
- g_free (mimedir);
-}
-
-GList *
-g_get_registered_content_types (void)
-{
- const char * const* dirs;
- GHashTable *mimetypes;
- int i;
- GList *l;
-
- mimetypes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-
- enumerate_mimetypes_dir (g_get_user_data_dir (), mimetypes);
- dirs = g_get_system_data_dirs ();
-
- for (i = 0; dirs[i] != NULL; i++)
- enumerate_mimetypes_dir (dirs[i], mimetypes);
-
- l = NULL;
- g_hash_table_foreach_steal (mimetypes, foreach_mimetype, &l);
- g_hash_table_destroy (mimetypes);
-
- return l;
-}
-
-#endif /* Unix version */
diff --git a/gio/gcontenttype.h b/gio/gcontenttype.h
deleted file mode 100644
index 34cd4199..00000000
--- a/gio/gcontenttype.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __G_CONTENT_TYPE_H__
-#define __G_CONTENT_TYPE_H__
-
-#include <glib.h>
-#include <gio/gicon.h>
-
-G_BEGIN_DECLS
-
-gboolean g_content_type_equals (const char *type1,
- const char *type2);
-gboolean g_content_type_is_a (const char *type,
- const char *supertype);
-gboolean g_content_type_is_unknown (const char *type);
-char * g_content_type_get_description (const char *type);
-char * g_content_type_get_mime_type (const char *type);
-GIcon * g_content_type_get_icon (const char *type);
-gboolean g_content_type_can_be_executable (const char *type);
-
-char * g_content_type_guess (const char *filename,
- const guchar *data,
- gsize data_size,
- gboolean *result_uncertain );
-
-GList * g_get_registered_content_types (void);
-
-G_END_DECLS
-
-#endif /* __G_CONTENT_TYPE_H__ */
diff --git a/gio/gcontenttypeprivate.h b/gio/gcontenttypeprivate.h
deleted file mode 100644
index 979377e6..00000000
--- a/gio/gcontenttypeprivate.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __G_CONTENT_TYPE_PRIVATE_H__
-#define __G_CONTENT_TYPE_PRIVATE_H__
-
-#include "gcontenttype.h"
-
-G_BEGIN_DECLS
-
-gsize _g_unix_content_type_get_sniff_len (void);
-char * _g_unix_content_type_unalias (const char *type);
-char **_g_unix_content_type_get_parents (const char *type);
-
-G_END_DECLS
-
-#endif /* __G_CONTENT_TYPE_PRIVATE_H__ */
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
deleted file mode 100644
index fed7c1a2..00000000
--- a/gio/gdesktopappinfo.c
+++ /dev/null
@@ -1,1678 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/wait.h>
-
-#include "gcontenttypeprivate.h"
-#include "gdesktopappinfo.h"
-#include "gioerror.h"
-#include "gthemedicon.h"
-#include "gfileicon.h"
-#include <glib/gi18n-lib.h>
-#include <glib/gstdio.h>
-
-static void g_desktop_app_info_iface_init (GAppInfoIface *iface);
-
-static GList *get_all_desktop_entries_for_mime_type (const char *base_mime_type);
-static void mime_info_cache_reload (const char *dir);
-
-struct _GDesktopAppInfo
-{
- GObject parent_instance;
-
- char *desktop_id;
- char *filename;
-
- char *name;
- char *comment;
- gboolean nodisplay;
- char *icon;
- char **only_show_in;
- char **not_show_in;
- char *try_exec;
- char *exec;
- char *binary;
- char *path;
- gboolean terminal;
- gboolean startup_notify;
-};
-
-G_DEFINE_TYPE_WITH_CODE (GDesktopAppInfo, g_desktop_app_info, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_APP_INFO,
- g_desktop_app_info_iface_init))
-
-static gpointer
-search_path_init (gpointer data)
-{
- char **args = NULL;
- const char * const *data_dirs;
- const char *user_data_dir;
- int i, length, j;
-
- data_dirs = g_get_system_data_dirs ();
- for (length = 0; data_dirs[length] != NULL; length++)
- ;
-
- args = g_new (char *, length + 2);
-
- j = 0;
- user_data_dir = g_get_user_data_dir ();
- args[j++] = g_build_filename (user_data_dir, "applications", NULL);
- for (i = 0; i < length; i++)
- args[j++] = g_build_filename (data_dirs[i],
- "applications", NULL);
- args[j++] = NULL;
-
- return args;
-}
-
-static const char * const *
-get_applications_search_path (void)
-{
- static GOnce once_init = G_ONCE_INIT;
- return g_once (&once_init, search_path_init, NULL);
-}
-
-static void
-g_desktop_app_info_finalize (GObject *object)
-{
- GDesktopAppInfo *info;
-
- info = G_DESKTOP_APP_INFO (object);
-
- g_free (info->desktop_id);
- g_free (info->filename);
- g_free (info->name);
- g_free (info->comment);
- g_free (info->icon);
- g_strfreev (info->only_show_in);
- g_strfreev (info->not_show_in);
- g_free (info->try_exec);
- g_free (info->exec);
- g_free (info->binary);
- g_free (info->path);
-
- if (G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize) (object);
-}
-
-static void
-g_desktop_app_info_class_init (GDesktopAppInfoClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_desktop_app_info_finalize;
-}
-
-static void
-g_desktop_app_info_init (GDesktopAppInfo *local)
-{
-}
-
-static GDesktopAppInfo *
-g_desktop_app_info_new_from_filename (const char *filename,
- gboolean *hidden)
-{
- GDesktopAppInfo *info;
- GKeyFile *key_file;
- char *start_group;
- char *type;
- char *try_exec;
-
- if (hidden)
- *hidden = FALSE;
-
- key_file = g_key_file_new ();
-
- if (!g_key_file_load_from_file (key_file,
- filename,
- G_KEY_FILE_NONE,
- NULL))
- return NULL;
-
- start_group = g_key_file_get_start_group (key_file);
- if (start_group == NULL || strcmp (start_group, "Desktop Entry") != 0)
- {
- g_free (start_group);
- return NULL;
- }
- g_free (start_group);
-
-
- type = g_key_file_get_string (key_file, "Desktop Entry", "Type", NULL);
- if (type == NULL || strcmp (type, "Application") != 0)
- {
- g_free (type);
- return NULL;
- }
- g_free (type);
-
- if (g_key_file_get_boolean (key_file, "Desktop Entry", "Hidden", NULL))
- {
- if (hidden)
- *hidden = TRUE;
- return NULL;
- }
-
- try_exec = g_key_file_get_string (key_file, "Desktop Entry", "TryExec", NULL);
- if (try_exec)
- {
- char *t;
- t = g_find_program_in_path (try_exec);
- if (t == NULL)
- {
- g_free (try_exec);
- return NULL;
- }
- }
-
- info = g_object_new (G_TYPE_DESKTOP_APP_INFO, NULL);
- info->filename = g_strdup (filename);
-
- info->name = g_key_file_get_locale_string (key_file, "Desktop Entry", "Name", NULL, NULL);
- info->comment = g_key_file_get_locale_string (key_file, "Desktop Entry", "Comment", NULL, NULL);
- info->nodisplay = g_key_file_get_boolean (key_file, "Desktop Entry", "NoDisplay", NULL);
- info->icon = g_key_file_get_locale_string (key_file, "Desktop Entry", "Icon", NULL, NULL);
- info->only_show_in = g_key_file_get_string_list (key_file, "Desktop Entry", "OnlyShowIn", NULL, NULL);
- info->not_show_in = g_key_file_get_string_list (key_file, "Desktop Entry", "NotShowIn", NULL, NULL);
- info->try_exec = try_exec;
- info->exec = g_key_file_get_string (key_file, "Desktop Entry", "Exec", NULL);
- info->path = g_key_file_get_string (key_file, "Desktop Entry", "Path", NULL);
- info->terminal = g_key_file_get_boolean (key_file, "Desktop Entry", "Terminal", NULL);
- info->startup_notify = g_key_file_get_boolean (key_file, "Desktop Entry", "StartupNotify", NULL);
-
- if (info->exec)
- {
- char *p, *start;
-
- p = info->exec;
- while (*p == ' ')
- p++;
- start = p;
- while (*p != ' ' && *p != 0)
- p++;
-
- info->binary = g_strndup (start, p - start);
- }
-
- return info;
-}
-
-GAppInfo *
-g_desktop_app_info_new (const char *desktop_id)
-{
- GDesktopAppInfo *appinfo;
- const char * const *dirs;
- int i;
- gboolean hidden;
-
-
- dirs = get_applications_search_path ();
-
- for (i = 0; dirs[i] != NULL; i++)
- {
- char *basename;
- char *filename;
- char *p;
-
- basename = g_strdup (desktop_id);
-
- filename = g_build_filename (dirs[i], basename, NULL);
- appinfo = g_desktop_app_info_new_from_filename (filename, &hidden);
- g_free (filename);
- if (appinfo != NULL || hidden)
- {
- g_free (basename);
- goto found;
- }
-
- p = basename;
- while ((p = strchr (p, '-')) != NULL)
- {
- *p = '/';
-
- filename = g_build_filename (dirs[i], basename, NULL);
- appinfo = g_desktop_app_info_new_from_filename (filename, &hidden);
- g_free (filename);
- if (appinfo != NULL || hidden)
- {
- g_free (basename);
- goto found;
- }
- *p = '-';
- p++;
- }
- }
-
- return NULL;
-
- found:
- if (appinfo)
- appinfo->desktop_id = g_strdup (desktop_id);
-
- return G_APP_INFO (appinfo);
-}
-
-static GAppInfo *
-g_desktop_app_info_dup (GAppInfo *appinfo)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
- GDesktopAppInfo *new_info;
-
- new_info = g_object_new (G_TYPE_DESKTOP_APP_INFO, NULL);
-
- new_info->filename = g_strdup (info->filename);
- new_info->desktop_id = g_strdup (info->desktop_id);
-
- new_info->name = g_strdup (info->name);
- new_info->comment = g_strdup (info->comment);
- new_info->nodisplay = info->nodisplay;
- new_info->icon = g_strdup (info->icon);
- new_info->only_show_in = g_strdupv (info->only_show_in);
- new_info->not_show_in = g_strdupv (info->not_show_in);
- new_info->try_exec = g_strdup (info->try_exec);
- new_info->exec = g_strdup (info->exec);
- new_info->binary = g_strdup (info->binary);
- new_info->path = g_strdup (info->path);
- new_info->terminal = info->terminal;
- new_info->startup_notify = info->startup_notify;
-
- return G_APP_INFO (new_info);
-}
-
-static gboolean
-g_desktop_app_info_equal (GAppInfo *appinfo1,
- GAppInfo *appinfo2)
-{
- GDesktopAppInfo *info1 = G_DESKTOP_APP_INFO (appinfo1);
- GDesktopAppInfo *info2 = G_DESKTOP_APP_INFO (appinfo2);
-
- if (info1->binary == NULL ||
- info2->binary == NULL)
- return FALSE;
-
- return strcmp (info1->binary, info2->binary) == 0;
-}
-
-static char *
-g_desktop_app_info_get_name (GAppInfo *appinfo)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
-
- if (info->name == NULL)
- return g_strdup (_("Unnamed"));
- return g_strdup (info->name);
-}
-
-static char *
-g_desktop_app_info_get_description (GAppInfo *appinfo)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
-
- return g_strdup (info->comment);
-}
-
-static GIcon *
-g_desktop_app_info_get_icon (GAppInfo *appinfo)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
- GFile *file;
- GIcon *icon;
-
- if (info->icon == NULL)
- return NULL;
-
- if (g_path_is_absolute (info->icon)) {
- file = g_file_new_for_path (info->icon);
- icon = g_file_icon_new (file);
- g_object_unref (file);
- } else {
- icon = g_themed_icon_new (info->icon);
- }
-
- return icon;
-}
-
-static char *
-expand_macro_single (char macro, const char *uri)
-{
- char *result = NULL, *path;
-
- switch (macro)
- {
- case 'u':
- case 'U':
- result = g_shell_quote (uri);
- break;
- case 'f':
- case 'F':
- path = g_filename_from_uri (uri, NULL, NULL);
- if (path)
- {
- result = g_shell_quote (path);
- g_free (path);
- }
- break;
- case 'd':
- case 'D':
- path = g_filename_from_uri (uri, NULL, NULL);
- if (path)
- {
- result = g_shell_quote (g_path_get_dirname (path));
- g_free (path);
- }
- break;
- case 'n':
- case 'N':
- path = g_filename_from_uri (uri, NULL, NULL);
- if (path)
- {
- result = g_shell_quote (g_path_get_basename (path));
- g_free (path);
- }
- break;
- }
-
- return result;
-}
-
-static void
-expand_macro (char macro, GString *exec, GDesktopAppInfo *info, GList **uri_list)
-{
- GList *uris = *uri_list;
- char *expanded;
-
- g_return_if_fail (uris != NULL);
- g_return_if_fail (exec != NULL);
-
- if (uris == NULL)
- return;
-
- switch (macro)
- {
- case 'u':
- case 'f':
- case 'd':
- case 'n':
- expanded = expand_macro_single (macro, uris->data);
- if (expanded)
- {
- g_string_append (exec, expanded);
- g_free (expanded);
- }
- uris = uris->next;
- break;
- case 'U':
- case 'F':
- case 'D':
- case 'N':
- while (uris)
- {
- expanded = expand_macro_single (macro, uris->data);
- if (expanded)
- {
- g_string_append (exec, expanded);
- g_free (expanded);
- }
-
- uris = uris->next;
-
- if (uris != NULL && expanded)
- g_string_append_c (exec, ' ');
- }
- break;
- case 'i':
- if (info->icon)
- {
- g_string_append (exec, "--icon ");
- g_string_append (exec, info->icon);
- }
- break;
- case 'c':
- if (info->name)
- g_string_append (exec, info->name);
- break;
- case 'k':
- if (info->filename)
- g_string_append (exec, info->filename);
- break;
- case 'm': /* deprecated */
- break;
- case '%':
- g_string_append_c (exec, '%');
- break;
- }
-
- *uri_list = uris;
-}
-
-static gboolean
-expand_application_parameters (GDesktopAppInfo *info,
- GList **uris,
- int *argc,
- char ***argv,
- GError **error)
-{
- GList *uri_list = *uris;
- const char *p = info->exec;
- GString *expanded_exec = g_string_new (NULL);
- gboolean res;
-
- if (info->exec == NULL)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Desktop file didn't specify Exec field"));
- return FALSE;
- }
-
- while (*p)
- {
- if (p[0] == '%' && p[1] != '\0')
- {
- expand_macro (p[1], expanded_exec, info, uris);
- p++;
- }
- else
- g_string_append_c (expanded_exec, *p);
-
- p++;
- }
-
- /* No file substitutions */
- if (uri_list == *uris && uri_list != NULL)
- {
- /* If there is no macro default to %f. This is also what KDE does */
- g_string_append_c (expanded_exec, ' ');
- expand_macro ('f', expanded_exec, info, uris);
- }
-
- res = g_shell_parse_argv (expanded_exec->str, argc, argv, error);
- g_string_free (expanded_exec, TRUE);
- return res;
-}
-
-static gboolean
-g_desktop_app_info_launch (GAppInfo *appinfo,
- GList *filenames,
- char **envp,
- GError **error)
-{
- GList *uris;
- char *uri;
- gboolean res;
-
- uris = NULL;
- while (filenames)
- {
- uri = g_filename_to_uri (filenames->data, NULL, NULL);
- if (uri == NULL)
- g_warning ("Invalid filename passed to g_desktop_app_info_launch");
-
- if (uri)
- uris = g_list_prepend (uris, uri);
- }
-
- uris = g_list_reverse (uris);
-
- res = g_app_info_launch_uris (appinfo, uris, envp, error);
-
- g_list_foreach (uris, (GFunc)g_free, NULL);
- g_list_free (uris);
-
- return res;
-}
-
-static gboolean
-g_desktop_app_info_supports_uris (GAppInfo *appinfo)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
-
- return
- (strstr (info->exec, "%u") != NULL) ||
- (strstr (info->exec, "%U") != NULL);
-}
-
-static gboolean
-prepend_terminal_to_vector (int *argc,
- char ***argv)
-{
-#ifndef G_OS_WIN32
- char **real_argv;
- int real_argc;
- int i, j;
- char **term_argv = NULL;
- int term_argc = 0;
- char *check;
- char **the_argv;
-
- g_return_val_if_fail (argc != NULL, FALSE);
- g_return_val_if_fail (argv != NULL, FALSE);
-
- /* sanity */
- if(*argv == NULL)
- *argc = 0;
-
- the_argv = *argv;
-
- /* compute size if not given */
- if (*argc < 0)
- {
- for (i = 0; the_argv[i] != NULL; i++)
- ;
- *argc = i;
- }
-
- term_argc = 2;
- term_argv = g_new0 (char *, 3);
-
- check = g_find_program_in_path ("gnome-terminal");
- if (check != NULL)
- {
- term_argv[0] = check;
- /* Note that gnome-terminal takes -x and
- * as -e in gnome-terminal is broken we use that. */
- term_argv[1] = g_strdup ("-x");
- }
- else
- {
- if (check == NULL)
- check = g_find_program_in_path ("nxterm");
- if (check == NULL)
- check = g_find_program_in_path ("color-xterm");
- if (check == NULL)
- check = g_find_program_in_path ("rxvt");
- if (check == NULL)
- check = g_find_program_in_path ("xterm");
- if (check == NULL)
- check = g_find_program_in_path ("dtterm");
- if (check == NULL)
- {
- check = g_strdup ("xterm");
- g_warning ("couldn't find a terminal, falling back to xterm");
- }
- term_argv[0] = check;
- term_argv[1] = g_strdup ("-e");
- }
-
- real_argc = term_argc + *argc;
- real_argv = g_new (char *, real_argc + 1);
-
- for (i = 0; i < term_argc; i++)
- real_argv[i] = term_argv[i];
-
- for (j = 0; j < *argc; j++, i++)
- real_argv[i] = (char *)the_argv[j];
-
- real_argv[i] = NULL;
-
- g_free (*argv);
- *argv = real_argv;
- *argc = real_argc;
-
- /* we use g_free here as we sucked all the inner strings
- * out from it into real_argv */
- g_free (term_argv);
- return TRUE;
-#else
- return FALSE;
-#endif /* G_OS_WIN32 */
-}
-
-
-static gboolean
-g_desktop_app_info_launch_uris (GAppInfo *appinfo,
- GList *uris,
- char **envp,
- GError **error)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
- char **argv;
- int argc;
-
- g_return_val_if_fail (appinfo != NULL, FALSE);
- g_return_val_if_fail (uris != NULL, FALSE);
-
- while (uris != NULL)
- {
- if (!expand_application_parameters (info, &uris,
- &argc, &argv, error))
- return FALSE;
-
- if (info->terminal)
- {
- if (!prepend_terminal_to_vector (&argc, &argv))
- {
- g_strfreev (argv);
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Unable to find terminal required for application"));
- return FALSE;
- }
- }
-
- if (!g_spawn_async (info->path, /* working directory */
- argv,
- envp,
- G_SPAWN_SEARCH_PATH /* flags */,
- NULL /* child_setup */,
- NULL /* data */,
- NULL /* child_pid */,
- error))
- {
- g_strfreev (argv);
- return FALSE;
- }
-
- g_strfreev (argv);
- }
-
- return TRUE;
-}
-
-static gboolean
-g_desktop_app_info_should_show (GAppInfo *appinfo,
- const char *desktop_env)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
- gboolean found;
- int i;
-
- if (info->nodisplay)
- return FALSE;
-
- if (info->only_show_in)
- {
- if (desktop_env == NULL)
- return FALSE;
-
- found = FALSE;
- for (i = 0; info->only_show_in[i] != NULL; i++)
- {
- if (strcmp (info->only_show_in[i], desktop_env) == 0)
- {
- found = TRUE;
- break;
- }
- }
- if (!found)
- return FALSE;
- }
-
- if (info->not_show_in && desktop_env)
- {
- for (i = 0; info->not_show_in[i] != NULL; i++)
- {
- if (strcmp (info->not_show_in[i], desktop_env) == 0)
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-ensure_dir (const char *path)
-{
- char **split_path;
- char *so_far;
- int i;
-
- if (g_file_test (path, G_FILE_TEST_IS_DIR))
- return TRUE;
-
- split_path = g_strsplit (path, G_DIR_SEPARATOR_S, 0);
-
- so_far = g_strdup ("/");
- for (i = 0; split_path[i] != NULL; i++)
- {
- char *to_check;
-
- to_check = g_build_filename (so_far, split_path[i], NULL);
- g_free (so_far);
-
- if (!g_file_test (to_check, G_FILE_TEST_IS_DIR))
- {
- if (mkdir (to_check, S_IRWXU) != 0)
- {
- g_free (to_check);
- g_strfreev (split_path);
- return FALSE;
- }
-
- }
-
- so_far = to_check;
- }
- g_free (so_far);
- g_strfreev (split_path);
-
- return TRUE;
-}
-
-static gboolean
-g_desktop_app_info_set_as_default_for_type (GAppInfo *appinfo,
- const char *content_type,
- GError **error)
-{
- GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
- char *dirname, *filename;
- GKeyFile *key_file;
- gboolean load_succeeded, res;;
- char **old_list;
- char **list;
- gsize length, data_size;
- char *data;
- int i, j;
-
- dirname = g_build_filename (g_get_user_data_dir (), "applications", NULL);
-
- if (!ensure_dir (dirname))
- {
- /* TODO: Should ensure dirname is UTF8 in error message */
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Can't create user applications dir (%s)"), dirname);
- g_free (dirname);
- return FALSE;
- }
-
- filename = g_build_filename (dirname, "defaults.list", NULL);
- g_free (dirname);
-
- key_file = g_key_file_new ();
- load_succeeded = g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, NULL);
- if (!load_succeeded || !g_key_file_has_group (key_file, "Default Applications"))
- {
- g_key_file_free (key_file);
- key_file = g_key_file_new ();
- }
-
- old_list = g_key_file_get_string_list (key_file, "Default Applications",
- content_type, &length, NULL);
-
- list = g_new (char *, 1 + length + 1);
-
- i = 0;
- list[i++] = g_strdup (info->desktop_id);
- if (old_list)
- {
- for (j = 0; old_list[j] != NULL; j++)
- {
- if (strcmp (old_list[j], info->desktop_id) != 0)
- list[i++] = g_strdup (old_list[j]);
- }
- }
- list[i] = NULL;
-
- g_strfreev (old_list);
-
- g_key_file_set_string_list (key_file,
- "Default Applications",
- content_type,
- (const char * const *)list, i);
-
- g_strfreev (list);
-
- data = g_key_file_to_data (key_file, &data_size, error);
- g_key_file_free (key_file);
- if (data == NULL)
- {
- g_free (filename);
- return FALSE;
- }
-
- res = g_file_set_contents (filename, data, data_size, error);
-
- mime_info_cache_reload (NULL);
-
- g_free (filename);
- g_free (data);
-
- return res;
-}
-
-static void
-update_program_done (GPid pid,
- gint status,
- gpointer data)
-{
- /* Did the application exit correctly */
- if (WIFEXITED (status) &&
- WEXITSTATUS (status) == 0)
- {
- /* Here we could clean out any caches in use */
- }
-}
-
-static void
-run_update_command (char *command,
- char *subdir)
-{
- char *argv[3] = {
- NULL,
- NULL
- };
- GPid pid = 0;
- GError *error = NULL;
-
- argv[0] = command;
- argv[1] = g_build_filename (g_get_user_data_dir (), subdir, NULL);
-
- if (g_spawn_async ("/", argv,
- NULL, /* envp */
- G_SPAWN_SEARCH_PATH |
- G_SPAWN_STDOUT_TO_DEV_NULL |
- G_SPAWN_STDERR_TO_DEV_NULL |
- G_SPAWN_DO_NOT_REAP_CHILD,
- NULL, NULL, /* No setup function */
- &pid,
- NULL))
- g_child_watch_add (pid, update_program_done, NULL);
- else
- {
- /* If we get an error at this point, it's quite likely the user doesn't
- * have an installed copy of either 'update-mime-database' or
- * 'update-desktop-database'. I don't think we want to popup an error
- * dialog at this point, so we just do a g_warning to give the user a
- * chance of debugging it.
- */
- g_warning ("%s", error->message);
- }
-
- g_free (argv[1]);
-}
-
-
-GAppInfo *
-g_app_info_create_from_commandline (const char *commandline,
- const char *application_name,
- GError **error)
-{
- GKeyFile *key_file;
- char *dirname;
- char **split;
- char *basename, *exec, *filename, *comment;
- char *data, *desktop_id;
- gsize data_size;
- int fd;
- GDesktopAppInfo *info;
- gboolean res;
-
- dirname = g_build_filename (g_get_user_data_dir (), "applications", NULL);
-
- if (!ensure_dir (dirname))
- {
- /* TODO: Should ensure dirname is UTF8 in error message */
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Can't create user applications dir (%s)"), dirname);
- g_free (dirname);
- return NULL;
- }
-
- key_file = g_key_file_new ();
-
- g_key_file_set_string (key_file, "Desktop Entry",
- "Encoding", "UTF-8");
- g_key_file_set_string (key_file, "Desktop Entry",
- "Version", "1.0");
- g_key_file_set_string (key_file, "Desktop Entry",
- "Type", "Application");
-
- exec = g_strconcat (commandline, " %f", NULL);
- g_key_file_set_string (key_file, "Desktop Entry",
- "Exec", exec);
- g_free (exec);
-
- split = g_strsplit (commandline, " ", 2);
- basename = g_path_get_basename (split[0]);
- g_strfreev (split);
- g_key_file_set_string (key_file, "Desktop Entry",
- "Name", application_name?application_name:basename);
-
- comment = g_strdup_printf (_("Custom definition for %s"), basename);
- g_key_file_set_string (key_file, "Desktop Entry",
- "Comment", comment);
- g_free (comment);
-
- g_key_file_set_string (key_file, "Desktop Entry",
- "NoDisplay", "true");
-
- data = g_key_file_to_data (key_file, &data_size, error);
- g_key_file_free (key_file);
- if (data == NULL)
- {
- g_free (dirname);
- g_free (basename);
- return NULL;
- }
-
-
- desktop_id = g_strdup_printf ("userapp-%s-XXXXXX.desktop", basename);
- g_free (basename);
- filename = g_build_filename (dirname, desktop_id, NULL);
- g_free (desktop_id);
- g_free (dirname);
-
- fd = g_mkstemp (filename);
- if (fd == -1)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Can't create user desktop file"));
- g_free (filename);
- g_free (data);
- return NULL;
- }
-
- desktop_id = g_path_get_basename (filename);
-
- close (fd);
-
- res = g_file_set_contents (filename, data, data_size, error);
- if (!res)
- {
- g_free (desktop_id);
- g_free (filename);
- return NULL;
- }
-
- run_update_command ("update-desktop-database", "applications");
-
- info = g_desktop_app_info_new_from_filename (filename, NULL);
- g_free (filename);
- if (info == NULL)
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Can't load just created desktop file"));
- else
- info->desktop_id = g_strdup (desktop_id);
-
- g_free (desktop_id);
-
- return G_APP_INFO (info);
-}
-
-
-static void
-g_desktop_app_info_iface_init (GAppInfoIface *iface)
-{
- iface->dup = g_desktop_app_info_dup;
- iface->equal = g_desktop_app_info_equal;
- iface->get_name = g_desktop_app_info_get_name;
- iface->get_description = g_desktop_app_info_get_description;
- iface->get_icon = g_desktop_app_info_get_icon;
- iface->launch = g_desktop_app_info_launch;
- iface->supports_uris = g_desktop_app_info_supports_uris;
- iface->launch_uris = g_desktop_app_info_launch_uris;
- iface->should_show = g_desktop_app_info_should_show;
- iface->set_as_default_for_type = g_desktop_app_info_set_as_default_for_type;
-}
-
-static gboolean
-app_info_in_list (GAppInfo *info, GList *l)
-{
- while (l != NULL)
- {
- if (g_app_info_equal (info, l->data))
- return TRUE;
- l = l->next;
- }
- return FALSE;
-}
-
-GList *
-g_get_all_app_info_for_type (const char *content_type)
-{
- GList *desktop_entries, *l;
- GList *infos;
- GAppInfo *info;
-
- desktop_entries = get_all_desktop_entries_for_mime_type (content_type);
-
- infos = NULL;
- for (l = desktop_entries; l != NULL; l = l->next)
- {
- char *desktop_entry = l->data;
-
- info = g_desktop_app_info_new (desktop_entry);
- if (info)
- {
- if (app_info_in_list (info, infos))
- g_object_unref (info);
- else
- infos = g_list_prepend (infos, info);
- }
- g_free (desktop_entry);
- }
-
- g_list_free (desktop_entries);
-
- return g_list_reverse (infos);
-}
-
-GAppInfo *
-g_get_default_app_info_for_type (const char *content_type)
-{
- GList *desktop_entries, *l;
- GAppInfo *info;
-
- desktop_entries = get_all_desktop_entries_for_mime_type (content_type);
-
- info = NULL;
- for (l = desktop_entries; l != NULL; l = l->next)
- {
- char *desktop_entry = l->data;
-
- info = g_desktop_app_info_new (desktop_entry);
- if (info)
- break;
- }
-
- g_list_foreach (desktop_entries, (GFunc)g_free, NULL);
- g_list_free (desktop_entries);
-
- return info;
-}
-
-static void
-get_apps_from_dir (GHashTable *apps, const char *dirname, const char *prefix)
-{
- GDir *dir;
- const char *basename;
- char *filename, *subprefix, *desktop_id;
- gboolean hidden;
- GDesktopAppInfo *appinfo;
-
- dir = g_dir_open (dirname, 0, NULL);
- if (dir)
- {
- while ((basename = g_dir_read_name (dir)) != NULL)
- {
- filename = g_build_filename (dirname, basename, NULL);
- if (g_str_has_suffix (basename, ".desktop"))
- {
- desktop_id = g_strconcat (prefix, basename, NULL);
-
- /* Use _extended so we catch NULLs too (hidden) */
- if (!g_hash_table_lookup_extended (apps, desktop_id, NULL, NULL))
- {
- appinfo = g_desktop_app_info_new_from_filename (filename, &hidden);
-
- /* Don't return apps that don't take arguments */
- if (appinfo &&
- strstr (appinfo->exec,"%U") == NULL &&
- strstr (appinfo->exec,"%u") == NULL &&
- strstr (appinfo->exec,"%f") == NULL &&
- strstr (appinfo->exec,"%F") == NULL)
- {
- g_object_unref (appinfo);
- appinfo = NULL;
- hidden = TRUE;
- }
-
- if (appinfo != NULL || hidden)
- {
- g_hash_table_insert (apps, g_strdup (desktop_id), appinfo);
-
- if (appinfo)
- {
- /* Reuse instead of strdup here */
- appinfo->desktop_id = desktop_id;
- desktop_id = NULL;
- }
- }
- }
- g_free (desktop_id);
- }
- else
- {
- if (g_file_test (filename, G_FILE_TEST_IS_DIR))
- {
- subprefix = g_strconcat (prefix, basename, "-", NULL);
- get_apps_from_dir (apps, filename, subprefix);
- g_free (subprefix);
- }
- }
- g_free (filename);
- }
- g_dir_close (dir);
- }
-}
-
-static void
-collect_apps (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- GList **infos = user_data;
-
- if (value)
- *infos = g_list_prepend (*infos, value);
-}
-
-
-GList *
-g_get_all_app_info (void)
-{
- const char * const *dirs;
- GHashTable *apps;
- int i;
- GList *infos;
-
- dirs = get_applications_search_path ();
-
- apps = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
-
-
- for (i = 0; dirs[i] != NULL; i++)
- get_apps_from_dir (apps, dirs[i], "");
-
-
- infos = NULL;
- g_hash_table_foreach (apps,
- collect_apps,
- &infos);
-
- g_hash_table_destroy (apps);
-
- return g_list_reverse (infos);
-}
-
-/* Cacheing of mimeinfo.cache and defaults.list files */
-
-typedef struct {
- char *path;
- GHashTable *mime_info_cache_map;
- GHashTable *defaults_list_map;
- time_t mime_info_cache_timestamp;
- time_t defaults_list_timestamp;
-} MimeInfoCacheDir;
-
-typedef struct {
- GList *dirs; /* mimeinfo.cache and defaults.list */
- GHashTable *global_defaults_cache; /* global results of defaults.list lookup and validation */
- time_t last_stat_time;
- guint should_ping_mime_monitor : 1;
-} MimeInfoCache;
-
-static MimeInfoCache *mime_info_cache = NULL;
-G_LOCK_DEFINE_STATIC (mime_info_cache);
-
-static void mime_info_cache_dir_add_desktop_entries (MimeInfoCacheDir *dir,
- const char *mime_type,
- char **new_desktop_file_ids);
-
-static MimeInfoCache * mime_info_cache_new (void);
-
-static void
-destroy_info_cache_value (gpointer key, GList *value, gpointer data)
-{
- g_list_foreach (value, (GFunc)g_free, NULL);
- g_list_free (value);
-}
-
-static void
-destroy_info_cache_map (GHashTable *info_cache_map)
-{
- g_hash_table_foreach (info_cache_map, (GHFunc)destroy_info_cache_value, NULL);
- g_hash_table_destroy (info_cache_map);
-}
-
-static gboolean
-mime_info_cache_dir_out_of_date (MimeInfoCacheDir *dir,
- const char *cache_file,
- time_t *timestamp)
-{
- struct stat buf;
- char *filename;
-
- filename = g_build_filename (dir->path, cache_file, NULL);
-
- if (g_stat (filename, &buf) < 0)
- {
- g_free (filename);
- return TRUE;
- }
- g_free (filename);
-
- if (buf.st_mtime != *timestamp)
- return TRUE;
-
- return FALSE;
-}
-
-/* Call with lock held */
-static gboolean
-remove_all (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- return TRUE;
-}
-
-
-static void
-mime_info_cache_blow_global_cache (void)
-{
- g_hash_table_foreach_remove (mime_info_cache->global_defaults_cache,
- remove_all, NULL);
-}
-
-static void
-mime_info_cache_dir_init (MimeInfoCacheDir *dir)
-{
- GError *load_error;
- GKeyFile *key_file;
- gchar *filename, **mime_types;
- int i;
- struct stat buf;
-
- load_error = NULL;
- mime_types = NULL;
-
- if (dir->mime_info_cache_map != NULL &&
- !mime_info_cache_dir_out_of_date (dir, "mimeinfo.cache",
- &dir->mime_info_cache_timestamp))
- return;
-
- if (dir->mime_info_cache_map != NULL)
- destroy_info_cache_map (dir->mime_info_cache_map);
-
- dir->mime_info_cache_map = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- NULL);
-
- key_file = g_key_file_new ();
-
- filename = g_build_filename (dir->path, "mimeinfo.cache", NULL);
-
- if (g_stat (filename, &buf) < 0)
- goto error;
-
- if (dir->mime_info_cache_timestamp > 0)
- mime_info_cache->should_ping_mime_monitor = TRUE;
-
- dir->mime_info_cache_timestamp = buf.st_mtime;
-
- g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &load_error);
-
- g_free (filename);
- filename = NULL;
-
- if (load_error != NULL)
- goto error;
-
- mime_types = g_key_file_get_keys (key_file, "MIME Cache",
- NULL, &load_error);
-
- if (load_error != NULL)
- goto error;
-
- for (i = 0; mime_types[i] != NULL; i++)
- {
- gchar **desktop_file_ids;
- char *unaliased_type;
- desktop_file_ids = g_key_file_get_string_list (key_file,
- "MIME Cache",
- mime_types[i],
- NULL,
- NULL);
-
- if (desktop_file_ids == NULL)
- continue;
-
- unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
- mime_info_cache_dir_add_desktop_entries (dir,
- unaliased_type,
- desktop_file_ids);
- g_free (unaliased_type);
-
- g_strfreev (desktop_file_ids);
- }
-
- g_strfreev (mime_types);
- g_key_file_free (key_file);
-
- return;
- error:
- if (filename)
- g_free (filename);
-
- g_key_file_free (key_file);
-
- if (mime_types != NULL)
- g_strfreev (mime_types);
-
- if (load_error)
- g_error_free (load_error);
-}
-
-static void
-mime_info_cache_dir_init_defaults_list (MimeInfoCacheDir *dir)
-{
- GKeyFile *key_file;
- GError *load_error;
- gchar *filename, **mime_types;
- char *unaliased_type;
- char **desktop_file_ids;
- int i;
- struct stat buf;
-
- load_error = NULL;
- mime_types = NULL;
-
- if (dir->defaults_list_map != NULL &&
- !mime_info_cache_dir_out_of_date (dir, "defaults.list",
- &dir->defaults_list_timestamp))
- return;
-
- if (dir->defaults_list_map != NULL)
- g_hash_table_destroy (dir->defaults_list_map);
-
- dir->defaults_list_map = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify)g_strfreev);
-
- key_file = g_key_file_new ();
-
- filename = g_build_filename (dir->path, "defaults.list", NULL);
- if (g_stat (filename, &buf) < 0)
- goto error;
-
- if (dir->defaults_list_timestamp > 0)
- mime_info_cache->should_ping_mime_monitor = TRUE;
-
- dir->defaults_list_timestamp = buf.st_mtime;
-
- g_key_file_load_from_file (key_file, filename, G_KEY_FILE_NONE, &load_error);
- g_free (filename);
- filename = NULL;
-
- if (load_error != NULL)
- goto error;
-
- mime_types = g_key_file_get_keys (key_file, "Default Applications",
- NULL, &load_error);
-
- if (load_error != NULL)
- goto error;
-
- for (i = 0; mime_types[i] != NULL; i++)
- {
- desktop_file_ids = g_key_file_get_string_list (key_file,
- "Default Applications",
- mime_types[i],
- NULL,
- NULL);
- if (desktop_file_ids == NULL)
- continue;
-
- unaliased_type = _g_unix_content_type_unalias (mime_types[i]);
- g_hash_table_replace (dir->defaults_list_map,
- unaliased_type,
- desktop_file_ids);
- }
-
- g_strfreev (mime_types);
- g_key_file_free (key_file);
-
- return;
- error:
- if (filename)
- g_free (filename);
-
- g_key_file_free (key_file);
-
- if (mime_types != NULL)
- g_strfreev (mime_types);
-
- if (load_error)
- g_error_free (load_error);
-}
-
-static MimeInfoCacheDir *
-mime_info_cache_dir_new (const char *path)
-{
- MimeInfoCacheDir *dir;
-
- dir = g_new0 (MimeInfoCacheDir, 1);
- dir->path = g_strdup (path);
-
- return dir;
-}
-
-static void
-mime_info_cache_dir_free (MimeInfoCacheDir *dir)
-{
- if (dir == NULL)
- return;
-
- if (dir->mime_info_cache_map != NULL)
- {
- destroy_info_cache_map (dir->mime_info_cache_map);
- dir->mime_info_cache_map = NULL;
-
- }
-
- if (dir->defaults_list_map != NULL)
- {
- g_hash_table_destroy (dir->defaults_list_map);
- dir->defaults_list_map = NULL;
- }
-
- g_free (dir);
-}
-
-static void
-mime_info_cache_dir_add_desktop_entries (MimeInfoCacheDir *dir,
- const char *mime_type,
- char **new_desktop_file_ids)
-{
- GList *desktop_file_ids;
- int i;
-
- desktop_file_ids = g_hash_table_lookup (dir->mime_info_cache_map,
- mime_type);
-
- for (i = 0; new_desktop_file_ids[i] != NULL; i++)
- {
- if (!g_list_find (desktop_file_ids, new_desktop_file_ids[i]))
- desktop_file_ids = g_list_append (desktop_file_ids,
- g_strdup (new_desktop_file_ids[i]));
- }
-
- g_hash_table_insert (dir->mime_info_cache_map, g_strdup (mime_type), desktop_file_ids);
-}
-
-static void
-mime_info_cache_init_dir_lists (void)
-{
- const char * const *dirs;
- int i;
-
- mime_info_cache = mime_info_cache_new ();
-
- dirs = get_applications_search_path ();
-
- for (i = 0; dirs[i] != NULL; i++)
- {
- MimeInfoCacheDir *dir;
-
- dir = mime_info_cache_dir_new (dirs[i]);
-
- if (dir != NULL)
- {
- mime_info_cache_dir_init (dir);
- mime_info_cache_dir_init_defaults_list (dir);
-
- mime_info_cache->dirs = g_list_append (mime_info_cache->dirs, dir);
- }
- }
-}
-
-static void
-mime_info_cache_update_dir_lists (void)
-{
- GList *tmp;
-
- tmp = mime_info_cache->dirs;
-
- while (tmp != NULL)
- {
- MimeInfoCacheDir *dir = (MimeInfoCacheDir *) tmp->data;
-
- /* No need to do this if we had file monitors... */
- mime_info_cache_blow_global_cache ();
- mime_info_cache_dir_init (dir);
- mime_info_cache_dir_init_defaults_list (dir);
-
- tmp = tmp->next;
- }
-}
-
-static void
-mime_info_cache_init (void)
-{
- G_LOCK (mime_info_cache);
- if (mime_info_cache == NULL)
- mime_info_cache_init_dir_lists ();
- else
- {
- time_t now;
-
- time (&now);
- if (now >= mime_info_cache->last_stat_time + 10)
- {
- mime_info_cache_update_dir_lists ();
- mime_info_cache->last_stat_time = now;
- }
- }
-
- if (mime_info_cache->should_ping_mime_monitor)
- {
- /* g_idle_add (emit_mime_changed, NULL); */
- mime_info_cache->should_ping_mime_monitor = FALSE;
- }
-
- G_UNLOCK (mime_info_cache);
-}
-
-static MimeInfoCache *
-mime_info_cache_new (void)
-{
- MimeInfoCache *cache;
-
- cache = g_new0 (MimeInfoCache, 1);
-
- cache->global_defaults_cache = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
- return cache;
-}
-
-static void
-mime_info_cache_free (MimeInfoCache *cache)
-{
- if (cache == NULL)
- return;
-
- g_list_foreach (cache->dirs,
- (GFunc) mime_info_cache_dir_free,
- NULL);
- g_list_free (cache->dirs);
- g_hash_table_destroy (cache->global_defaults_cache);
- g_free (cache);
-}
-
-/**
- * mime_info_cache_reload:
- * @dir: directory path which needs reloading.
- *
- * Reload the mime information for the @dir.
- */
-static void
-mime_info_cache_reload (const char *dir)
-{
- /* FIXME: just reload the dir that needs reloading,
- * don't blow the whole cache
- */
- if (mime_info_cache != NULL)
- {
- G_LOCK (mime_info_cache);
- mime_info_cache_free (mime_info_cache);
- mime_info_cache = NULL;
- G_UNLOCK (mime_info_cache);
- }
-}
-
-static GList *
-append_desktop_entry (GList *list, const char *desktop_entry)
-{
- /* Add if not already in list, and valid */
- if (!g_list_find_custom (list, desktop_entry, (GCompareFunc) strcmp))
- list = g_list_prepend (list, g_strdup (desktop_entry));
-
- return list;
-}
-
-/**
- * get_all_desktop_entries_for_mime_type:
- * @mime_type: a mime type.
- *
- * Returns all the desktop filenames for @mime_type. The desktop files
- * are listed in an order so that default applications are listed before
- * non-default ones, and handlers for inherited mimetypes are listed
- * after the base ones.
- *
- * Return value: a #GList containing the desktop filenames containing the
- * @mime_type.
- */
-static GList *
-get_all_desktop_entries_for_mime_type (const char *base_mime_type)
-{
- GList *desktop_entries, *list, *dir_list, *tmp;
- MimeInfoCacheDir *dir;
- char *mime_type;
- char **mime_types;
- char **default_entries;
- int i,j;
-
- mime_info_cache_init ();
-
- mime_types = _g_unix_content_type_get_parents (base_mime_type);
- G_LOCK (mime_info_cache);
-
- desktop_entries = NULL;
- for (i = 0; mime_types[i] != NULL; i++)
- {
- mime_type = mime_types[i];
-
- /* Go through all apps listed as defaults */
- for (dir_list = mime_info_cache->dirs;
- dir_list != NULL;
- dir_list = dir_list->next)
- {
- dir = dir_list->data;
- default_entries = g_hash_table_lookup (dir->defaults_list_map, mime_type);
- for (j = 0; default_entries != NULL && default_entries[j] != NULL; j++)
- desktop_entries = append_desktop_entry (desktop_entries, default_entries[j]);
- }
-
- /* Go through all entries that support the mimetype */
- for (dir_list = mime_info_cache->dirs;
- dir_list != NULL;
- dir_list = dir_list->next) {
- dir = dir_list->data;
-
- list = g_hash_table_lookup (dir->mime_info_cache_map, mime_type);
- for (tmp = list; tmp != NULL; tmp = tmp->next) {
- desktop_entries = append_desktop_entry (desktop_entries, tmp->data);
- }
- }
- }
-
- G_UNLOCK (mime_info_cache);
-
- g_strfreev (mime_types);
-
- desktop_entries = g_list_reverse (desktop_entries);
-
- return desktop_entries;
-}
diff --git a/gio/gdesktopappinfo.h b/gio/gdesktopappinfo.h
deleted file mode 100644
index 19c17587..00000000
--- a/gio/gdesktopappinfo.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __G_DESKTOP_APP_INFO_H__
-#define __G_DESKTOP_APP_INFO_H__
-
-#include <gio/gappinfo.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_DESKTOP_APP_INFO (g_desktop_app_info_get_type ())
-#define G_DESKTOP_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DESKTOP_APP_INFO, GDesktopAppInfo))
-#define G_DESKTOP_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DESKTOP_APP_INFO, GDesktopAppInfoClass))
-#define G_IS_DESKTOP_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DESKTOP_APP_INFO))
-#define G_IS_DESKTOP_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DESKTOP_APP_INFO))
-#define G_DESKTOP_APP_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DESKTOP_APP_INFO, GDesktopAppInfoClass))
-
-typedef struct _GDesktopAppInfo GDesktopAppInfo;
-typedef struct _GDesktopAppInfoClass GDesktopAppInfoClass;
-
-struct _GDesktopAppInfoClass
-{
- GObjectClass parent_class;
-};
-
-GType g_desktop_app_info_get_type (void) G_GNUC_CONST;
-
-GAppInfo *g_desktop_app_info_new (const char *desktop_id);
-
-G_END_DECLS
-
-
-#endif /* __G_DESKTOP_APP_INFO_H__ */
diff --git a/gio/gdirectorymonitor.c b/gio/gdirectorymonitor.c
deleted file mode 100644
index 7960cca6..00000000
--- a/gio/gdirectorymonitor.c
+++ /dev/null
@@ -1,403 +0,0 @@
-#include <config.h>
-#include <string.h>
-
-#include "gdirectorymonitorpriv.h"
-#include "gvfs-marshal.h"
-#include "gfile.h"
-#include "gvfs.h"
-
-enum {
- CHANGED,
- LAST_SIGNAL
-};
-
-G_DEFINE_TYPE (GDirectoryMonitor, g_directory_monitor, G_TYPE_OBJECT);
-
-typedef struct {
- GFile *file;
- guint32 last_sent_change_time; /* 0 == not sent */
- guint32 send_delayed_change_at; /* 0 == never */
- guint32 send_virtual_changes_done_at; /* 0 == never */
-} RateLimiter;
-
-struct _GDirectoryMonitorPrivate {
- gboolean cancelled;
- int rate_limit_msec;
-
- GHashTable *rate_limiter;
-
- GSource *timeout;
- guint32 timeout_fires_at;
-};
-
-#define DEFAULT_RATE_LIMIT_MSECS 800
-#define DEFAULT_VIRTUAL_CHANGES_DONE_DELAY_SECS 2
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void
-rate_limiter_free (RateLimiter *limiter)
-{
- g_object_unref (limiter->file);
- g_free (limiter);
-}
-
-static void
-g_directory_monitor_finalize (GObject *object)
-{
- GDirectoryMonitor *monitor;
-
- monitor = G_DIRECTORY_MONITOR (object);
-
- if (monitor->priv->timeout)
- {
- g_source_destroy (monitor->priv->timeout);
- g_source_unref (monitor->priv->timeout);
- }
-
- g_hash_table_destroy (monitor->priv->rate_limiter);
-
- if (G_OBJECT_CLASS (g_directory_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_directory_monitor_parent_class)->finalize) (object);
-}
-
-static void
-g_directory_monitor_dispose (GObject *object)
-{
- GDirectoryMonitor *monitor;
-
- monitor = G_DIRECTORY_MONITOR (object);
-
- /* Make sure we cancel on last unref */
- if (!monitor->priv->cancelled)
- g_directory_monitor_cancel (monitor);
-
- if (G_OBJECT_CLASS (g_directory_monitor_parent_class)->dispose)
- (*G_OBJECT_CLASS (g_directory_monitor_parent_class)->dispose) (object);
-}
-
-static void
-g_directory_monitor_class_init (GDirectoryMonitorClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GDirectoryMonitorPrivate));
-
- gobject_class->finalize = g_directory_monitor_finalize;
- gobject_class->dispose = g_directory_monitor_dispose;
-
- signals[CHANGED] =
- g_signal_new (I_("changed"),
- G_TYPE_DIRECTORY_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GDirectoryMonitorClass, changed),
- NULL, NULL,
- _gvfs_marshal_VOID__OBJECT_OBJECT_INT,
- G_TYPE_NONE,3,
- G_TYPE_FILE,
- G_TYPE_FILE,
- G_TYPE_INT);
-}
-
-static void
-g_directory_monitor_init (GDirectoryMonitor *monitor)
-{
- monitor->priv = G_TYPE_INSTANCE_GET_PRIVATE (monitor,
- G_TYPE_DIRECTORY_MONITOR,
- GDirectoryMonitorPrivate);
-
- monitor->priv->rate_limit_msec = DEFAULT_RATE_LIMIT_MSECS;
- monitor->priv->rate_limiter = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal,
- NULL, (GDestroyNotify) rate_limiter_free);
-}
-
-
-gboolean
-g_directory_monitor_cancel (GDirectoryMonitor* monitor)
-{
- GDirectoryMonitorClass *class;
-
- if (monitor->priv->cancelled)
- return TRUE;
-
- monitor->priv->cancelled = TRUE;
-
- class = G_DIRECTORY_MONITOR_GET_CLASS (monitor);
- return (* class->cancel) (monitor);
-}
-
-void
-g_directory_monitor_set_rate_limit (GDirectoryMonitor *monitor,
- int limit_msecs)
-{
- monitor->priv->rate_limit_msec = limit_msecs;
-}
-
-gboolean
-g_directory_monitor_is_cancelled (GDirectoryMonitor *monitor)
-{
- return monitor->priv->cancelled;
-}
-
-static guint32
-get_time_msecs (void)
-{
- return g_thread_gettime() / (1000 * 1000);
-}
-
-static guint32
-time_difference (guint32 from, guint32 to)
-{
- if (from > to)
- return 0;
- return to - from;
-}
-
-static RateLimiter *
-new_limiter (GDirectoryMonitor *monitor,
- GFile *file)
-{
- RateLimiter *limiter;
-
- limiter = g_new0 (RateLimiter, 1);
- limiter->file = g_object_ref (file);
- g_hash_table_insert (monitor->priv->rate_limiter, file, limiter);
-
- return limiter;
-}
-
-static void
-rate_limiter_send_virtual_changes_done_now (GDirectoryMonitor *monitor, RateLimiter *limiter)
-{
- if (limiter->send_virtual_changes_done_at != 0)
- {
- g_signal_emit (monitor, signals[CHANGED], 0, limiter->file, NULL, G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT);
- limiter->send_virtual_changes_done_at = 0;
- }
-}
-
-static void
-rate_limiter_send_delayed_change_now (GDirectoryMonitor *monitor, RateLimiter *limiter, guint32 time_now)
-{
- if (limiter->send_delayed_change_at != 0)
- {
- g_signal_emit (monitor, signals[CHANGED], 0, limiter->file, NULL, G_FILE_MONITOR_EVENT_CHANGED);
- limiter->send_delayed_change_at = 0;
- limiter->last_sent_change_time = time_now;
- }
-}
-
-typedef struct {
- guint32 min_time;
- guint32 time_now;
- GDirectoryMonitor *monitor;
-} ForEachData;
-
-static gboolean
-calc_min_time (GDirectoryMonitor *monitor, RateLimiter *limiter, guint32 time_now, guint32 *min_time)
-{
- gboolean delete_me;
- guint32 expire_at;
-
- delete_me = TRUE;
-
- if (limiter->last_sent_change_time != 0)
- {
- /* Set a timeout at 2*rate limit so that we can clear out the change from the hash eventualy */
- expire_at = limiter->last_sent_change_time + 2 * monitor->priv->rate_limit_msec;
-
- if (time_difference (time_now, expire_at) > 0)
- {
- delete_me = FALSE;
- *min_time = MIN (*min_time,
- time_difference (time_now, expire_at));
- }
- }
-
- if (limiter->send_delayed_change_at != 0)
- {
- delete_me = FALSE;
- *min_time = MIN (*min_time,
- time_difference (time_now, limiter->send_delayed_change_at));
- }
-
- if (limiter->send_virtual_changes_done_at != 0)
- {
- delete_me = FALSE;
- *min_time = MIN (*min_time,
- time_difference (time_now, limiter->send_virtual_changes_done_at));
- }
-
- return delete_me;
-}
-
-static gboolean
-foreach_rate_limiter_fire (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- RateLimiter *limiter = value;
- ForEachData *data = user_data;
-
- if (limiter->send_delayed_change_at != 0 &&
- time_difference (data->time_now, limiter->send_delayed_change_at) == 0)
- rate_limiter_send_delayed_change_now (data->monitor, limiter, data->time_now);
-
- if (limiter->send_virtual_changes_done_at != 0 &&
- time_difference (data->time_now, limiter->send_virtual_changes_done_at) == 0)
- rate_limiter_send_virtual_changes_done_now (data->monitor, limiter);
-
- return calc_min_time (data->monitor, limiter, data->time_now, &data->min_time);
-}
-
-static gboolean
-rate_limiter_timeout (gpointer timeout_data)
-{
- GDirectoryMonitor *monitor = timeout_data;
- ForEachData data;
- GSource *source;
-
- data.min_time = G_MAXUINT32;
- data.monitor = monitor;
- data.time_now = get_time_msecs ();
- g_hash_table_foreach_remove (monitor->priv->rate_limiter,
- foreach_rate_limiter_fire,
- &data);
-
- /* Remove old timeout */
- if (monitor->priv->timeout)
- {
- g_source_destroy (monitor->priv->timeout);
- g_source_unref (monitor->priv->timeout);
- monitor->priv->timeout_fires_at = 0;
- }
-
- /* Set up new timeout */
- if (data.min_time != G_MAXUINT32)
- {
- source = g_timeout_source_new (data.min_time + 1); /* + 1 to make sure we've really passed the time */
- g_source_set_callback (source, rate_limiter_timeout, monitor, NULL);
- g_source_attach (source, NULL);
-
- monitor->priv->timeout = source;
- monitor->priv->timeout_fires_at = data.time_now + data.min_time;
- }
-
- return FALSE;
-}
-
-static gboolean
-foreach_rate_limiter_update (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- RateLimiter *limiter = value;
- ForEachData *data = user_data;
-
- return calc_min_time (data->monitor, limiter, data->time_now, &data->min_time);
-}
-
-static void
-update_rate_limiter_timeout (GDirectoryMonitor *monitor, guint new_time)
-{
- ForEachData data;
- GSource *source;
-
- if (monitor->priv->timeout_fires_at != 0 && new_time != 0 &&
- time_difference (new_time, monitor->priv->timeout_fires_at) == 0)
- return; /* Nothing to do, we already fire earlier than that */
-
- data.min_time = G_MAXUINT32;
- data.monitor = monitor;
- data.time_now = get_time_msecs ();
- g_hash_table_foreach_remove (monitor->priv->rate_limiter,
- foreach_rate_limiter_update,
- &data);
-
- /* Remove old timeout */
- if (monitor->priv->timeout)
- {
- g_source_destroy (monitor->priv->timeout);
- g_source_unref (monitor->priv->timeout);
- monitor->priv->timeout_fires_at = 0;
- }
-
- /* Set up new timeout */
- if (data.min_time != G_MAXUINT32)
- {
- source = g_timeout_source_new (data.min_time + 1); /* + 1 to make sure we've really passed the time */
- g_source_set_callback (source, rate_limiter_timeout, monitor, NULL);
- g_source_attach (source, NULL);
-
- monitor->priv->timeout = source;
- monitor->priv->timeout_fires_at = data.time_now + data.min_time;
- }
-}
-
-void
-g_directory_monitor_emit_event (GDirectoryMonitor *monitor,
- GFile *child,
- GFile *other_file,
- GFileMonitorEvent event_type)
-{
- guint32 time_now, since_last;
- gboolean emit_now;
- RateLimiter *limiter;
-
- limiter = g_hash_table_lookup (monitor->priv->rate_limiter, child);
-
- if (event_type != G_FILE_MONITOR_EVENT_CHANGED)
- {
- if (limiter)
- {
- rate_limiter_send_delayed_change_now (monitor, limiter, get_time_msecs ());
- if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
- limiter->send_virtual_changes_done_at = 0;
- else
- rate_limiter_send_virtual_changes_done_now (monitor, limiter);
- update_rate_limiter_timeout (monitor, 0);
- }
- g_signal_emit (monitor, signals[CHANGED], 0, child, other_file, event_type);
- }
- else
- {
- /* Changed event, rate limit */
- time_now = get_time_msecs ();
- emit_now = TRUE;
-
- if (limiter)
- {
- since_last = time_difference (limiter->last_sent_change_time, time_now);
- if (since_last < monitor->priv->rate_limit_msec)
- {
- /* We ignore this change, but arm a timer so that we can fire it later if we
- don't get any other events (that kill this timeout) */
- emit_now = FALSE;
- if (limiter->send_delayed_change_at == 0)
- {
- limiter->send_delayed_change_at = time_now + monitor->priv->rate_limit_msec;
- update_rate_limiter_timeout (monitor, limiter->send_delayed_change_at);
- }
- }
- }
-
- if (limiter == NULL)
- limiter = new_limiter (monitor, child);
-
- if (emit_now)
- {
- g_signal_emit (monitor, signals[CHANGED], 0, child, other_file, event_type);
-
- limiter->last_sent_change_time = time_now;
- limiter->send_delayed_change_at = 0;
- /* Set a timeout of 2*rate limit so that we can clear out the change from the hash eventualy */
- update_rate_limiter_timeout (monitor, time_now + 2 * monitor->priv->rate_limit_msec);
- }
-
- /* Schedule a virtual change done. This is removed if we get a real one, and
- postponed if we get more change events. */
-
- limiter->send_virtual_changes_done_at = time_now + DEFAULT_VIRTUAL_CHANGES_DONE_DELAY_SECS * 1000;
- update_rate_limiter_timeout (monitor, limiter->send_virtual_changes_done_at);
- }
-}
diff --git a/gio/gdirectorymonitor.h b/gio/gdirectorymonitor.h
deleted file mode 100644
index 60202d83..00000000
--- a/gio/gdirectorymonitor.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __G_DIRECTORY_MONITOR_H__
-#define __G_DIRECTORY_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gfile.h>
-#include <gio/gfilemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_DIRECTORY_MONITOR (g_directory_monitor_get_type ())
-#define G_DIRECTORY_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DIRECTORY_MONITOR, GDirectoryMonitor))
-#define G_DIRECTORY_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DIRECTORY_MONITOR, GDirectoryMonitorClass))
-#define G_IS_DIRECTORY_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DIRECTORY_MONITOR))
-#define G_IS_DIRECTORY_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DIRECTORY_MONITOR))
-#define G_DIRECTORY_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DIRECTORY_MONITOR, GDirectoryMonitorClass))
-
-typedef struct _GDirectoryMonitorClass GDirectoryMonitorClass;
-typedef struct _GDirectoryMonitorPrivate GDirectoryMonitorPrivate;
-
-struct _GDirectoryMonitor
-{
- GObject parent;
-
- /*< private >*/
- GDirectoryMonitorPrivate *priv;
-};
-
-struct _GDirectoryMonitorClass
-{
- GObjectClass parent_class;
-
- /* Signals */
- void (* changed) (GDirectoryMonitor* monitor,
- GFile *child,
- GFile *other_file,
- GFileMonitorEvent event_type);
-
- /* Virtual Table */
- gboolean (*cancel)(GDirectoryMonitor* monitor);
-};
-
-GType g_directory_monitor_get_type (void) G_GNUC_CONST;
-
-gboolean g_directory_monitor_cancel (GDirectoryMonitor *monitor);
-gboolean g_directory_monitor_is_cancelled (GDirectoryMonitor *monitor);
-void g_directory_monitor_set_rate_limit (GDirectoryMonitor *monitor,
- int limit_msecs);
-
-G_END_DECLS
-
-#endif /* __G_DIRECTORY_MONITOR_H__ */
diff --git a/gio/gdirectorymonitorpriv.h b/gio/gdirectorymonitorpriv.h
deleted file mode 100644
index bb84a420..00000000
--- a/gio/gdirectorymonitorpriv.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __G_DIRECTORY_MONITOR_PRIV_H__
-#define __G_DIRECTORY_MONITOR_PRIV_H__
-
-#include <gio/gdirectorymonitor.h>
-
-G_BEGIN_DECLS
-
-void g_directory_monitor_emit_event (GDirectoryMonitor *monitor,
- GFile *child,
- GFile *other_file,
- GFileMonitorEvent event_type);
-
-G_END_DECLS
-
-#endif /* __G_DIRECTORY_MONITOR_PRIV_H__ */
diff --git a/gio/gdrive.c b/gio/gdrive.c
deleted file mode 100644
index 93e56818..00000000
--- a/gio/gdrive.c
+++ /dev/null
@@ -1,209 +0,0 @@
-#include <config.h>
-#include "gdrive.h"
-#include "gsimpleasyncresult.h"
-#include <glib/gi18n-lib.h>
-
-static void g_drive_base_init (gpointer g_class);
-static void g_drive_class_init (gpointer g_class,
- gpointer class_data);
-
-GType
-g_drive_get_type (void)
-{
- static GType drive_type = 0;
-
- if (! drive_type)
- {
- static const GTypeInfo drive_info =
- {
- sizeof (GDriveIface), /* class_size */
- g_drive_base_init, /* base_init */
- NULL, /* base_finalize */
- g_drive_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- drive_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GDrive"),
- &drive_info, 0);
-
- g_type_interface_add_prerequisite (drive_type, G_TYPE_OBJECT);
- }
-
- return drive_type;
-}
-
-static void
-g_drive_class_init (gpointer g_class,
- gpointer class_data)
-{
-}
-
-static void
-g_drive_base_init (gpointer g_class)
-{
- static gboolean initialized = FALSE;
-
- if (! initialized)
- {
- g_signal_new (I_("changed"),
- G_TYPE_DRIVE,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GDriveIface, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
- }
-}
-
-char *
-g_drive_get_name (GDrive *drive)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- return (* iface->get_name) (drive);
-}
-
-GIcon *
-g_drive_get_icon (GDrive *drive)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- return (* iface->get_icon) (drive);
-}
-
-GList *
-g_drive_get_volumes (GDrive *drive)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- return (* iface->get_volumes) (drive);
-}
-
-gboolean
-g_drive_is_automounted (GDrive *drive)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- return (* iface->is_automounted) (drive);
-}
-
-gboolean
-g_drive_can_mount (GDrive *drive)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- if (iface->can_mount == NULL)
- return FALSE;
-
- return (* iface->can_mount) (drive);
-}
-
-gboolean
-g_drive_can_eject (GDrive *drive)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- if (iface->can_eject == NULL)
- return FALSE;
-
- return (* iface->can_eject) (drive);
-}
-
-void
-g_drive_mount (GDrive *drive,
- GMountOperation *mount_operation,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- if (iface->mount == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (drive), callback, user_data,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("drive doesn't implement mount"));
-
- return;
- }
-
- return (* iface->mount) (drive, mount_operation, callback, user_data);
-}
-
-gboolean
-g_drive_mount_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error)
-{
- GDriveIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
- iface = G_DRIVE_GET_IFACE (drive);
- return (* iface->mount_finish) (drive, result, error);
-}
-
-void
-g_drive_eject (GDrive *drive,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GDriveIface *iface;
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- if (iface->eject == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (drive), callback, user_data,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("drive doesn't implement eject"));
-
- return;
- }
-
- return (* iface->eject) (drive, callback, user_data);
-}
-
-gboolean
-g_drive_eject_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error)
-{
- GDriveIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
- iface = G_DRIVE_GET_IFACE (drive);
-
- return (* iface->mount_finish) (drive, result, error);
-}
diff --git a/gio/gdrive.h b/gio/gdrive.h
deleted file mode 100644
index 49c91b70..00000000
--- a/gio/gdrive.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef __G_DRIVE_H__
-#define __G_DRIVE_H__
-
-#include <glib-object.h>
-#include <gio/gvolume.h>
-#include <gio/gmountoperation.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_DRIVE (g_drive_get_type ())
-#define G_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DRIVE, GDrive))
-#define G_IS_DRIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DRIVE))
-#define G_DRIVE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DRIVE, GDriveIface))
-
-typedef struct _GDriveIface GDriveIface;
-
-struct _GDriveIface
-{
- GTypeInterface g_iface;
-
- /* signals */
- void (*changed) (GVolume *volume);
-
- /* Virtual Table */
-
- char * (*get_name) (GDrive *drive);
- GIcon * (*get_icon) (GDrive *drive);
- GList * (*get_volumes) (GDrive *drive);
- gboolean (*is_automounted)(GDrive *drive);
- gboolean (*can_mount) (GDrive *drive);
- gboolean (*can_eject) (GDrive *drive);
- void (*mount) (GDrive *drive,
- GMountOperation *mount_operation,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*mount_finish)(GDrive *drive,
- GAsyncResult *result,
- GError **error);
- void (*eject) (GDrive *drive,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*eject_finish)(GDrive *drive,
- GAsyncResult *result,
- GError **error);
-};
-
-GType g_drive_get_type (void) G_GNUC_CONST;
-
-char * g_drive_get_name (GDrive *drive);
-GIcon * g_drive_get_icon (GDrive *drive);
-GList * g_drive_get_volumes (GDrive *drive);
-gboolean g_drive_is_automounted (GDrive *drive);
-gboolean g_drive_can_mount (GDrive *drive);
-gboolean g_drive_can_eject (GDrive *drive);
-void g_drive_mount (GDrive *drive,
- GMountOperation *mount_operation,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_drive_mount_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error);
-void g_drive_eject (GDrive *drive,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_drive_eject_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __G_DRIVE_H__ */
diff --git a/gio/gdrivepriv.h b/gio/gdrivepriv.h
deleted file mode 100644
index 9de3f410..00000000
--- a/gio/gdrivepriv.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __G_DRIVEPRIV_H__
-#define __G_DRIVEPRIV_H__
-
-#include <gio/gdrive.h>
-
-G_BEGIN_DECLS
-
-char *g_drive_get_platform_id (GDrive *drive);
-
-G_END_DECLS
-
-#endif /* __G_DRIVEPRIV_H__ */
diff --git a/gio/gdummyfile.c b/gio/gdummyfile.c
deleted file mode 100644
index 69f00007..00000000
--- a/gio/gdummyfile.c
+++ /dev/null
@@ -1,561 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "gdummyfile.h"
-
-static void g_dummy_file_file_iface_init (GFileIface *iface);
-
-typedef struct {
- char *scheme;
- char *userinfo;
- char *host;
- int port; /* -1 => not in uri */
- char *path;
- char *query;
- char *fragment;
-} GDecodedUri;
-
-struct _GDummyFile
-{
- GObject parent_instance;
-
- GDecodedUri *decoded_uri;
- char *text_uri;
-};
-
-G_DEFINE_TYPE_WITH_CODE (GDummyFile, g_dummy_file, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_FILE,
- g_dummy_file_file_iface_init))
-
-static char * _g_encode_uri (GDecodedUri *decoded);
-static void _g_decoded_uri_free (GDecodedUri *decoded);
-static GDecodedUri *_g_decode_uri (const char *uri);
-static GDecodedUri *_g_decoded_uri_new (void);
-
-
-static void
-g_dummy_file_finalize (GObject *object)
-{
- GDummyFile *dummy;
-
- dummy = G_DUMMY_FILE (object);
-
- if (dummy->decoded_uri)
- _g_decoded_uri_free (dummy->decoded_uri);
-
- g_free (dummy->text_uri);
-
- if (G_OBJECT_CLASS (g_dummy_file_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_dummy_file_parent_class)->finalize) (object);
-}
-
-static void
-g_dummy_file_class_init (GDummyFileClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_dummy_file_finalize;
-}
-
-static void
-g_dummy_file_init (GDummyFile *dummy)
-{
-}
-
-GFile *
-g_dummy_file_new (const char *uri)
-{
- GDummyFile *dummy;
-
- dummy = g_object_new (G_TYPE_DUMMY_FILE, NULL);
- dummy->text_uri = g_strdup (uri);
- dummy->decoded_uri = _g_decode_uri (uri);
-
- return G_FILE (dummy);
-}
-
-static gboolean
-g_dummy_file_is_native (GFile *file)
-{
- return FALSE;
-}
-
-static char *
-g_dummy_file_get_basename (GFile *file)
-{
- GDummyFile *dummy = G_DUMMY_FILE (file);
-
- if (dummy->decoded_uri)
- return g_path_get_basename (dummy->decoded_uri->path);
- return g_strdup (dummy->text_uri);
-}
-
-static char *
-g_dummy_file_get_path (GFile *file)
-{
- return NULL;
-}
-
-static char *
-g_dummy_file_get_uri (GFile *file)
-{
- return g_strdup (G_DUMMY_FILE (file)->text_uri);
-}
-
-static char *
-g_dummy_file_get_parse_name (GFile *file)
-{
- return g_strdup (G_DUMMY_FILE (file)->text_uri);
-}
-
-static GFile *
-g_dummy_file_get_parent (GFile *file)
-{
- GDummyFile *dummy = G_DUMMY_FILE (file);
- GFile *parent;
- char *dirname;
- char *uri;
- GDecodedUri new_decoded_uri;
-
- if (dummy->decoded_uri == NULL)
- return NULL;
-
- dirname = g_path_get_dirname (dummy->decoded_uri->path);
-
- if (strcmp (dirname, ".") == 0)
- {
- g_free (dirname);
- return NULL;
- }
-
- new_decoded_uri = *dummy->decoded_uri;
- new_decoded_uri.path = dirname;
- uri = _g_encode_uri (&new_decoded_uri);
- g_free (dirname);
-
- parent = g_dummy_file_new (uri);
- g_free (uri);
-
- return parent;
-}
-
-static GFile *
-g_dummy_file_dup (GFile *file)
-{
- GDummyFile *dummy = G_DUMMY_FILE (file);
-
- return g_dummy_file_new (dummy->text_uri);
-}
-
-static guint
-g_dummy_file_hash (GFile *file)
-{
- GDummyFile *dummy = G_DUMMY_FILE (file);
-
- return g_str_hash (dummy->text_uri);
-}
-
-static gboolean
-g_dummy_file_equal (GFile *file1,
- GFile *file2)
-{
- GDummyFile *dummy1 = G_DUMMY_FILE (file1);
- GDummyFile *dummy2 = G_DUMMY_FILE (file2);
-
- return g_str_equal (dummy1->text_uri, dummy2->text_uri);
-}
-
-static GFile *
-g_dummy_file_resolve_relative (GFile *file,
- const char *relative_path)
-{
- GDummyFile *dummy = G_DUMMY_FILE (file);
- GFile *child;
- char *uri;
- GDecodedUri new_decoded_uri;
-
- if (dummy->decoded_uri == NULL)
- {
- uri = g_strconcat (dummy->text_uri, "/", relative_path, NULL);
- child = g_dummy_file_new (uri);
- g_free (uri);
- }
- else
- {
- new_decoded_uri = *dummy->decoded_uri;
-
- if (g_path_is_absolute (relative_path))
- new_decoded_uri.path = g_strdup (relative_path);
- else
- new_decoded_uri.path = g_build_filename (new_decoded_uri.path, relative_path, NULL);
-
- uri = _g_encode_uri (&new_decoded_uri);
- g_free (new_decoded_uri.path);
-
- child = g_dummy_file_new (uri);
- g_free (uri);
- }
-
- return child;
-}
-
-static GFile *
-g_dummy_file_get_child_for_display_name (GFile *file,
- const char *display_name,
- GError **error)
-{
- return g_file_get_child (file, display_name);
-}
-
-static void
-g_dummy_file_file_iface_init (GFileIface *iface)
-{
- iface->dup = g_dummy_file_dup;
- iface->hash = g_dummy_file_hash;
- iface->equal = g_dummy_file_equal;
- iface->is_native = g_dummy_file_is_native;
- iface->get_basename = g_dummy_file_get_basename;
- iface->get_path = g_dummy_file_get_path;
- iface->get_uri = g_dummy_file_get_uri;
- iface->get_parse_name = g_dummy_file_get_parse_name;
- iface->get_parent = g_dummy_file_get_parent;
- iface->resolve_relative = g_dummy_file_resolve_relative;
- iface->get_child_for_display_name = g_dummy_file_get_child_for_display_name;
-}
-
-/* Uri handling helper functions: */
-
-static int
-unescape_character (const char *scanner)
-{
- int first_digit;
- int second_digit;
-
- first_digit = g_ascii_xdigit_value (*scanner++);
- if (first_digit < 0)
- return -1;
-
- second_digit = g_ascii_xdigit_value (*scanner++);
- if (second_digit < 0)
- return -1;
-
- return (first_digit << 4) | second_digit;
-}
-
-static char *
-unescape_string (const gchar *escaped_string,
- const gchar *escaped_string_end,
- const gchar *illegal_characters)
-{
- const gchar *in;
- gchar *out, *result;
- gint character;
-
- if (escaped_string == NULL)
- return NULL;
-
- result = g_malloc (escaped_string_end - escaped_string + 1);
-
- out = result;
- for (in = escaped_string; in < escaped_string_end; in++) {
- character = *in;
- if (*in == '%') {
- in++;
- if (escaped_string_end - in < 2)
- {
- g_free (result);
- return NULL;
- }
-
- character = unescape_character (in);
-
- /* Check for an illegal character. We consider '\0' illegal here. */
- if (character <= 0 ||
- (illegal_characters != NULL &&
- strchr (illegal_characters, (char)character) != NULL))
- {
- g_free (result);
- return NULL;
- }
- in++; /* The other char will be eaten in the loop header */
- }
- *out++ = (char)character;
- }
-
- *out = '\0';
- g_assert (out - result <= strlen (escaped_string));
- return result;
-}
-
-void
-_g_decoded_uri_free (GDecodedUri *decoded)
-{
- if (decoded == NULL)
- return;
-
- g_free (decoded->scheme);
- g_free (decoded->query);
- g_free (decoded->fragment);
- g_free (decoded->userinfo);
- g_free (decoded->host);
- g_free (decoded->path);
- g_free (decoded);
-}
-
-GDecodedUri *
-_g_decoded_uri_new (void)
-{
- GDecodedUri *uri;
-
- uri = g_new0 (GDecodedUri, 1);
- uri->port = -1;
-
- return uri;
-}
-
-GDecodedUri *
-_g_decode_uri (const char *uri)
-{
- GDecodedUri *decoded;
- const char *p, *in, *hier_part_start, *hier_part_end, *query_start, *fragment_start;
- char *out;
- char c;
-
- /* From RFC 3986 Decodes:
- * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
- */
-
- p = uri;
-
- /* Decode scheme:
- scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
- */
-
- if (!g_ascii_isalpha (*p))
- return NULL;
-
- while (1)
- {
- c = *p++;
-
- if (c == ':')
- break;
-
- if (!(g_ascii_isalnum(c) ||
- c == '+' ||
- c == '-' ||
- c == '.'))
- return NULL;
- }
-
- decoded = _g_decoded_uri_new ();
-
- decoded->scheme = g_malloc (p - uri);
- out = decoded->scheme;
- for (in = uri; in < p - 1; in++)
- *out++ = g_ascii_tolower (*in);
- *out = 0;
-
- hier_part_start = p;
-
- query_start = strchr (p, '?');
- if (query_start)
- {
- hier_part_end = query_start++;
- fragment_start = strchr (query_start, '#');
- if (fragment_start)
- {
- decoded->query = g_strndup (query_start, fragment_start - query_start);
- decoded->fragment = g_strdup (fragment_start+1);
- }
- else
- {
- decoded->query = g_strdup (query_start);
- decoded->fragment = NULL;
- }
- }
- else
- {
- /* No query */
- decoded->query = NULL;
- fragment_start = strchr (p, '#');
- if (fragment_start)
- {
- hier_part_end = fragment_start++;
- decoded->fragment = g_strdup (fragment_start);
- }
- else
- {
- hier_part_end = p + strlen (p);
- decoded->fragment = NULL;
- }
- }
-
- /* 3:
- hier-part = "//" authority path-abempty
- / path-absolute
- / path-rootless
- / path-empty
-
- */
-
- if (hier_part_start[0] == '/' &&
- hier_part_start[1] == '/')
- {
- const char *authority_start, *authority_end;
- const char *userinfo_start, *userinfo_end;
- const char *host_start, *host_end;
- const char *port_start;
-
- authority_start = hier_part_start + 2;
- /* authority is always followed by / or nothing */
- authority_end = memchr (authority_start, '/', hier_part_end - authority_start);
- if (authority_end == NULL)
- authority_end = hier_part_end;
-
- /* 3.2:
- authority = [ userinfo "@" ] host [ ":" port ]
- */
-
- userinfo_end = memchr (authority_start, '@', authority_end - authority_start);
- if (userinfo_end)
- {
- userinfo_start = authority_start;
- decoded->userinfo = unescape_string (userinfo_start, userinfo_end, NULL);
- if (decoded->userinfo == NULL)
- {
- _g_decoded_uri_free (decoded);
- return NULL;
- }
- host_start = userinfo_end + 1;
- }
- else
- host_start = authority_start;
-
- port_start = memchr (host_start, ':', authority_end - host_start);
- if (port_start)
- {
- host_end = port_start++;
-
- decoded->port = atoi(port_start);
- }
- else
- {
- host_end = authority_end;
- decoded->port = -1;
- }
-
- decoded->host = g_strndup (host_start, host_end - host_start);
-
- hier_part_start = authority_end;
- }
-
- decoded->path = unescape_string (hier_part_start, hier_part_end, "/");
-
- if (decoded->path == NULL)
- {
- _g_decoded_uri_free (decoded);
- return NULL;
- }
-
- return decoded;
-}
-
-#define SUB_DELIM_CHARS "!$&'()*+,;="
-
-static gboolean
-is_valid (char c, const char *reserved_chars_allowed)
-{
- if (g_ascii_isalnum (c) ||
- c == '-' ||
- c == '.' ||
- c == '_' ||
- c == '~')
- return TRUE;
-
- if (reserved_chars_allowed &&
- strchr (reserved_chars_allowed, c) != NULL)
- return TRUE;
-
- return FALSE;
-}
-
-static void
-g_string_append_encoded (GString *string, const char *encoded,
- const char *reserved_chars_allowed)
-{
- unsigned char c;
- const char *end;
- static const gchar hex[16] = "0123456789ABCDEF";
-
- end = encoded + strlen (encoded);
-
- while ((c = *encoded) != 0)
- {
- if (is_valid (c, reserved_chars_allowed))
- {
- g_string_append_c (string, c);
- encoded++;
- }
- else
- {
- g_string_append_c (string, '%');
- g_string_append_c (string, hex[((guchar)c) >> 4]);
- g_string_append_c (string, hex[((guchar)c) & 0xf]);
- encoded++;
- }
- }
-}
-
-char *
-_g_encode_uri (GDecodedUri *decoded)
-{
- GString *uri;
-
- uri = g_string_new (NULL);
-
- g_string_append (uri, decoded->scheme);
- g_string_append (uri, "://");
-
- if (decoded->host != NULL)
- {
- if (decoded->userinfo)
- {
- /* userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) */
- g_string_append_encoded (uri, decoded->userinfo, SUB_DELIM_CHARS ":");
- g_string_append_c (uri, '@');
- }
-
- g_string_append (uri, decoded->host);
-
- if (decoded->port != -1)
- {
- g_string_append_c (uri, ':');
- g_string_append_printf (uri, "%d", decoded->port);
- }
- }
-
- g_string_append_encoded (uri, decoded->path, SUB_DELIM_CHARS ":@/");
-
- if (decoded->query)
- {
- g_string_append_c (uri, '?');
- g_string_append (uri, decoded->query);
- }
-
- if (decoded->fragment)
- {
- g_string_append_c (uri, '#');
- g_string_append (uri, decoded->fragment);
- }
-
- return g_string_free (uri, FALSE);
-}
diff --git a/gio/gdummyfile.h b/gio/gdummyfile.h
deleted file mode 100644
index e044205f..00000000
--- a/gio/gdummyfile.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __G_DUMMY_FILE_H__
-#define __G_DUMMY_FILE_H__
-
-#include <gio/gfile.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_DUMMY_FILE (g_dummy_file_get_type ())
-#define G_DUMMY_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DUMMY_FILE, GDummyFile))
-#define G_DUMMY_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DUMMY_FILE, GDummyFileClass))
-#define G_IS_DUMMY_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DUMMY_FILE))
-#define G_IS_DUMMY_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DUMMY_FILE))
-#define G_DUMMY_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DUMMY_FILE, GDummyFileClass))
-
-typedef struct _GDummyFile GDummyFile;
-typedef struct _GDummyFileClass GDummyFileClass;
-
-struct _GDummyFileClass
-{
- GObjectClass parent_class;
-};
-
-GType g_dummy_file_get_type (void) G_GNUC_CONST;
-
-GFile * g_dummy_file_new (const char *uri);
-
-G_END_DECLS
-
-#endif /* __G_DUMMY_FILE_H__ */
diff --git a/gio/gfile.c b/gio/gfile.c
deleted file mode 100644
index 307000d1..00000000
--- a/gio/gfile.c
+++ /dev/null
@@ -1,2551 +0,0 @@
-#include <config.h>
-#include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-#include "gfile.h"
-#include "gvfs.h"
-#include "gioscheduler.h"
-#include <glib/gi18n-lib.h>
-#include <glocalfile.h>
-#include "gsimpleasyncresult.h"
-#include "gpollfilemonitor.h"
-
-static void g_file_base_init (gpointer g_class);
-static void g_file_class_init (gpointer g_class,
- gpointer class_data);
-
-static void g_file_real_get_info_async (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static GFileInfo * g_file_real_get_info_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-static void g_file_real_read_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static GFileInputStream * g_file_real_read_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-static void g_file_real_append_to_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static GFileOutputStream *g_file_real_append_to_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-static void g_file_real_create_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static GFileOutputStream *g_file_real_create_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-static void g_file_real_replace_async (GFile *file,
- const char *etag,
- gboolean make_backup,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static GFileOutputStream *g_file_real_replace_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-static gboolean g_file_real_set_attributes_from_info (GFile *file,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-static GFileMonitor* g_file_real_monitor_file (GFile *file,
- GFileMonitorFlags flags);
-
-GType
-g_file_get_type (void)
-{
- static GType file_type = 0;
-
- if (! file_type)
- {
- static const GTypeInfo file_info =
- {
- sizeof (GFileIface), /* class_size */
- g_file_base_init, /* base_init */
- NULL, /* base_finalize */
- g_file_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- file_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GFile"),
- &file_info, 0);
-
- g_type_interface_add_prerequisite (file_type, G_TYPE_OBJECT);
- }
-
- return file_type;
-}
-
-static void
-g_file_class_init (gpointer g_class,
- gpointer class_data)
-{
- GFileIface *iface = g_class;
-
- iface->monitor_file = g_file_real_monitor_file;
- iface->get_info_async = g_file_real_get_info_async;
- iface->get_info_finish = g_file_real_get_info_finish;
- iface->read_async = g_file_real_read_async;
- iface->read_finish = g_file_real_read_finish;
- iface->append_to_async = g_file_real_append_to_async;
- iface->append_to_finish = g_file_real_append_to_finish;
- iface->create_async = g_file_real_create_async;
- iface->create_finish = g_file_real_create_finish;
- iface->replace_async = g_file_real_replace_async;
- iface->replace_finish = g_file_real_replace_finish;
- iface->set_attributes_from_info = g_file_real_set_attributes_from_info;
-}
-
-static void
-g_file_base_init (gpointer g_class)
-{
-}
-
-gboolean
-g_file_is_native (GFile *file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->is_native) (file);
-}
-
-char *
-g_file_get_basename (GFile *file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->get_basename) (file);
-}
-
-char *
-g_file_get_path (GFile *file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->get_path) (file);
-}
-
-char *
-g_file_get_uri (GFile *file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->get_uri) (file);
-}
-
-
-char *
-g_file_get_parse_name (GFile *file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->get_parse_name) (file);
-}
-
-GFile *
-g_file_dup (GFile *file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->dup) (file);
-}
-
-guint
-g_file_hash (gconstpointer file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->hash) ((GFile *)file);
-}
-
-gboolean
-g_file_equal (GFile *file1,
- GFile *file2)
-{
- GFileIface *iface;
-
- if (G_TYPE_FROM_INSTANCE (file1) != G_TYPE_FROM_INSTANCE (file2))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file1);
-
- return (* iface->equal) (file1, file2);
-}
-
-
-GFile *
-g_file_get_parent (GFile *file)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->get_parent) (file);
-}
-
-GFile *
-g_file_get_child (GFile *file,
- const char *name)
-{
- return g_file_resolve_relative (file, name);
-}
-
-GFile *
-g_file_get_child_for_display_name (GFile *file,
- const char *display_name,
- GError **error)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->get_child_for_display_name) (file, display_name, error);
-}
-
-GFile *
-g_file_resolve_relative (GFile *file,
- const char *relative_path)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->resolve_relative) (file, relative_path);
-}
-
-GFileEnumerator *
-g_file_enumerate_children (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->enumerate_children == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return NULL;
- }
-
- return (* iface->enumerate_children) (file, attributes, flags,
- cancellable, error);
-}
-
-GFileInfo *
-g_file_get_info (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->get_info == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return NULL;
- }
-
- return (* iface->get_info) (file, attributes, flags, cancellable, error);
-}
-
-void
-g_file_get_info_async (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
- (* iface->get_info_async) (file,
- attributes,
- flags,
- io_priority,
- cancellable,
- callback,
- user_data);
-}
-
-GFileInfo *
-g_file_get_info_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->get_info_finish) (file, res, error);
-}
-
-GFileInfo *
-g_file_get_filesystem_info (GFile *file,
- const char *attributes,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->get_filesystem_info == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return NULL;
- }
-
- return (* iface->get_filesystem_info) (file, attributes, cancellable, error);
-}
-
-/* Fails on directories */
-GFileInputStream *
-g_file_read (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->read == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return NULL;
- }
-
- return (* iface->read) (file, cancellable, error);
-}
-
-GFileOutputStream *
-g_file_append_to (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->append_to == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return NULL;
- }
-
- return (* iface->append_to) (file, cancellable, error);
-}
-
-GFileOutputStream *
-g_file_create (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->create == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return NULL;
- }
-
- return (* iface->create) (file, cancellable, error);
-}
-
-GFileOutputStream *
-g_file_replace (GFile *file,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->replace == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return NULL;
- }
-
-
- /* Handle empty tag string as NULL in consistent way. */
- if (etag && *etag == 0)
- etag = NULL;
-
- return (* iface->replace) (file, etag, make_backup, cancellable, error);
-}
-
-void
-g_file_read_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
- (* iface->read_async) (file,
- io_priority,
- cancellable,
- callback,
- user_data);
-}
-
-GFileInputStream *
-g_file_read_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->read_finish) (file, res, error);
-}
-
-void
-g_file_append_to_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
- (* iface->append_to_async) (file,
- io_priority,
- cancellable,
- callback,
- user_data);
-}
-
-GFileOutputStream *
-g_file_append_to_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->append_to_finish) (file, res, error);
-}
-
-void
-g_file_create_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
- (* iface->create_async) (file,
- io_priority,
- cancellable,
- callback,
- user_data);
-}
-
-GFileOutputStream *
-g_file_create_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->create_finish) (file, res, error);
-}
-
-void
-g_file_replace_async (GFile *file,
- const char *etag,
- gboolean make_backup,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
- (* iface->replace_async) (file,
- etag,
- make_backup,
- io_priority,
- cancellable,
- callback,
- user_data);
-}
-
-GFileOutputStream *
-g_file_replace_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->replace_finish) (file, res, error);
-}
-
-static gboolean
-copy_symlink (GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- const char *target,
- GError **error)
-{
- GError *my_error;
- gboolean tried_delete;
- GFileInfo *info;
- GFileType file_type;
-
- tried_delete = FALSE;
-
- retry:
- my_error = NULL;
- if (!g_file_make_symbolic_link (destination, target, cancellable, &my_error))
- {
- /* Maybe it already existed, and we want to overwrite? */
- if (!tried_delete && (flags & G_FILE_COPY_OVERWRITE) &&
- my_error->domain == G_IO_ERROR && my_error->code == G_IO_ERROR_EXISTS)
- {
- g_error_free (my_error);
-
-
- /* Don't overwrite if the destination is a directory */
- info = g_file_get_info (destination, G_FILE_ATTRIBUTE_STD_TYPE,
- G_FILE_GET_INFO_NOFOLLOW_SYMLINKS,
- cancellable, &my_error);
- if (info != NULL)
- {
- file_type = g_file_info_get_file_type (info);
- g_object_unref (info);
-
- if (file_type == G_FILE_TYPE_DIRECTORY)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY,
- _("Can't copy over directory"));
- return FALSE;
- }
- }
-
- if (!g_file_delete (destination, cancellable, error))
- return FALSE;
-
- tried_delete = TRUE;
- goto retry;
- }
- /* Nah, fail */
- g_propagate_error (error, my_error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static GInputStream *
-open_source_for_copy (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GError *my_error;
- GInputStream *in;
- GFileInfo *info;
- GFileType file_type;
-
- my_error = NULL;
- in = (GInputStream *)g_file_read (source, cancellable, &my_error);
- if (in != NULL)
- return in;
-
- /* There was an error opening the source, try to set a good error for it: */
-
- if (my_error->domain == G_IO_ERROR && my_error->code == G_IO_ERROR_IS_DIRECTORY)
- {
- /* The source is a directory, don't fail with WOULD_RECURSE immediately, as
- that is less useful to the app. Better check for errors on the target instead. */
-
- g_error_free (my_error);
- my_error = NULL;
-
- info = g_file_get_info (destination, G_FILE_ATTRIBUTE_STD_TYPE,
- G_FILE_GET_INFO_NOFOLLOW_SYMLINKS,
- cancellable, &my_error);
- if (info != NULL)
- {
- file_type = g_file_info_get_file_type (info);
- g_object_unref (info);
-
- if (flags & G_FILE_COPY_OVERWRITE)
- {
- if (file_type == G_FILE_TYPE_DIRECTORY)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY,
- _("Can't copy over directory"));
- return NULL;
- }
- /* continue to would_recurse error */
- }
- else
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
- _("Target file exists"));
- return NULL;
- }
- }
- else
- {
- /* Error getting info from target, return that error (except for NOT_FOUND, which is no error here) */
- if (my_error->domain != G_IO_ERROR && my_error->code != G_IO_ERROR_NOT_FOUND)
- {
- g_propagate_error (error, my_error);
- return NULL;
- }
- g_error_free (my_error);
- }
-
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_WOULD_RECURSE,
- _("Can't recursively copy directory"));
- return NULL;
- }
-
- g_propagate_error (error, my_error);
- return NULL;
-}
-
-static gboolean
-should_copy (GFileAttributeInfo *info, gboolean as_move)
-{
- if (as_move)
- return info->flags & G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED;
- return info->flags & G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE;
-}
-
-static char *
-build_attribute_list_for_copy (GFileAttributeInfoList *attributes,
- GFileAttributeInfoList *namespaces,
- gboolean as_move)
-{
- GString *s;
- gboolean first;
- int i;
-
- first = TRUE;
- s = g_string_new ("");
-
- if (attributes)
- {
- for (i = 0; i < attributes->n_infos; i++)
- {
- if (should_copy (&attributes->infos[i], as_move))
- {
- if (first)
- first = FALSE;
- else
- g_string_append_c (s, ',');
-
- g_string_append (s, attributes->infos[i].name);
- }
- }
- }
-
- if (namespaces)
- {
- for (i = 0; i < namespaces->n_infos; i++)
- {
- if (should_copy (&namespaces->infos[i], as_move))
- {
- if (first)
- first = FALSE;
- else
- g_string_append_c (s, ',');
-
- g_string_append (s, namespaces->infos[i].name);
- g_string_append (s, ":*");
- }
- }
- }
-
- return g_string_free (s, FALSE);
-
-}
-
-static gboolean
-copy_attributes (GFile *source,
- GFile *destination,
- gboolean as_move,
- gboolean source_nofollow_symlinks,
- GCancellable *cancellable,
- GError **error)
-{
- GFileAttributeInfoList *attributes, *namespaces;
- char *attrs_to_read;
- gboolean res;
- GFileInfo *info;
-
- /* Ignore errors here, if the target supports no attributes there is nothing to copy */
- attributes = g_file_query_settable_attributes (destination, cancellable, NULL);
- namespaces = g_file_query_writable_namespaces (destination, cancellable, NULL);
-
- if (attributes == NULL && namespaces == NULL)
- return TRUE;
-
- attrs_to_read = build_attribute_list_for_copy (attributes, namespaces, as_move);
-
- /* Ignore errors here, if we can't read some info (e.g. if it doesn't exist)
- we just don't copy it. */
- info = g_file_get_info (source, attrs_to_read,
- source_nofollow_symlinks ? G_FILE_GET_INFO_NOFOLLOW_SYMLINKS:0,
- cancellable,
- NULL);
-
- g_free (attrs_to_read);
-
- res = TRUE;
- if (info)
- {
- res = g_file_set_attributes_from_info (destination,
- info, 0,
- cancellable,
- error);
- g_object_unref (info);
- }
-
- g_file_attribute_info_list_unref (attributes);
- g_file_attribute_info_list_unref (namespaces);
-
- return res;
-}
-
-/* Closes the streams */
-static gboolean
-copy_stream_with_progress (GInputStream *in,
- GOutputStream *out,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error)
-{
- gssize n_read, n_written;
- goffset current_size;
- char buffer[8192], *p;
- gboolean res;
- goffset total_size;
- GFileInfo *info;
-
- total_size = 0;
- info = g_file_input_stream_get_file_info (G_FILE_INPUT_STREAM (in),
- G_FILE_ATTRIBUTE_STD_SIZE,
- cancellable, NULL);
- if (info)
- {
- total_size = g_file_info_get_size (info);
- g_object_unref (info);
- }
-
- current_size = 0;
- res = TRUE;
- while (TRUE)
- {
- n_read = g_input_stream_read (in, buffer, sizeof (buffer), cancellable, error);
- if (n_read == -1)
- {
- res = FALSE;
- break;
- }
-
- if (n_read == 0)
- break;
-
- current_size += n_read;
-
- p = buffer;
- while (n_read > 0)
- {
- n_written = g_output_stream_write (out, p, n_read, cancellable, error);
- if (n_written == -1)
- {
- res = FALSE;
- break;
- }
-
- p += n_written;
- n_read -= n_read;
- }
-
- if (progress_callback)
- progress_callback (current_size, total_size, progress_callback_data);
- }
-
- if (!res)
- error = NULL; /* Ignore further errors */
-
- /* Don't care about errors in source here */
- g_input_stream_close (in, cancellable, NULL);
-
- /* But write errors on close are bad! */
- if (!g_output_stream_close (out, cancellable, error))
- res = FALSE;
-
- g_object_unref (in);
- g_object_unref (out);
-
- return res;
-}
-
-static gboolean
-file_copy_fallback (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error)
-{
- GInputStream *in;
- GOutputStream *out;
- GFileInfo *info;
- const char *target;
-
- /* Maybe copy the symlink? */
- if (flags & G_FILE_COPY_NOFOLLOW_SYMLINKS)
- {
- info = g_file_get_info (source,
- G_FILE_ATTRIBUTE_STD_TYPE "," G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET,
- G_FILE_GET_INFO_NOFOLLOW_SYMLINKS,
- cancellable,
- error);
- if (info == NULL)
- return FALSE;
-
- if (g_file_info_get_file_type (info) == G_FILE_TYPE_SYMBOLIC_LINK &&
- (target = g_file_info_get_symlink_target (info)) != NULL)
- {
- if (!copy_symlink (destination, flags, cancellable, target, error))
- {
- g_object_unref (info);
- return FALSE;
- }
-
- g_object_unref (info);
- goto copied_file;
- }
-
- g_object_unref (info);
- }
-
- in = open_source_for_copy (source, destination, flags, cancellable, error);
- if (in == NULL)
- return FALSE;
-
- if (flags & G_FILE_COPY_OVERWRITE)
- out = (GOutputStream *)g_file_replace (destination, 0, flags & G_FILE_COPY_BACKUP, cancellable, error);
- else
- out = (GOutputStream *)g_file_create (destination, cancellable, error);
-
- if (out == NULL)
- {
- g_object_unref (in);
- return FALSE;
- }
-
- if (!copy_stream_with_progress (in, out, cancellable,
- progress_callback, progress_callback_data,
- error))
- return FALSE;
-
- copied_file:
-
- /* Ignore errors here. Failure to copy metadata is not a hard error */
- copy_attributes (source, destination,
- flags & G_FILE_COPY_ALL_METADATA,
- flags & G_FILE_COPY_NOFOLLOW_SYMLINKS,
- cancellable, NULL);
-
- return TRUE;
-}
-
-/* Errors:
-
- source dest flags res
- - * * G_IO_ERROR_NOT_FOUND
- file - * ok
- file * 0 G_IO_ERROR_EXISTS
- file file overwr ok
- file dir overwr G_IO_ERROR_IS_DIRECTORY
-
- dir - * G_IO_ERROR_WOULD_RECURSE
- dir * 0 G_IO_ERROR_EXISTS
- dir dir overwr G_IO_ERROR_IS_DIRECTORY
- dir file overwr G_IO_ERROR_WOULD_RECURSE
- */
-gboolean
-g_file_copy (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error)
-{
- GFileIface *iface;
- GError *my_error;
- gboolean res;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- if (G_OBJECT_TYPE (source) == G_OBJECT_TYPE (destination))
- {
- iface = G_FILE_GET_IFACE (source);
-
- if (iface->copy)
- {
- my_error = NULL;
- res = (* iface->copy) (source, destination, flags, cancellable, progress_callback, progress_callback_data, &my_error);
-
- if (res)
- return TRUE;
-
- if (my_error->domain != G_IO_ERROR || my_error->code != G_IO_ERROR_NOT_SUPPORTED)
- {
- g_propagate_error (error, my_error);
- return FALSE;
- }
- }
- }
-
- return file_copy_fallback (source, destination, flags, cancellable,
- progress_callback, progress_callback_data,
- error);
-}
-
-/* Errors:
-
- source dest flags res
- - * * G_IO_ERROR_NOT_FOUND
- file - * ok
- file * 0 G_IO_ERROR_EXISTS
- file file overwr ok
- file dir overwr G_IO_ERROR_IS_DIRECTORY
-
- dir - * ok || G_IO_ERROR_WOULD_RECURSE
- dir * 0 G_IO_ERROR_EXISTS
- dir dir overwr G_IO_ERROR_IS_DIRECTORY
- dir file overwr ok || G_IO_ERROR_WOULD_RECURSE
- */
-gboolean
-g_file_move (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error)
-{
- GFileIface *iface;
- GError *my_error;
- gboolean res;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- if (G_OBJECT_TYPE (source) == G_OBJECT_TYPE (destination))
- {
- iface = G_FILE_GET_IFACE (source);
-
- if (iface->move)
- {
- my_error = NULL;
- res = (* iface->move) (source, destination, flags, cancellable, progress_callback, progress_callback_data, &my_error);
-
- if (res)
- return TRUE;
-
- if (my_error->domain != G_IO_ERROR || my_error->code != G_IO_ERROR_NOT_SUPPORTED)
- {
- g_propagate_error (error, my_error);
- return FALSE;
- }
- }
- }
-
- flags |= G_FILE_COPY_ALL_METADATA;
- if (!g_file_copy (source, destination, flags, cancellable,
- progress_callback, progress_callback_data,
- error))
- return FALSE;
-
- return g_file_delete (source, cancellable, error);
-}
-
-gboolean
-g_file_make_directory (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->make_directory == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return FALSE;
- }
-
- return (* iface->make_directory) (file, cancellable, error);
-}
-
-gboolean
-g_file_make_symbolic_link (GFile *file,
- const char *symlink_value,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->make_symbolic_link == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return FALSE;
- }
-
- return (* iface->make_symbolic_link) (file, symlink_value, cancellable, error);
-}
-
-gboolean
-g_file_delete (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->delete_file == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return FALSE;
- }
-
- return (* iface->delete_file) (file, cancellable, error);
-}
-
-gboolean
-g_file_trash (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->trash == NULL)
- {
- g_set_error (error,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Trash not supported"));
- return FALSE;
- }
-
- return (* iface->trash) (file, cancellable, error);
-}
-
-GFile *
-g_file_set_display_name (GFile *file,
- const char *display_name,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (strchr (display_name, '/') != NULL)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT,
- _("File names cannot contain '/'"));
- return FALSE;
- }
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->set_display_name) (file, display_name, cancellable, error);
-}
-/*
- Returns the type and full attribute name of all the attributes that
- the file can set. This doesn't mean setting it will always succeed though,
- you might get an access failure, or some specific file may not support a
- specific attribute
-*/
-GFileAttributeInfoList *
-g_file_query_settable_attributes (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
- GError *my_error;
- GFileAttributeInfoList *list;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->query_settable_attributes == NULL)
- return g_file_attribute_info_list_new ();
-
- my_error = NULL;
- list = (* iface->query_settable_attributes) (file, cancellable, &my_error);
-
- if (list == NULL)
- {
- if (my_error->domain == G_IO_ERROR && my_error->code == G_IO_ERROR_NOT_SUPPORTED)
- {
- list = g_file_attribute_info_list_new ();
- g_error_free (my_error);
- }
- else
- g_propagate_error (error, my_error);
- }
-
- return list;
-}
-
-/* Returns the list of attribute namespaces where the user can create
- their own attribute names, such as extended attributes */
-GFileAttributeInfoList *
-g_file_query_writable_namespaces (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
- GError *my_error;
- GFileAttributeInfoList *list;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->query_writable_namespaces == NULL)
- return g_file_attribute_info_list_new ();
-
- my_error = NULL;
- list = (* iface->query_writable_namespaces) (file, cancellable, &my_error);
-
- if (list == NULL)
- {
- if (my_error->domain == G_IO_ERROR && my_error->code == G_IO_ERROR_NOT_SUPPORTED)
- {
- list = g_file_attribute_info_list_new ();
- g_error_free (my_error);
- }
- else
- g_propagate_error (error, my_error);
- }
-
- return list;
-}
-
-gboolean
-g_file_set_attribute (GFile *file,
- const char *attribute,
- const GFileAttributeValue *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->set_attribute == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return FALSE;
- }
-
- return (* iface->set_attribute) (file, attribute, value, flags, cancellable, error);
-}
-
-/* Tries to set all attributes in the GFileInfo on the target values, not stopping
- on the first error.
- Will return TRUE if there was any error, and *error will be set to
- the first error. Error on particular fields are flagged by setting the
- "status" field in the attribute value to G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING.
-*/
-gboolean
-g_file_set_attributes_from_info (GFile *file,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileIface *iface;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
-
- g_file_info_clear_status (info);
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->set_attributes_from_info) (file, info, flags, cancellable, error);
-}
-
-static gboolean
-g_file_real_set_attributes_from_info (GFile *file,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- char **attributes;
- int i;
- gboolean res;
- GFileAttributeValue *value;
-
- res = TRUE;
-
- attributes = g_file_info_list_attributes (info, NULL);
-
- for (i = 0; attributes[i] != NULL; i++)
- {
- value = (GFileAttributeValue *)g_file_info_get_attribute (info, attributes[i]);
-
- if (value->status != G_FILE_ATTRIBUTE_STATUS_UNSET)
- continue;
-
- if (!g_file_set_attribute (file, attributes[i], value, flags, cancellable, error))
- {
- value->status = G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING;
- res = FALSE;
- /* Don't set error multiple times */
- error = NULL;
- }
- else
- value->status = G_FILE_ATTRIBUTE_STATUS_SET;
- }
-
- g_strfreev (attributes);
-
- return res;
-}
-
-
-gboolean
-g_file_set_attribute_string (GFile *file,
- const char *attribute,
- const char *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileAttributeValue v;
- v.type = G_FILE_ATTRIBUTE_TYPE_STRING;
- v.u.string = (char *)value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
-}
-
-gboolean
-g_file_set_attribute_byte_string (GFile *file,
- const char *attribute,
- const char *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileAttributeValue v;
- v.type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING;
- v.u.string = (char *)value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
-}
-
-gboolean
-g_file_set_attribute_uint32 (GFile *file,
- const char *attribute,
- guint32 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileAttributeValue v;
- v.type = G_FILE_ATTRIBUTE_TYPE_UINT32;
- v.u.uint32 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
-}
-
-gboolean
-g_file_set_attribute_int32 (GFile *file,
- const char *attribute,
- gint32 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileAttributeValue v;
- v.type = G_FILE_ATTRIBUTE_TYPE_INT32;
- v.u.int32 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
-}
-
-gboolean
-g_file_set_attribute_uint64 (GFile *file,
- const char *attribute,
- guint64 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
- {
- GFileAttributeValue v;
- v.type = G_FILE_ATTRIBUTE_TYPE_UINT64;
- v.u.uint64 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
-}
-
-gboolean
-g_file_set_attribute_int64 (GFile *file,
- const char *attribute,
- gint64 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileAttributeValue v;
- v.type = G_FILE_ATTRIBUTE_TYPE_INT64;
- v.u.int64 = value;
- return g_file_set_attribute (file, attribute, &v, flags, cancellable, error);
-}
-
-void
-g_file_mount_mountable (GFile *file,
- GMountOperation *mount_operation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->mount_mountable == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (file),
- callback,
- user_data,
- G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- }
-
- (* iface->mount_mountable) (file,
- mount_operation,
- cancellable,
- callback,
- user_data);
-
-}
-
-GFile *
-g_file_mount_mountable_finish (GFile *file,
- GAsyncResult *result,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->mount_mountable_finish) (file, result, error);
-}
-
-void
-g_file_unmount_mountable (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->unmount_mountable == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (file),
- callback,
- user_data,
- G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- }
-
- (* iface->unmount_mountable) (file,
- cancellable,
- callback,
- user_data);
-}
-
-gboolean
-g_file_unmount_mountable_finish (GFile *file,
- GAsyncResult *result,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->unmount_mountable_finish) (file, result, error);
-}
-
-void
-g_file_eject_mountable (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->eject_mountable == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (file),
- callback,
- user_data,
- G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- }
-
- (* iface->eject_mountable) (file,
- cancellable,
- callback,
- user_data);
-}
-
-gboolean
-g_file_eject_mountable_finish (GFile *file,
- GAsyncResult *result,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
- iface = G_FILE_GET_IFACE (file);
- return (* iface->eject_mountable_finish) (file, result, error);
-}
-
-GDirectoryMonitor*
-g_file_monitor_directory (GFile *file,
- GFileMonitorFlags flags)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- if (iface->monitor_dir == NULL)
- return NULL;
-
- return (* iface->monitor_dir) (file, flags);
-}
-
-GFileMonitor*
-g_file_monitor_file (GFile *file,
- GFileMonitorFlags flags)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (file);
-
- return (* iface->monitor_file) (file, flags);
-}
-
-/* Fallback to polling */
-static GFileMonitor*
-g_file_real_monitor_file (GFile *file,
- GFileMonitorFlags flags)
-{
- return g_poll_file_monitor_new (file);
-}
-
-/********************************************
- * Default implementation of async ops *
- ********************************************/
-
-typedef struct {
- char *attributes;
- GFileGetInfoFlags flags;
- GFileInfo *info;
-} GetInfoAsyncData;
-
-static void
-get_info_data_free (GetInfoAsyncData *data)
-{
- if (data->info)
- g_object_unref (data->info);
- g_free (data->attributes);
- g_free (data);
-}
-
-static void
-get_info_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GError *error = NULL;
- GetInfoAsyncData *data;
- GFileInfo *info;
-
- data = g_simple_async_result_get_op_res_gpointer (res);
-
- info = g_file_get_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);
- }
- else
- data->info = info;
-}
-
-static void
-g_file_real_get_info_async (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
- GetInfoAsyncData *data;
-
- data = g_new0 (GetInfoAsyncData, 1);
- data->attributes = g_strdup (attributes);
- data->flags = flags;
-
- res = g_simple_async_result_new (G_OBJECT (file), callback, user_data, g_file_real_get_info_async);
- g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)get_info_data_free);
-
- g_simple_async_result_run_in_thread (res, get_info_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static GFileInfo *
-g_file_real_get_info_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- GetInfoAsyncData *data;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_get_info_async);
-
- data = g_simple_async_result_get_op_res_gpointer (simple);
- if (data->info)
- return g_object_ref (data->info);
-
- return NULL;
-}
-
-static void
-open_read_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GFileIface *iface;
- GFileInputStream *stream;
- GError *error = NULL;
-
- iface = G_FILE_GET_IFACE (object);
-
- stream = iface->read (G_FILE (object), cancellable, &error);
-
- if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
- else
- g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
-}
-
-static void
-g_file_real_read_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (file), callback, user_data, g_file_real_read_async);
-
- g_simple_async_result_run_in_thread (res, open_read_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static GFileInputStream *
-g_file_real_read_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- gpointer op;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_read_async);
-
- op = g_simple_async_result_get_op_res_gpointer (simple);
- if (op)
- return g_object_ref (op);
-
- return NULL;
-}
-
-static void
-append_to_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GFileIface *iface;
- GFileOutputStream *stream;
- GError *error = NULL;
-
- iface = G_FILE_GET_IFACE (object);
-
- stream = iface->append_to (G_FILE (object), cancellable, &error);
-
- if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
- else
- g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
-}
-
-static void
-g_file_real_append_to_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (file), callback, user_data, g_file_real_append_to_async);
-
- g_simple_async_result_run_in_thread (res, append_to_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static GFileOutputStream *
-g_file_real_append_to_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- gpointer op;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_append_to_async);
-
- op = g_simple_async_result_get_op_res_gpointer (simple);
- if (op)
- return g_object_ref (op);
-
- return NULL;
-}
-
-static void
-create_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GFileIface *iface;
- GFileOutputStream *stream;
- GError *error = NULL;
-
- iface = G_FILE_GET_IFACE (object);
-
- stream = iface->create (G_FILE (object), cancellable, &error);
-
- if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
- else
- g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
-}
-
-static void
-g_file_real_create_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (file), callback, user_data, g_file_real_create_async);
-
- g_simple_async_result_run_in_thread (res, create_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static GFileOutputStream *
-g_file_real_create_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- gpointer op;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_create_async);
-
- op = g_simple_async_result_get_op_res_gpointer (simple);
- if (op)
- return g_object_ref (op);
-
- return NULL;
-}
-
-typedef struct {
- GFileOutputStream *stream;
- char *etag;
- gboolean make_backup;
-} ReplaceAsyncData;
-
-static void
-replace_async_data_free (ReplaceAsyncData *data)
-{
- if (data->stream)
- g_object_unref (data->stream);
- g_free (data->etag);
- g_free (data);
-}
-
-static void
-replace_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GFileIface *iface;
- GFileOutputStream *stream;
- GError *error = NULL;
- ReplaceAsyncData *data;
-
- iface = G_FILE_GET_IFACE (object);
-
- data = g_simple_async_result_get_op_res_gpointer (res);
-
- stream = iface->replace (G_FILE (object), data->etag, data->make_backup, cancellable, &error);
-
- if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
- else
- data->stream = stream;
-}
-
-static void
-g_file_real_replace_async (GFile *file,
- const char *etag,
- gboolean make_backup,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
- ReplaceAsyncData *data;
-
- data = g_new0 (ReplaceAsyncData, 1);
- data->etag = g_strdup (etag);
- data->make_backup = make_backup;
-
- res = g_simple_async_result_new (G_OBJECT (file), callback, user_data, g_file_real_replace_async);
- g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)replace_async_data_free);
-
- g_simple_async_result_run_in_thread (res, replace_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static GFileOutputStream *
-g_file_real_replace_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- ReplaceAsyncData *data;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_real_replace_async);
-
- data = g_simple_async_result_get_op_res_gpointer (simple);
- if (data->stream)
- return g_object_ref (data->stream);
-
- return NULL;
-}
-
-/********************************************
- * Default VFS operations *
- ********************************************/
-
-GFile *
-g_file_new_for_path (const char *path)
-{
- return g_vfs_get_file_for_path (g_vfs_get_default (),
- path);
-}
-
-GFile *
-g_file_new_for_uri (const char *uri)
-{
- return g_vfs_get_file_for_uri (g_vfs_get_default (),
- uri);
-}
-
-GFile *
-g_file_parse_name (const char *parse_name)
-{
- return g_vfs_parse_name (g_vfs_get_default (),
- parse_name);
-}
-
-static gboolean
-is_valid_scheme_character (char c)
-{
- return g_ascii_isalnum (c) || c == '+' || c == '-' || c == '.';
-}
-
-static gboolean
-has_valid_scheme (const char *uri)
-{
- const char *p;
-
- p = uri;
-
- if (!is_valid_scheme_character (*p))
- return FALSE;
-
- do {
- p++;
- } while (is_valid_scheme_character (*p));
-
- return *p == ':';
-}
-
-GFile *
-g_file_new_for_commandline_arg (const char *arg)
-{
- GFile *file;
- char *filename;
- char *current_dir;
-
- g_return_val_if_fail (arg != NULL, NULL);
-
- if (g_path_is_absolute (arg))
- return g_file_new_for_path (arg);
-
- if (has_valid_scheme (arg))
- return g_file_new_for_uri (arg);
-
- current_dir = g_get_current_dir ();
- filename = g_build_filename (current_dir, arg, NULL);
- g_free (current_dir);
-
- file = g_file_new_for_path (filename);
- g_free (filename);
-
- return file;
-}
-
-void
-g_mount_for_location (GFile *location,
- GMountOperation *mount_operation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIface *iface;
-
- iface = G_FILE_GET_IFACE (location);
-
- if (iface->mount_for_location == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (location),
- callback, user_data,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("volume doesn't implement mount"));
-
- return;
- }
-
- return (* iface->mount_for_location) (location, mount_operation, cancellable, callback, user_data);
-
-}
-
-gboolean
-g_mount_for_location_finish (GFile *location,
- GAsyncResult *result,
- GError **error)
-{
- GFileIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
- iface = G_FILE_GET_IFACE (location);
-
- return (* iface->mount_for_location_finish) (location, result, error);
-}
-
-/********************************************
- * Utility functions *
- ********************************************/
-
-#define GET_CONTENT_BLOCK_SIZE 8192
-
-gboolean
-g_file_load_contents (GFile *file,
- GCancellable *cancellable,
- char **contents,
- gsize *length,
- GError **error)
-{
- GFileInputStream *in;
- GByteArray *content;
- gsize pos;
- gssize res;
-
- in = g_file_read (file,
- cancellable,
- error);
- if (in == NULL)
- return FALSE;
-
- content = g_byte_array_new ();
- pos = 0;
-
- g_byte_array_set_size (content, pos + GET_CONTENT_BLOCK_SIZE + 1);
- while ((res = g_input_stream_read (G_INPUT_STREAM (in),
- content->data + pos,
- GET_CONTENT_BLOCK_SIZE,
- cancellable, error)) > 0)
- {
- pos += res;
- g_byte_array_set_size (content, pos + GET_CONTENT_BLOCK_SIZE + 1);
- }
-
- /* Ignore errors on close */
- g_input_stream_close (G_INPUT_STREAM (in), cancellable, NULL);
-
- if (res < 0)
- {
- /* error is set already */
- g_byte_array_free (content, TRUE);
- return FALSE;
- }
-
- if (length)
- *length = pos;
-
- /* Zero terminate (we got an extra byte allocated for this */
- content->data[pos] = 0;
-
- *contents = (char *)g_byte_array_free (content, FALSE);
-
- return TRUE;
-}
-
-typedef struct {
- GFile *file;
- GError *error;
- GCancellable *cancellable;
- GAsyncReadyCallback callback;
- gpointer user_data;
- GByteArray *content;
- gsize pos;
-} LoadContentsData;
-
-
-static void
-load_contents_data_free (LoadContentsData *data)
-{
- if (data->error)
- g_error_free (data->error);
- if (data->cancellable)
- g_object_unref (data->cancellable);
- if (data->content)
- g_byte_array_free (data->content, TRUE);
- g_object_unref (data->file);
- g_free (data);
-}
-
-static void
-load_contents_close_callback (GObject *obj,
- GAsyncResult *close_res,
- gpointer user_data)
-{
- GInputStream *stream = G_INPUT_STREAM (obj);
- LoadContentsData *data = user_data;
- GSimpleAsyncResult *res;
-
- /* Ignore errors here, we're only reading anyway */
- g_input_stream_close_finish (stream, close_res, NULL);
- g_object_unref (stream);
-
- res = g_simple_async_result_new (G_OBJECT (data->file),
- data->callback,
- data->user_data,
- g_file_load_contents_async);
- g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)load_contents_data_free);
- g_simple_async_result_complete (res);
- g_object_unref (res);
-}
-
-static void
-load_contents_read_callback (GObject *obj,
- GAsyncResult *read_res,
- gpointer user_data)
-{
- GInputStream *stream = G_INPUT_STREAM (obj);
- LoadContentsData *data = user_data;
- GError *error = NULL;
- gssize read_size;
-
- read_size = g_input_stream_read_finish (stream, read_res, &error);
-
- if (read_size <= 0)
- {
- /* Error or EOF, close the file */
- if (read_size < 0)
- data->error = error;
- g_input_stream_close_async (stream, 0,
- data->cancellable,
- load_contents_close_callback, data);
- }
- else if (read_size > 0)
- {
- data->pos += read_size;
-
- g_byte_array_set_size (data->content,
- data->pos + GET_CONTENT_BLOCK_SIZE);
- g_input_stream_read_async (stream,
- data->content->data + data->pos,
- GET_CONTENT_BLOCK_SIZE,
- 0,
- data->cancellable,
- load_contents_read_callback,
- data);
- }
-}
-
-static void
-load_contents_open_callback (GObject *obj,
- GAsyncResult *open_res,
- gpointer user_data)
-{
- GFile *file = G_FILE (obj);
- GFileInputStream *stream;
- LoadContentsData *data = user_data;
- GError *error = NULL;
- GSimpleAsyncResult *res;
-
- stream = g_file_read_finish (file, open_res, &error);
-
- if (stream)
- {
- g_byte_array_set_size (data->content,
- data->pos + GET_CONTENT_BLOCK_SIZE);
- g_input_stream_read_async (G_INPUT_STREAM (stream),
- data->content->data + data->pos,
- GET_CONTENT_BLOCK_SIZE,
- 0,
- data->cancellable,
- load_contents_read_callback,
- data);
-
- }
- else
- {
- res = g_simple_async_result_new_from_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);
- }
-}
-
-void
-g_file_load_contents_async (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- LoadContentsData *data;
-
- data = g_new0 (LoadContentsData, 1);
-
- if (cancellable)
- data->cancellable = g_object_ref (cancellable);
- data->callback = callback;
- data->user_data = user_data;
- data->content = g_byte_array_new ();
- data->file = g_object_ref (file);
-
- g_file_read_async (file,
- 0,
- cancellable,
- load_contents_open_callback,
- data);
-}
-
-gboolean
-g_file_load_contents_finish (GFile *file,
- GAsyncResult *res,
- char **contents,
- gsize *length,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- LoadContentsData *data;
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_load_contents_async);
-
- data = g_simple_async_result_get_op_res_gpointer (simple);
-
- if (data->error)
- {
- g_propagate_error (error, data->error);
- data->error = NULL;
- *contents = NULL;
- if (length)
- *length = 0;
- return FALSE;
- }
-
- if (length)
- *length = data->pos;
-
- /* Zero terminate */
- g_byte_array_set_size (data->content,
- data->pos + 1);
- data->content->data[data->pos] = 0;
-
- *contents = (char *)g_byte_array_free (data->content, FALSE);
- data->content = NULL;
-
- return TRUE;
-}
-
-gboolean
-g_file_replace_contents (GFile *file,
- const char *contents,
- gsize length,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GError **error)
-{
- GFileOutputStream *out;
- gsize pos, remainder;
- gssize res;
-
- out = g_file_replace (file,
- etag,
- make_backup,
- cancellable,
- error);
- if (out == NULL)
- return FALSE;
-
- pos = 0;
- remainder = length;
- while (remainder > 0 &&
- (res = g_output_stream_write (G_OUTPUT_STREAM (out),
- contents + pos,
- MIN (remainder, GET_CONTENT_BLOCK_SIZE),
- cancellable,
- error)) > 0)
- {
- pos += res;
- remainder -= res;
- }
-
- if (remainder > 0 && res < 0)
- {
- /* Ignore errors on close */
- g_output_stream_close (G_OUTPUT_STREAM (out), cancellable, NULL);
-
- /* error is set already */
- return FALSE;
- }
-
- if (!g_output_stream_close (G_OUTPUT_STREAM (out), cancellable, error))
- return FALSE;
-
- return TRUE;
-}
-
-typedef struct {
- GFile *file;
- GError *error;
- GCancellable *cancellable;
- GAsyncReadyCallback callback;
- gpointer user_data;
- const char *content;
- gsize length;
- gsize pos;
-} ReplaceContentsData;
-
-static void
-replace_contents_data_free (ReplaceContentsData *data)
-{
- if (data->error)
- g_error_free (data->error);
- if (data->cancellable)
- g_object_unref (data->cancellable);
- g_object_unref (data->file);
- g_free (data);
-}
-
-static void
-replace_contents_close_callback (GObject *obj,
- GAsyncResult *close_res,
- gpointer user_data)
-{
- GOutputStream *stream = G_OUTPUT_STREAM (obj);
- ReplaceContentsData *data = user_data;
- GSimpleAsyncResult *res;
-
- /* Ignore errors here, we're only reading anyway */
- g_output_stream_close_finish (stream, close_res, NULL);
- g_object_unref (stream);
-
- res = g_simple_async_result_new (G_OBJECT (data->file),
- data->callback,
- data->user_data,
- g_file_replace_contents_async);
- g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify)replace_contents_data_free);
- g_simple_async_result_complete (res);
- g_object_unref (res);
-}
-
-static void
-replace_contents_write_callback (GObject *obj,
- GAsyncResult *read_res,
- gpointer user_data)
-{
- GOutputStream *stream = G_OUTPUT_STREAM (obj);
- ReplaceContentsData *data = user_data;
- GError *error = NULL;
- gssize write_size;
-
- write_size = g_output_stream_write_finish (stream, read_res, &error);
-
- if (write_size <= 0)
- {
- /* Error or EOF, close the file */
- if (write_size < 0)
- data->error = error;
- g_output_stream_close_async (stream, 0,
- data->cancellable,
- replace_contents_close_callback, data);
- }
- else if (write_size > 0)
- {
- data->pos += write_size;
-
- if (data->pos >= data->length)
- g_output_stream_close_async (stream, 0,
- data->cancellable,
- replace_contents_close_callback, data);
- else
- g_output_stream_write_async (stream,
- data->content + data->pos,
- data->length - data->pos,
- 0,
- data->cancellable,
- replace_contents_write_callback,
- data);
- }
-}
-
-static void
-replace_contents_open_callback (GObject *obj,
- GAsyncResult *open_res,
- gpointer user_data)
-{
- GFile *file = G_FILE (obj);
- GFileOutputStream *stream;
- ReplaceContentsData *data = user_data;
- GError *error = NULL;
- GSimpleAsyncResult *res;
-
- stream = g_file_replace_finish (file, open_res, &error);
-
- if (stream)
- {
- g_output_stream_write_async (G_OUTPUT_STREAM (stream),
- data->content + data->pos,
- data->length - data->pos,
- 0,
- data->cancellable,
- replace_contents_write_callback,
- data);
-
- }
- else
- {
- res = g_simple_async_result_new_from_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);
- }
-}
-
-void
-g_file_replace_contents_async (GFile *file,
- const char *contents,
- gsize length,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- ReplaceContentsData *data;
-
- data = g_new0 (ReplaceContentsData, 1);
-
- if (cancellable)
- data->cancellable = g_object_ref (cancellable);
- data->callback = callback;
- data->user_data = user_data;
- data->content = contents;
- data->length = length;
- data->pos = 0;
- data->file = g_object_ref (file);
-
- g_file_replace_async (file,
- etag,
- make_backup,
- 0,
- cancellable,
- replace_contents_open_callback,
- data);
-}
-
-gboolean
-g_file_replace_contents_finish (GFile *file,
- GAsyncResult *res,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- ReplaceContentsData *data;
-
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_replace_contents_async);
-
- data = g_simple_async_result_get_op_res_gpointer (simple);
-
- if (data->error)
- {
- g_propagate_error (error, data->error);
- data->error = NULL;
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/gio/gfile.h b/gio/gfile.h
deleted file mode 100644
index e189ace3..00000000
--- a/gio/gfile.h
+++ /dev/null
@@ -1,485 +0,0 @@
-#ifndef __G_FILE_H__
-#define __G_FILE_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gfileinfo.h>
-#include <gio/gfileenumerator.h>
-#include <gio/gfileinputstream.h>
-#include <gio/gfileoutputstream.h>
-#include <gio/gmountoperation.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILE (g_file_get_type ())
-#define G_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_FILE, GFile))
-#define G_IS_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_FILE))
-#define G_FILE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_FILE, GFileIface))
-
-typedef enum {
- G_FILE_GET_INFO_NOFOLLOW_SYMLINKS = (1<<0)
-} GFileGetInfoFlags;
-
-typedef enum {
- G_FILE_COPY_OVERWRITE = (1<<0),
- G_FILE_COPY_BACKUP = (1<<1),
- G_FILE_COPY_NOFOLLOW_SYMLINKS = (1<<2),
- G_FILE_COPY_ALL_METADATA = (1<<3),
-} GFileCopyFlags;
-
-typedef enum {
- G_FILE_MONITOR_FLAGS_NONE = 0,
- G_FILE_MONITOR_FLAGS_MONITOR_MOUNTS = (1<<0)
-} GFileMonitorFlags;
-
-typedef struct _GFile GFile; /* Dummy typedef */
-typedef struct _GFileIface GFileIface;
-typedef struct _GDirectoryMonitor GDirectoryMonitor;
-typedef struct _GFileMonitor GFileMonitor;
-
-typedef void (*GFileProgressCallback) (goffset current_num_bytes,
- goffset total_num_bytes,
- gpointer user_data);
-
-struct _GFileIface
-{
- GTypeInterface g_iface;
-
- /* Virtual Table */
-
- GFile * (*dup) (GFile *file);
- guint (*hash) (GFile *file);
- gboolean (*equal) (GFile *file1,
- GFile *file2);
- gboolean (*is_native) (GFile *file);
- char * (*get_basename) (GFile *file);
- char * (*get_path) (GFile *file);
- char * (*get_uri) (GFile *file);
- char * (*get_parse_name) (GFile *file);
- GFile * (*get_parent) (GFile *file);
- GFile * (*resolve_relative) (GFile *file,
- const char *relative_path);
- GFile * (*get_child_for_display_name) (GFile *file,
- const char *display_name,
- GError **error);
- GFileEnumerator * (*enumerate_children) (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
- GFileInfo * (*get_info) (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
- void (*get_info_async) (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GFileInfo * (*get_info_finish) (GFile *file,
- GAsyncResult *res,
- GError **error);
- GFileInfo * (*get_filesystem_info)(GFile *file,
- const char *attributes,
- GCancellable *cancellable,
- GError **error);
- GFile * (*set_display_name) (GFile *file,
- const char *display_name,
- GCancellable *cancellable,
- GError **error);
- GFileAttributeInfoList * (*query_settable_attributes) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- GFileAttributeInfoList * (*query_writable_namespaces) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- gboolean (*set_attribute) (GFile *file,
- const char *attribute,
- const GFileAttributeValue *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
- gboolean (*set_attributes_from_info) (GFile *file,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
- GFileInputStream * (*read) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- GFileOutputStream * (*append_to) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- GFileOutputStream * (*create) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- GFileOutputStream * (*replace) (GFile *file,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GError **error);
- gboolean (*delete_file) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- gboolean (*trash) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- gboolean (*make_directory) (GFile *file,
- GCancellable *cancellable,
- GError **error);
- gboolean (*make_symbolic_link) (GFile *file,
- const char *symlink_value,
- GCancellable *cancellable,
- GError **error);
- gboolean (*copy) (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error);
- gboolean (*move) (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error);
-
- void (*read_async) (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GFileInputStream * (*read_finish) (GFile *file,
- GAsyncResult *res,
- GError **error);
-
- void (*append_to_async) (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GFileOutputStream * (*append_to_finish) (GFile *file,
- GAsyncResult *res,
- GError **error);
- void (*create_async) (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GFileOutputStream * (*create_finish) (GFile *file,
- GAsyncResult *res,
- GError **error);
- void (*replace_async) (GFile *file,
- const char *etag,
- gboolean make_backup,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GFileOutputStream * (*replace_finish) (GFile *file,
- GAsyncResult *res,
- GError **error);
-
-
- void (*mount_mountable) (GFile *file,
- GMountOperation *mount_operation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GFile * (*mount_mountable_finish) (GFile *file,
- GAsyncResult *result,
- GError **error);
- void (*unmount_mountable) (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*unmount_mountable_finish) (GFile *file,
- GAsyncResult *result,
- GError **error);
- void (*eject_mountable) (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*eject_mountable_finish) (GFile *file,
- GAsyncResult *result,
- GError **error);
-
-
- void (*mount_for_location) (GFile *location,
- GMountOperation *mount_operation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*mount_for_location_finish) (GFile *location,
- GAsyncResult *result,
- GError **error);
-
- GDirectoryMonitor* (*monitor_dir) (GFile *file,
- GFileMonitorFlags flags);
-
- GFileMonitor* (*monitor_file) (GFile *file,
- GFileMonitorFlags flags);
-};
-
-GType g_file_get_type (void) G_GNUC_CONST;
-
-GFile * g_file_new_for_path (const char *path);
-GFile * g_file_new_for_uri (const char *uri);
-GFile * g_file_new_for_commandline_arg (const char *arg);
-GFile * g_file_parse_name (const char *parse_name);
-GFile * g_file_dup (GFile *file);
-guint g_file_hash (gconstpointer file);
-gboolean g_file_equal (GFile *file1,
- GFile *file2);
-char * g_file_get_basename (GFile *file);
-char * g_file_get_path (GFile *file);
-char * g_file_get_uri (GFile *file);
-char * g_file_get_parse_name (GFile *file);
-GFile * g_file_get_parent (GFile *file);
-GFile * g_file_get_child (GFile *file,
- const char *name);
-GFile * g_file_get_child_for_display_name (GFile *file,
- const char *display_name,
- GError **error);
-GFile * g_file_resolve_relative (GFile *file,
- const char *relative_path);
-gboolean g_file_is_native (GFile *file);
-GFileInputStream * g_file_read (GFile *file,
- GCancellable *cancellable,
- GError **error);
-void g_file_read_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GFileInputStream * g_file_read_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-GFileOutputStream * g_file_append_to (GFile *file,
- GCancellable *cancellable,
- GError **error);
-GFileOutputStream * g_file_create (GFile *file,
- GCancellable *cancellable,
- GError **error);
-GFileOutputStream * g_file_replace (GFile *file,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GError **error);
-void g_file_append_to_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GFileOutputStream * g_file_append_to_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-void g_file_create_async (GFile *file,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GFileOutputStream * g_file_create_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-void g_file_replace_async (GFile *file,
- const char *etag,
- gboolean make_backup,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GFileOutputStream * g_file_replace_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-GFileInfo * g_file_get_info (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-void g_file_get_info_async (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GFileInfo * g_file_get_info_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-GFileInfo * g_file_get_filesystem_info (GFile *file,
- const char *attributes,
- GCancellable *cancellable,
- GError **error);
-GFileEnumerator * g_file_enumerate_children (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-GFile * g_file_set_display_name (GFile *file,
- const char *display_name,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_delete (GFile *file,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_trash (GFile *file,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_copy (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error);
-gboolean g_file_move (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error);
-gboolean g_file_make_directory (GFile *file,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_make_symbolic_link (GFile *file,
- const char *symlink_value,
- GCancellable *cancellable,
- GError **error);
-GFileAttributeInfoList *g_file_query_settable_attributes (GFile *file,
- GCancellable *cancellable,
- GError **error);
-GFileAttributeInfoList *g_file_query_writable_namespaces (GFile *file,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attribute (GFile *file,
- const char *attribute,
- const GFileAttributeValue *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attributes_from_info (GFile *file,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attribute_string (GFile *file,
- const char *attribute,
- const char *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attribute_byte_string (GFile *file,
- const char *attribute,
- const char *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attribute_uint32 (GFile *file,
- const char *attribute,
- guint32 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attribute_int32 (GFile *file,
- const char *attribute,
- gint32 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attribute_uint64 (GFile *file,
- const char *attribute,
- guint64 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_set_attribute_int64 (GFile *file,
- const char *attribute,
- gint64 value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-void g_mount_for_location (GFile *location,
- GMountOperation *mount_operation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_mount_for_location_finish (GFile *location,
- GAsyncResult *result,
- GError **error);
-void g_file_mount_mountable (GFile *file,
- GMountOperation *mount_operation,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GFile * g_file_mount_mountable_finish (GFile *file,
- GAsyncResult *result,
- GError **error);
-void g_file_unmount_mountable (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_file_unmount_mountable_finish (GFile *file,
- GAsyncResult *result,
- GError **error);
-void g_file_eject_mountable (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_file_eject_mountable_finish (GFile *file,
- GAsyncResult *result,
- GError **error);
-
-
-
-GDirectoryMonitor* g_file_monitor_directory (GFile *file,
- GFileMonitorFlags flags);
-GFileMonitor* g_file_monitor_file (GFile *file,
- GFileMonitorFlags flags);
-
-
-/* Utilities */
-
-gboolean g_file_load_contents (GFile *file,
- GCancellable *cancellable,
- char **contents,
- gsize *length,
- GError **error);
-void g_file_load_contents_async (GFile *file,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_file_load_contents_finish (GFile *file,
- GAsyncResult *res,
- char **contents,
- gsize *length,
- GError **error);
-gboolean g_file_replace_contents (GFile *file,
- const char *contents,
- gsize length,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GError **error);
-void g_file_replace_contents_async (GFile *file,
- const char *contents,
- gsize length,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_file_replace_contents_finish (GFile *file,
- GAsyncResult *res,
- GError **error);
-
-
-G_END_DECLS
-
-#endif /* __G_FILE_H__ */
diff --git a/gio/gfileattribute.c b/gio/gfileattribute.c
deleted file mode 100644
index 002e33bd..00000000
--- a/gio/gfileattribute.c
+++ /dev/null
@@ -1,469 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include "gfileattribute.h"
-#include <glib/gi18n-lib.h>
-
-void
-g_file_attribute_value_free (GFileAttributeValue *attr)
-{
- g_file_attribute_value_clear (attr);
- g_free (attr);
-}
-
-void
-g_file_attribute_value_clear (GFileAttributeValue *attr)
-{
- if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
- attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
- g_free (attr->u.string);
-
- if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT &&
- attr->u.obj != NULL)
- g_object_unref (attr->u.obj);
-
- attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
-}
-
-void
-g_file_attribute_value_set (GFileAttributeValue *attr,
- const GFileAttributeValue *new_value)
-{
- g_file_attribute_value_clear (attr);
- *attr = *new_value;
-
- if (attr->type == G_FILE_ATTRIBUTE_TYPE_STRING ||
- attr->type == G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
- attr->u.string = g_strdup (attr->u.string);
-
- if (attr->type == G_FILE_ATTRIBUTE_TYPE_OBJECT &&
- attr->u.obj != NULL)
- g_object_ref (attr->u.obj);
-}
-
-GFileAttributeValue *
-g_file_attribute_value_new (void)
-{
- GFileAttributeValue *attr;
-
- attr = g_new (GFileAttributeValue, 1);
- attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
- return attr;
-}
-
-GFileAttributeValue *
-g_file_attribute_value_dup (const GFileAttributeValue *old_attr)
-{
- GFileAttributeValue *attr;
-
- attr = g_new (GFileAttributeValue, 1);
- attr->type = G_FILE_ATTRIBUTE_TYPE_INVALID;
- g_file_attribute_value_set (attr, old_attr);
- return attr;
-}
-
-static gboolean
-valid_char (char c)
-{
- return c >= 32 && c <= 126 && c != '\\';
-}
-
-static char *
-escape_byte_string (const char *str)
-{
- size_t len;
- int num_invalid, i;
- char *escaped_val, *p;
- unsigned char c;
- char *hex_digits = "0123456789abcdef";
-
- len = strlen (str);
-
- num_invalid = 0;
- for (i = 0; i < len; i++)
- {
- if (!valid_char (str[i]))
- num_invalid++;
- }
-
- if (num_invalid == 0)
- return g_strdup (str);
- else
- {
- escaped_val = g_malloc (len + num_invalid*3 + 1);
-
- p = escaped_val;
- for (i = 0; i < len; i++)
- {
- c = str[i];
- if (valid_char (c))
- *p++ = c;
- else
- {
- *p++ = '\\';
- *p++ = 'x';
- *p++ = hex_digits[(c >> 8) & 0xf];
- *p++ = hex_digits[c & 0xf];
- }
- }
- *p++ = 0;
- return escaped_val;
- }
-}
-
-char *
-g_file_attribute_value_as_string (const GFileAttributeValue *attr)
-{
- char *str;
-
- switch (attr->type)
- {
- case G_FILE_ATTRIBUTE_TYPE_STRING:
- str = g_strdup (attr->u.string);
- break;
- case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
- str = escape_byte_string (attr->u.string);
- break;
- case G_FILE_ATTRIBUTE_TYPE_BOOLEAN:
- str = g_strdup_printf ("%s", attr->u.boolean?"TRUE":"FALSE");
- break;
- case G_FILE_ATTRIBUTE_TYPE_UINT32:
- str = g_strdup_printf ("%u", (unsigned int)attr->u.uint32);
- break;
- case G_FILE_ATTRIBUTE_TYPE_INT32:
- str = g_strdup_printf ("%i", (int)attr->u.int32);
- break;
- case G_FILE_ATTRIBUTE_TYPE_UINT64:
- str = g_strdup_printf ("%"G_GUINT64_FORMAT, attr->u.uint64);
- break;
- case G_FILE_ATTRIBUTE_TYPE_INT64:
- str = g_strdup_printf ("%"G_GINT64_FORMAT, attr->u.int64);
- break;
- default:
- g_warning ("Invalid type in GFileInfo attribute");
- str = g_strdup ("<invalid>");
- break;
- }
-
- return str;
-}
-
-const char *
-g_file_attribute_value_get_string (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_STRING)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return NULL;
- }
- return attr->u.string;
-}
-
-const char *
-g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return NULL;
- }
- return attr->u.string;
-}
-
-gboolean
-g_file_attribute_value_get_boolean (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_BOOLEAN)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return FALSE;
- }
- return attr->u.boolean;
-}
-
-guint32
-g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_UINT32)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return 0;
- }
- return attr->u.uint32;
-}
-
-gint32
-g_file_attribute_value_get_int32 (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_INT32)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return 0;
- }
- return attr->u.int32;
-}
-
-guint64
-g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_UINT64)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return 0;
- }
- return attr->u.uint64;
-}
-
-gint64
-g_file_attribute_value_get_int64 (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_INT64)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return 0;
- }
- return attr->u.int64;
-}
-
-GObject *
-g_file_attribute_value_get_object (const GFileAttributeValue *attr)
-{
- if (attr == NULL || attr->type != G_FILE_ATTRIBUTE_TYPE_OBJECT)
- {
- if (attr != NULL)
- g_warning ("Invalid type in GFileInfo attribute");
- return NULL;
- }
- if (attr->u.obj)
- return g_object_ref (attr->u.obj);
- return NULL;
-}
-
-void
-g_file_attribute_value_set_string (GFileAttributeValue *attr,
- const char *string)
-{
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_STRING;
- attr->u.string = g_strdup (string);
-}
-
-
-void
-g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
- const char *string)
-{
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_BYTE_STRING;
- attr->u.string = g_strdup (string);
-}
-
-void
-g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
- gboolean value)
-{
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_BOOLEAN;
- attr->u.boolean = !!value;
-}
-
-void
-g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
- guint32 value)
-{
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_UINT32;
- attr->u.uint32 = value;
-}
-
-void
-g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
- gint32 value)
-{
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_INT32;
- attr->u.int32 = value;
-}
-
-void
-g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
- guint64 value)
-{
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_UINT64;
- attr->u.uint64 = value;
-}
-
-void
-g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
- gint64 value)
-{
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_INT64;
- attr->u.int64 = value;
-}
-
-void
-g_file_attribute_value_set_object (GFileAttributeValue *attr,
- GObject *obj)
- {
- g_file_attribute_value_clear (attr);
- attr->type = G_FILE_ATTRIBUTE_TYPE_OBJECT;
- if (obj)
- attr->u.obj = g_object_ref (obj);
- else
- attr->u.obj = NULL;
-}
-
-typedef struct {
- GFileAttributeInfoList public;
- GArray *array;
- int ref_count;
-} GFileAttributeInfoListPriv;
-
-static void
-list_update_public (GFileAttributeInfoListPriv *priv)
-{
- priv->public.infos = (GFileAttributeInfo *)priv->array->data;
- priv->public.n_infos = priv->array->len;
-}
-
-GFileAttributeInfoList *
-g_file_attribute_info_list_new (void)
-{
- GFileAttributeInfoListPriv *priv;
-
- priv = g_new0 (GFileAttributeInfoListPriv, 1);
-
- priv->ref_count = 1;
- priv->array = g_array_new (TRUE, FALSE, sizeof (GFileAttributeInfo));
-
- list_update_public (priv);
-
- return (GFileAttributeInfoList *)priv;
-}
-
-GFileAttributeInfoList *
-g_file_attribute_info_list_dup (GFileAttributeInfoList *list)
-{
- GFileAttributeInfoListPriv *new;
- int i;
-
- new = g_new0 (GFileAttributeInfoListPriv, 1);
- new->ref_count = 1;
- new->array = g_array_new (TRUE, FALSE, sizeof (GFileAttributeInfo));
-
- g_array_set_size (new->array, list->n_infos);
- list_update_public (new);
- for (i = 0; i < list->n_infos; i++)
- {
- new->public.infos[i].name = g_strdup (list->infos[i].name);
- new->public.infos[i].type = list->infos[i].type;
- new->public.infos[i].flags = list->infos[i].flags;
- }
-
- return (GFileAttributeInfoList *)new;
-}
-
-GFileAttributeInfoList *
-g_file_attribute_info_list_ref (GFileAttributeInfoList *list)
-{
- GFileAttributeInfoListPriv *priv = (GFileAttributeInfoListPriv *)list;
-
- priv->ref_count ++;
-
- return list;
-}
-
-void
-g_file_attribute_info_list_unref (GFileAttributeInfoList *list)
-{
- GFileAttributeInfoListPriv *priv = (GFileAttributeInfoListPriv *)list;
- int i;
-
- if (list)
- {
- priv->ref_count --;
-
- if (priv->ref_count == 0)
- {
- for (i = 0; i < list->n_infos; i++)
- g_free (list->infos[i].name);
- g_array_free (priv->array, TRUE);
- }
- }
-}
-
-static int
-g_file_attribute_info_list_bsearch (GFileAttributeInfoList *list,
- const char *name)
-{
- int start, end, mid;
-
- start = 0;
- end = list->n_infos;
-
- while (start != end)
- {
- mid = start + (end - start) / 2;
-
- if (strcmp (name, list->infos[mid].name) < 0)
- end = mid;
- else if (strcmp (name, list->infos[mid].name) > 0)
- start = mid + 1;
- else
- return mid;
- }
- return start;
-}
-
-const GFileAttributeInfo *
-g_file_attribute_info_list_lookup (GFileAttributeInfoList *list,
- const char *name)
-{
- int i;
-
- if (list == NULL)
- return NULL;
-
- i = g_file_attribute_info_list_bsearch (list, name);
-
- if (i < list->n_infos && strcmp (list->infos[i].name, name) == 0)
- return &list->infos[i];
-
- return NULL;
-}
-
-void
-g_file_attribute_info_list_add (GFileAttributeInfoList *list,
- const char *name,
- GFileAttributeType type,
- GFileAttributeFlags flags)
-{
- GFileAttributeInfoListPriv *priv = (GFileAttributeInfoListPriv *)list;
- GFileAttributeInfo info;
- int i;
-
- i = g_file_attribute_info_list_bsearch (list, name);
-
- if (i < list->n_infos && strcmp (list->infos[i].name, name) == 0)
- {
- list->infos[i].type = type;
- return;
- }
-
- info.name = g_strdup (name);
- info.type = type;
- info.flags = flags;
- g_array_insert_vals (priv->array, i, &info, 1);
-
- list_update_public (priv);
-}
diff --git a/gio/gfileattribute.h b/gio/gfileattribute.h
deleted file mode 100644
index 7467a80d..00000000
--- a/gio/gfileattribute.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#ifndef __G_FILE_ATTRIBUTE_H__
-#define __G_FILE_ATTRIBUTE_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- G_FILE_ATTRIBUTE_TYPE_INVALID = 0,
- G_FILE_ATTRIBUTE_TYPE_STRING,
- G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, /* zero terminated string of non-zero bytes */
- G_FILE_ATTRIBUTE_TYPE_BOOLEAN,
- G_FILE_ATTRIBUTE_TYPE_UINT32,
- G_FILE_ATTRIBUTE_TYPE_INT32,
- G_FILE_ATTRIBUTE_TYPE_UINT64,
- G_FILE_ATTRIBUTE_TYPE_INT64,
- G_FILE_ATTRIBUTE_TYPE_OBJECT
-} GFileAttributeType;
-
-typedef enum {
- G_FILE_ATTRIBUTE_FLAGS_NONE = 0,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE = 1 << 0,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED = 1 << 1,
-} GFileAttributeFlags;
-
-/* Used by g_file_set_attributes_from_info */
-typedef enum {
- G_FILE_ATTRIBUTE_STATUS_UNSET = 0,
- G_FILE_ATTRIBUTE_STATUS_SET,
- G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING,
-} GFileAttributeStatus;
-
-#define G_FILE_ATTRIBUTE_VALUE_INIT {0}
-
-typedef struct {
- GFileAttributeType type : 8;
- GFileAttributeStatus status : 8;
- union {
- gboolean boolean;
- gint32 int32;
- guint32 uint32;
- gint64 int64;
- guint64 uint64;
- char *string;
- GQuark quark;
- GObject *obj;
- } u;
-} GFileAttributeValue;
-
-typedef struct {
- char *name;
- GFileAttributeType type;
- GFileAttributeFlags flags;
-} GFileAttributeInfo;
-
-typedef struct {
- GFileAttributeInfo *infos;
- int n_infos;
-} GFileAttributeInfoList;
-
-GFileAttributeValue *g_file_attribute_value_new (void);
-void g_file_attribute_value_free (GFileAttributeValue *attr);
-void g_file_attribute_value_clear (GFileAttributeValue *attr);
-void g_file_attribute_value_set (GFileAttributeValue *attr,
- const GFileAttributeValue *new_value);
-GFileAttributeValue *g_file_attribute_value_dup (const GFileAttributeValue *attr);
-
-char * g_file_attribute_value_as_string (const GFileAttributeValue *attr);
-
-const char * g_file_attribute_value_get_string (const GFileAttributeValue *attr);
-const char * g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr);
-gboolean g_file_attribute_value_get_boolean (const GFileAttributeValue *attr);
-guint32 g_file_attribute_value_get_uint32 (const GFileAttributeValue *attr);
-gint32 g_file_attribute_value_get_int32 (const GFileAttributeValue *attr);
-guint64 g_file_attribute_value_get_uint64 (const GFileAttributeValue *attr);
-gint64 g_file_attribute_value_get_int64 (const GFileAttributeValue *attr);
-GObject * g_file_attribute_value_get_object (const GFileAttributeValue *attr);
-
-void g_file_attribute_value_set_string (GFileAttributeValue *attr,
- const char *value);
-void g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
- const char *value);
-void g_file_attribute_value_set_boolean (GFileAttributeValue *attr,
- gboolean value);
-void g_file_attribute_value_set_uint32 (GFileAttributeValue *attr,
- guint32 value);
-void g_file_attribute_value_set_int32 (GFileAttributeValue *attr,
- gint32 value);
-void g_file_attribute_value_set_uint64 (GFileAttributeValue *attr,
- guint64 value);
-void g_file_attribute_value_set_int64 (GFileAttributeValue *attr,
- gint64 value);
-void g_file_attribute_value_set_object (GFileAttributeValue *attr,
- GObject *obj);
-
-GFileAttributeInfoList * g_file_attribute_info_list_new (void);
-GFileAttributeInfoList * g_file_attribute_info_list_ref (GFileAttributeInfoList *list);
-void g_file_attribute_info_list_unref (GFileAttributeInfoList *list);
-GFileAttributeInfoList * g_file_attribute_info_list_dup (GFileAttributeInfoList *list);
-const GFileAttributeInfo *g_file_attribute_info_list_lookup (GFileAttributeInfoList *list,
- const char *name);
-void g_file_attribute_info_list_add (GFileAttributeInfoList *list,
- const char *name,
- GFileAttributeType type,
- GFileAttributeFlags flags);
-
-G_END_DECLS
-
-
-#endif /* __G_FILE_INFO_H__ */
diff --git a/gio/gfileenumerator.c b/gio/gfileenumerator.c
deleted file mode 100644
index fb8f64c1..00000000
--- a/gio/gfileenumerator.c
+++ /dev/null
@@ -1,596 +0,0 @@
-#include <config.h>
-#include "gfileenumerator.h"
-#include <glib/gi18n-lib.h>
-#include "gioscheduler.h"
-#include "gasynchelper.h"
-
-G_DEFINE_TYPE (GFileEnumerator, g_file_enumerator, G_TYPE_OBJECT);
-
-struct _GFileEnumeratorPrivate {
- /* TODO: Should be public for subclasses? */
- guint stopped : 1;
- guint pending : 1;
- gpointer outstanding_callback;
- GError *outstanding_error;
-};
-
-static void g_file_enumerator_real_next_files_async (GFileEnumerator *enumerator,
- int num_files,
- int io_priority,
- GAsyncNextFilesCallback callback,
- gpointer data,
- GCancellable *cancellable);
-static void g_file_enumerator_real_stop_async (GFileEnumerator *enumerator,
- int io_priority,
- GAsyncStopEnumeratingCallback callback,
- gpointer data,
- GCancellable *cancellable);
-
-static void
-g_file_enumerator_finalize (GObject *object)
-{
- GFileEnumerator *enumerator;
-
- enumerator = G_FILE_ENUMERATOR (object);
-
- if (!enumerator->priv->stopped)
- g_file_enumerator_stop (enumerator, NULL, NULL);
-
- if (G_OBJECT_CLASS (g_file_enumerator_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_file_enumerator_parent_class)->finalize) (object);
-}
-
-static void
-g_file_enumerator_class_init (GFileEnumeratorClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GFileEnumeratorPrivate));
-
- gobject_class->finalize = g_file_enumerator_finalize;
-
- klass->next_files_async = g_file_enumerator_real_next_files_async;
- klass->stop_async = g_file_enumerator_real_stop_async;
-}
-
-static void
-g_file_enumerator_init (GFileEnumerator *enumerator)
-{
- enumerator->priv = G_TYPE_INSTANCE_GET_PRIVATE (enumerator,
- G_TYPE_FILE_ENUMERATOR,
- GFileEnumeratorPrivate);
-}
-
-/**
- * g_file_enumerator_next_file:
- * @enumerator: a #GFileEnumerator.
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Returns information for the next file in the enumerated object.
- * Will block until the information is availible.
- *
- * On error, returns %NULL and sets @error to the error. If the
- * enumerator is at the end, %NULL will be returned and @error will
- * be unset.
- *
- * Return value: A GFileInfo or %NULL on error or end of enumerator
- **/
-GFileInfo *
-g_file_enumerator_next_file (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error)
-{
- GFileEnumeratorClass *class;
- GFileInfo *info;
-
- g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), NULL);
- g_return_val_if_fail (enumerator != NULL, NULL);
-
- if (enumerator->priv->stopped)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Enumerator is stopped"));
- return NULL;
- }
-
- if (enumerator->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("File enumerator has outstanding operation"));
- return NULL;
- }
-
- if (enumerator->priv->outstanding_error)
- {
- g_propagate_error (error, enumerator->priv->outstanding_error);
- enumerator->priv->outstanding_error = NULL;
- return NULL;
- }
-
- class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- enumerator->priv->pending = TRUE;
- info = (* class->next_file) (enumerator, cancellable, error);
- enumerator->priv->pending = FALSE;
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- return info;
-}
-
-/**
- * g_file_enumerator_stop:
- * @enumerator: a #GFileEnumerator.
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Releases all resources used by this enumerator, making the
- * enumerator return %G_IO_ERROR_CLOSED on all calls.
- *
- * This will be automatically called when the last reference
- * is dropped, but you might want to call make sure resources
- * are released as early as possible.
- **/
-gboolean
-g_file_enumerator_stop (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error)
-{
- GFileEnumeratorClass *class;
-
- g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), FALSE);
- g_return_val_if_fail (enumerator != NULL, FALSE);
-
- class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
-
- if (enumerator->priv->stopped)
- return TRUE;
-
- if (enumerator->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("File enumerator has outstanding operation"));
- return FALSE;
- }
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- enumerator->priv->pending = TRUE;
- (* class->stop) (enumerator, cancellable, error);
- enumerator->priv->pending = FALSE;
- enumerator->priv->stopped = TRUE;
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- return TRUE;
-}
-
-typedef struct {
- GAsyncResultData generic;
- int num_files;
- GAsyncNextFilesCallback callback;
-} NextAsyncResult;
-
-static gboolean
-call_next_async_result (gpointer data)
-{
- NextAsyncResult *res = data;
-
- if (res->callback)
- res->callback (res->generic.async_object,
- NULL,
- res->num_files,
- res->generic.user_data,
- res->generic.error);
-
- return FALSE;
-}
-
-static void
-queue_next_async_result (GFileEnumerator *enumerator,
- int num_files,
- GError *error,
- GAsyncNextFilesCallback callback,
- gpointer data)
-{
- NextAsyncResult *res;
-
- res = g_new0 (NextAsyncResult, 1);
-
- res->num_files = num_files;
- res->callback = callback;
-
- _g_queue_async_result ((GAsyncResultData *)res, enumerator,
- error, data,
- call_next_async_result);
-}
-
-static void
-next_async_callback_wrapper (GFileEnumerator *enumerator,
- GList *files,
- int num_files,
- gpointer data,
- GError *error)
-{
- GAsyncNextFilesCallback real_callback = enumerator->priv->outstanding_callback;
-
- enumerator->priv->pending = FALSE;
- (*real_callback) (enumerator, files, num_files, data, error);
- g_object_unref (enumerator);
-}
-
-/**
- * g_file_enumerator_next_files_async:
- * @enumerator: a #GFileEnumerator.
- * @num_file: the number of file info objects to request
- * @io_priority: the io priority of the request
- * @callback: callback to call when the request is satisfied
- * @user_data: the user_data to pass to callback function
- * @cancellable: optional cancellable object
- *
- * Request information for a number of files from the enumerator asynchronously.
- * When all i/o for the operation is finished the @callback will be called with
- * the requested information.
- *
- * The callback can be called with less than @num_files files in case of error
- * or at the end of the enumerator. In case of a partial error the callback will
- * be called with any succeeding items and no error, and on the next request the
- * error will be reported. If a request is cancelled the callback will be called
- * with %G_IO_ERROR_CANCELLED.
- *
- * During an async request no other sync and async calls are allowed, and will
- * result in %G_IO_ERROR_PENDING errors.
- *
- * Any outstanding i/o request with higher priority (lower numerical value) will
- * be executed before an outstanding request with lower priority. Default
- * priority is %G_PRIORITY_DEFAULT.
- **/
-void
-g_file_enumerator_next_files_async (GFileEnumerator *enumerator,
- int num_files,
- int io_priority,
- GAsyncNextFilesCallback callback,
- gpointer user_data,
- GCancellable *cancellable)
-{
- GFileEnumeratorClass *class;
- GError *error;
-
- g_return_if_fail (G_IS_FILE_ENUMERATOR (enumerator));
- g_return_if_fail (enumerator != NULL);
- g_return_if_fail (num_files >= 0);
-
- if (num_files == 0)
- {
- queue_next_async_result (enumerator, 0, NULL, callback, user_data);
- return;
- }
-
- if (enumerator->priv->stopped)
- {
- error = NULL;
- g_set_error (&error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("File enumerator is already closed"));
- queue_next_async_result (enumerator, -1, error,
- callback, user_data);
- return;
- }
-
- if (enumerator->priv->pending)
- {
- error = NULL;
- g_set_error (&error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("File enumerator has outstanding operation"));
- queue_next_async_result (enumerator, -1, error,
- callback, user_data);
- return;
- }
-
- class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
-
- enumerator->priv->pending = TRUE;
- enumerator->priv->outstanding_callback = callback;
- g_object_ref (enumerator);
- (* class->next_files_async) (enumerator, num_files, io_priority,
- next_async_callback_wrapper, user_data, cancellable);
-}
-
-
-typedef struct {
- GAsyncResultData generic;
- gboolean result;
- GAsyncStopEnumeratingCallback callback;
-} StopAsyncResult;
-
-static gboolean
-call_stop_async_result (gpointer data)
-{
- StopAsyncResult *res = data;
-
- if (res->callback)
- res->callback (res->generic.async_object,
- res->result,
- res->generic.user_data,
- res->generic.error);
-
- return FALSE;
-}
-
-static void
-queue_stop_async_result (GFileEnumerator *enumerator,
- gboolean result,
- GError *error,
- GAsyncStopEnumeratingCallback callback,
- gpointer data)
-{
- StopAsyncResult *res;
-
- res = g_new0 (StopAsyncResult, 1);
-
- res->result = result;
- res->callback = callback;
-
- _g_queue_async_result ((GAsyncResultData *)res, enumerator,
- error, data,
- call_stop_async_result);
-}
-
-static void
-stop_async_callback_wrapper (GFileEnumerator *enumerator,
- gboolean result,
- gpointer data,
- GError *error)
-{
- GAsyncStopEnumeratingCallback real_callback = enumerator->priv->outstanding_callback;
-
- enumerator->priv->pending = FALSE;
- enumerator->priv->stopped = TRUE;
- (*real_callback) (enumerator, result, data, error);
- g_object_unref (enumerator);
-}
-
-void
-g_file_enumerator_stop_async (GFileEnumerator *enumerator,
- int io_priority,
- GAsyncStopEnumeratingCallback callback,
- gpointer user_data,
- GCancellable *cancellable)
-{
- GFileEnumeratorClass *class;
- GError *error;
-
- g_return_if_fail (G_IS_FILE_ENUMERATOR (enumerator));
-
- if (enumerator->priv->stopped)
- {
- error = NULL;
- g_set_error (&error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("File enumerator is already stopped"));
- queue_stop_async_result (enumerator, FALSE, error,
- callback, user_data);
- return;
- }
-
- if (enumerator->priv->pending)
- {
- error = NULL;
- g_set_error (&error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("File enumerator has outstanding operation"));
- queue_stop_async_result (enumerator, FALSE, error,
- callback, user_data);
- return;
- }
-
- class = G_FILE_ENUMERATOR_GET_CLASS (enumerator);
-
- enumerator->priv->pending = TRUE;
- enumerator->priv->outstanding_callback = callback;
- g_object_ref (enumerator);
- (* class->stop_async) (enumerator, io_priority,
- stop_async_callback_wrapper, user_data, cancellable);
-}
-
-gboolean
-g_file_enumerator_is_stopped (GFileEnumerator *enumerator)
-{
- g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), TRUE);
- g_return_val_if_fail (enumerator != NULL, TRUE);
-
- return enumerator->priv->stopped;
-}
-
-gboolean
-g_file_enumerator_has_pending (GFileEnumerator *enumerator)
-{
- g_return_val_if_fail (G_IS_FILE_ENUMERATOR (enumerator), TRUE);
- g_return_val_if_fail (enumerator != NULL, TRUE);
-
- return enumerator->priv->pending;
-}
-
-void
-g_file_enumerator_set_pending (GFileEnumerator *enumerator,
- gboolean pending)
-{
- g_return_if_fail (G_IS_FILE_ENUMERATOR (enumerator));
- g_return_if_fail (enumerator != NULL);
-
- enumerator->priv->pending = pending;
-}
-
-typedef struct {
- GFileEnumerator *enumerator;
- GError *error;
- gpointer data;
-} FileEnumeratorOp;
-
-static void
-file_enumerator_op_free (gpointer data)
-{
- FileEnumeratorOp *op = data;
-
- if (op->error)
- g_error_free (op->error);
-
- g_free (op);
-}
-
-typedef struct {
- FileEnumeratorOp op;
- int num_files;
- GList *files;
- GAsyncNextFilesCallback callback;
-} NextAsyncOp;
-
-static void
-next_op_report (gpointer data)
-{
- NextAsyncOp *op = data;
-
- op->callback (op->op.enumerator,
- op->files,
- op->num_files,
- op->op.data,
- op->op.error);
-
- g_list_foreach (op->files, (GFunc)g_object_unref, NULL);
- g_list_free (op->files);
- op->files = NULL;
-}
-
-static void
-next_op_func (GIOJob *job,
- GCancellable *cancellable,
- gpointer data)
-{
- NextAsyncOp *op = data;
- GFileEnumeratorClass *class;
- GFileInfo *info;
- int i;
-
- class = G_FILE_ENUMERATOR_GET_CLASS (op->op.enumerator);
-
- for (i = 0; i < op->num_files; i++)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, &op->op.error))
- info = NULL;
- else
- info = class->next_file (op->op.enumerator, cancellable, &op->op.error);
-
- if (info == NULL)
- {
- /* If we get an error after first file, return that on next operation */
- if (op->op.error != NULL && i > 0)
- {
- op->op.enumerator->priv->outstanding_error = op->op.error;
- op->op.error = NULL;
- }
-
- break;
- }
- else
- op->files = g_list_prepend (op->files, info);
-
- }
-
- if (op->op.error != NULL)
- op->num_files = -1;
- else
- op->num_files = i;
-
- g_io_job_send_to_mainloop (job, next_op_report,
- op, file_enumerator_op_free,
- FALSE);
-}
-
-static void
-g_file_enumerator_real_next_files_async (GFileEnumerator *enumerator,
- int num_files,
- int io_priority,
- GAsyncNextFilesCallback callback,
- gpointer user_data,
- GCancellable *cancellable)
-{
- NextAsyncOp *op;
-
- op = g_new0 (NextAsyncOp, 1);
-
- op->op.enumerator = enumerator;
- op->num_files = num_files;
- op->files = NULL;
- op->callback = callback;
- op->op.data = user_data;
-
- g_schedule_io_job (next_op_func,
- op,
- NULL,
- io_priority,
- cancellable);
-}
-
-typedef struct {
- FileEnumeratorOp op;
- gboolean result;
- GAsyncStopEnumeratingCallback callback;
-} StopAsyncOp;
-
-static void
-stop_op_report (gpointer data)
-{
- StopAsyncOp *op = data;
-
- op->callback (op->op.enumerator,
- op->result,
- op->op.data,
- op->op.error);
-}
-
-static void
-stop_op_func (GIOJob *job,
- GCancellable *cancellable,
- gpointer data)
-{
- StopAsyncOp *op = data;
- GFileEnumeratorClass *class;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, &op->op.error))
- op->result = FALSE;
- else
- {
- class = G_FILE_ENUMERATOR_GET_CLASS (op->op.enumerator);
- op->result = class->stop (op->op.enumerator, cancellable, &op->op.error);
- }
-
- g_io_job_send_to_mainloop (job, stop_op_report,
- op, file_enumerator_op_free,
- FALSE);
-}
-
-static void
-g_file_enumerator_real_stop_async (GFileEnumerator *enumerator,
- int io_priority,
- GAsyncStopEnumeratingCallback callback,
- gpointer user_data,
- GCancellable *cancellable)
-{
- StopAsyncOp *op;
-
- op = g_new0 (StopAsyncOp, 1);
-
- op->op.enumerator = enumerator;
- op->callback = callback;
- op->op.data = user_data;
-
- g_schedule_io_job (stop_op_func,
- op,
- NULL,
- io_priority,
- cancellable);
-}
diff --git a/gio/gfileenumerator.h b/gio/gfileenumerator.h
deleted file mode 100644
index 87b99b39..00000000
--- a/gio/gfileenumerator.h
+++ /dev/null
@@ -1,113 +0,0 @@
-#ifndef __G_FILE_ENUMERATOR_H__
-#define __G_FILE_ENUMERATOR_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gioerror.h>
-#include <gio/gcancellable.h>
-#include <gio/gfileinfo.h>
-
-G_BEGIN_DECLS
-
-
-#define G_TYPE_FILE_ENUMERATOR (g_file_enumerator_get_type ())
-#define G_FILE_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_ENUMERATOR, GFileEnumerator))
-#define G_FILE_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_ENUMERATOR, GFileEnumeratorClass))
-#define G_IS_FILE_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_ENUMERATOR))
-#define G_IS_FILE_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_ENUMERATOR))
-#define G_FILE_ENUMERATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_ENUMERATOR, GFileEnumeratorClass))
-
-
-typedef struct _GFileEnumerator GFileEnumerator;
-typedef struct _GFileEnumeratorClass GFileEnumeratorClass;
-typedef struct _GFileEnumeratorPrivate GFileEnumeratorPrivate;
-
-/**
- * GAsyncNextFilesCallback:
- * @enumerator: a #GFileEnumerator
- * @files: list of #GFileInfo objects
- * @num_files: size of @files list, or -1 on error
- * @user_data: the @user_data pointer passed to the async call
- * @error: the error, if num_files is -1, otherwise %NULL
- *
- * This callback is called when an asychronous next_file operation
- * is finished. When there are no more files to enumerate @num_files
- * is set to 0.
- *
- * The callback is always called, even if the operation was cancelled.
- * If the operation was cancelled @result will be %FALSE, and @error
- * will be %G_IO_ERROR_CANCELLED.
- **/
-typedef void (*GAsyncNextFilesCallback) (GFileEnumerator *enumerator,
- GList *files,
- int num_files,
- gpointer user_data,
- GError *error);
-
-typedef void (*GAsyncStopEnumeratingCallback) (GFileEnumerator *enumerator,
- gboolean result,
- gpointer user_data,
- GError *error);
-
-
-struct _GFileEnumerator
-{
- GObject parent;
-
- /*< private >*/
- GFileEnumeratorPrivate *priv;
-};
-
-struct _GFileEnumeratorClass
-{
- GObjectClass parent_class;
-
- /* Virtual Table */
-
- GFileInfo *(*next_file) (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error);
- gboolean (*stop) (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error);
-
- void (*next_files_async) (GFileEnumerator *enumerator,
- int num_files,
- int io_priority,
- GAsyncNextFilesCallback callback,
- gpointer user_data,
- GCancellable *cancellable);
- void (*stop_async) (GFileEnumerator *enumerator,
- int io_priority,
- GAsyncStopEnumeratingCallback callback,
- gpointer user_data,
- GCancellable *cancellable);
-};
-
-GType g_file_enumerator_get_type (void) G_GNUC_CONST;
-
-GFileInfo * g_file_enumerator_next_file (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_enumerator_stop (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error);
-void g_file_enumerator_next_files_async (GFileEnumerator *enumerator,
- int num_files,
- int io_priority,
- GAsyncNextFilesCallback callback,
- gpointer user_data,
- GCancellable *cancellable);
-void g_file_enumerator_stop_async (GFileEnumerator *enumerator,
- int io_priority,
- GAsyncStopEnumeratingCallback callback,
- gpointer user_data,
- GCancellable *cancellable);
-gboolean g_file_enumerator_is_stopped (GFileEnumerator *enumerator);
-gboolean g_file_enumerator_has_pending (GFileEnumerator *enumerator);
-void g_file_enumerator_set_pending (GFileEnumerator *enumerator,
- gboolean pending);
-
-G_END_DECLS
-
-#endif /* __G_FILE_ENUMERATOR_H__ */
diff --git a/gio/gfileicon.c b/gio/gfileicon.c
deleted file mode 100644
index 3fbb27aa..00000000
--- a/gio/gfileicon.c
+++ /dev/null
@@ -1,214 +0,0 @@
-#include <config.h>
-
-#include "gfileicon.h"
-#include "gsimpleasyncresult.h"
-
-static void g_file_icon_icon_iface_init (GIconIface *iface);
-static void g_file_icon_loadable_icon_iface_init (GLoadableIconIface *iface);
-static void g_file_icon_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-struct _GFileIcon
-{
- GObject parent_instance;
-
- GFile *file;
-};
-
-G_DEFINE_TYPE_WITH_CODE (GFileIcon, g_file_icon, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
- g_file_icon_icon_iface_init);
- G_IMPLEMENT_INTERFACE (G_TYPE_LOADABLE_ICON,
- g_file_icon_loadable_icon_iface_init);
- )
-
-static void
-g_file_icon_finalize (GObject *object)
-{
- GFileIcon *icon;
-
- icon = G_FILE_ICON (object);
-
- g_object_unref (icon->file);
-
- if (G_OBJECT_CLASS (g_file_icon_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_file_icon_parent_class)->finalize) (object);
-}
-
-static void
-g_file_icon_class_init (GFileIconClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_file_icon_finalize;
-}
-
-static void
-g_file_icon_init (GFileIcon *file)
-{
-}
-
-GIcon *
-g_file_icon_new (GFile *file)
-{
- GFileIcon *icon;
-
- icon = g_object_new (G_TYPE_FILE_ICON, NULL);
- icon->file = g_object_ref (file);
-
- return G_ICON (icon);
-}
-
-GFile *
-g_file_icon_get_file (GFileIcon *icon)
-{
- return g_object_ref (icon->file);
-}
-
-static guint
-g_file_icon_hash (GIcon *icon)
-{
- GFileIcon *file_icon = G_FILE_ICON (icon);
-
- return g_file_hash (file_icon->file);
-}
-
-static gboolean
-g_file_icon_equal (GIcon *icon1,
- GIcon *icon2)
-{
- GFileIcon *file1 = G_FILE_ICON (icon1);
- GFileIcon *file2 = G_FILE_ICON (icon2);
-
- return g_file_equal (file1->file, file2->file);
-}
-
-
-static void
-g_file_icon_icon_iface_init (GIconIface *iface)
-{
- iface->hash = g_file_icon_hash;
- iface->equal = g_file_icon_equal;
-}
-
-
-static GInputStream *
-g_file_icon_load (GLoadableIcon *icon,
- int size,
- char **type,
- GCancellable *cancellable,
- GError **error)
-{
- GFileInputStream *stream;
- GFileIcon *file_icon = G_FILE_ICON (icon);
-
- stream = g_file_read (file_icon->file,
- cancellable,
- error);
-
- return G_INPUT_STREAM (stream);
-}
-
-typedef struct {
- GLoadableIcon *icon;
- GAsyncReadyCallback callback;
- gpointer user_data;
-} LoadData;
-
-static void
-load_data_free (LoadData *data)
-{
- g_object_unref (data->icon);
- g_free (data);
-}
-
-static void
-load_async_callback (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GFileInputStream *stream;
- GError *error = NULL;
- GSimpleAsyncResult *simple;
- LoadData *data = user_data;
-
- stream = g_file_read_finish (G_FILE (source_object), res, &error);
-
- if (stream == NULL)
- {
- simple = g_simple_async_result_new_from_error (G_OBJECT (data->icon),
- data->callback,
- data->user_data,
- error);
- g_error_free (error);
- }
- else
- {
- simple = g_simple_async_result_new (G_OBJECT (data->icon),
- data->callback,
- data->user_data,
- g_file_icon_load_async);
-
- g_simple_async_result_set_op_res_gpointer (simple,
- stream,
- g_object_unref);
- }
-
-
- g_simple_async_result_complete (simple);
-
- load_data_free (data);
-}
-
-static void
-g_file_icon_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFileIcon *file_icon = G_FILE_ICON (icon);
- LoadData *data;
-
- data = g_new0 (LoadData, 1);
- data->icon = g_object_ref (icon);
- data->callback = callback;
- data->user_data = user_data;
-
- g_file_read_async (file_icon->file, 0,
- cancellable,
- load_async_callback, data);
-
-}
-
-static GInputStream *
-g_file_icon_load_finish (GLoadableIcon *icon,
- GAsyncResult *res,
- char **type,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- gpointer op;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_file_icon_load_async);
-
- if (type)
- *type = NULL;
-
- op = g_simple_async_result_get_op_res_gpointer (simple);
- if (op)
- return g_object_ref (op);
-
- return NULL;
-}
-
-static void
-g_file_icon_loadable_icon_iface_init (GLoadableIconIface *iface)
-{
- iface->load = g_file_icon_load;
- iface->load_async = g_file_icon_load_async;
- iface->load_finish = g_file_icon_load_finish;
-}
diff --git a/gio/gfileicon.h b/gio/gfileicon.h
deleted file mode 100644
index 16259f9d..00000000
--- a/gio/gfileicon.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __G_FILE_ICON_H__
-#define __G_FILE_ICON_H__
-
-#include <gio/gloadableicon.h>
-#include <gio/gfile.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILE_ICON (g_file_icon_get_type ())
-#define G_FILE_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_ICON, GFileIcon))
-#define G_FILE_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_ICON, GFileIconClass))
-#define G_IS_FILE_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_ICON))
-#define G_IS_FILE_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_ICON))
-#define G_FILE_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_ICON, GFileIconClass))
-
-typedef struct _GFileIcon GFileIcon;
-typedef struct _GFileIconClass GFileIconClass;
-
-struct _GFileIconClass
-{
- GObjectClass parent_class;
-};
-
-GType g_file_icon_get_type (void) G_GNUC_CONST;
-
-GIcon *g_file_icon_new (GFile *file);
-
-GFile *g_file_icon_get_file (GFileIcon *icon);
-
-G_END_DECLS
-
-#endif /* __G_FILE_ICON_H__ */
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
deleted file mode 100644
index 4cbfca61..00000000
--- a/gio/gfileinfo.c
+++ /dev/null
@@ -1,1307 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include "gfileinfo.h"
-#include <glib/gi18n-lib.h>
-
-/* We use this nasty thing, because NULL is a valid attribute matcher (matches nothing) */
-#define NO_ATTRIBUTE_MASK ((GFileAttributeMatcher *)1)
-
-typedef struct {
- guint32 attribute;
- GFileAttributeValue value;
-} GFileAttribute;
-
-struct _GFileInfo
-{
- GObject parent_instance;
-
- GArray *attributes;
- GFileAttributeMatcher *mask;
-};
-
-static gboolean g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher,
- guint32 id);
-
-G_DEFINE_TYPE (GFileInfo, g_file_info, G_TYPE_OBJECT);
-
-typedef struct {
- guint32 id;
- guint32 attribute_id_counter;
-} NSInfo;
-
-G_LOCK_DEFINE_STATIC (attribute_hash);
-static int namespace_id_counter = 0;
-static GHashTable *ns_hash = NULL;
-static GHashTable *attribute_hash = NULL;
-static char ***attributes = NULL;
-
-/* Attribute ids are 32bit, we split it up like this:
- * |------------|--------------------|
- * 12 bit 20 bit
- * namespace attribute id
- *
- * This way the attributes gets sorted in namespace order
- */
-
-#define NS_POS 20
-#define NS_MASK ((guint32)((1<<12) - 1))
-#define ID_POS 0
-#define ID_MASK ((guint32)((1<<20) - 1))
-
-#define GET_NS(_attr_id) \
- (((guint32) (_attr_id) >> NS_POS) & NS_MASK)
-#define GET_ID(_attr_id) \
- (((guint32)(_attr_id) >> ID_POS) & ID_MASK)
-
-#define MAKE_ATTR_ID(_ns, _id) \
- ( ((((guint32) _ns) & NS_MASK) << NS_POS) | \
- ((((guint32) _id) & ID_MASK) << ID_POS) )
-
-static NSInfo *
-_lookup_namespace (const char *namespace)
-{
- NSInfo *ns_info;
-
- ns_info = g_hash_table_lookup (ns_hash, namespace);
- if (ns_info == NULL)
- {
- ns_info = g_new0 (NSInfo, 1);
- ns_info->id = ++namespace_id_counter;
- g_hash_table_insert (ns_hash, g_strdup (namespace), ns_info);
- attributes = g_realloc (attributes, (ns_info->id + 1) * sizeof (char **));
- attributes[ns_info->id] = NULL;
- }
- return ns_info;
-}
-
-static guint32
-lookup_namespace (const char *namespace)
-{
- NSInfo *ns_info;
- guint32 id;
-
- G_LOCK (attribute_hash);
-
- if (attribute_hash == NULL)
- {
- ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
- attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- ns_info = _lookup_namespace (namespace);
- id = 0;
- if (ns_info)
- id = ns_info->id;
-
- G_UNLOCK (attribute_hash);
-
- return id;
-}
-
-static char *
-get_attribute_for_id (int attribute)
-{
- char *s;
- G_LOCK (attribute_hash);
- s = attributes[GET_NS(attribute)][GET_ID(attribute)];
- G_UNLOCK (attribute_hash);
- return s;
-}
-
-static guint32
-lookup_attribute (const char *attribute)
-{
- guint32 attr_id, id;
- char *ns;
- const char *colon;
- NSInfo *ns_info;
-
- G_LOCK (attribute_hash);
- if (attribute_hash == NULL)
- {
- ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
- attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- attr_id = GPOINTER_TO_UINT (g_hash_table_lookup (attribute_hash, attribute));
-
- if (attr_id != 0)
- {
- G_UNLOCK (attribute_hash);
- return attr_id;
- }
-
- colon = strchr (attribute, ':');
- if (colon)
- ns = g_strndup (attribute, colon - attribute);
- else
- ns = g_strdup ("");
-
- ns_info = _lookup_namespace (ns);
- g_free (ns);
-
- id = ++ns_info->attribute_id_counter;
- attributes[ns_info->id] = g_realloc (attributes[ns_info->id], (id + 1) * sizeof (char *));
- attributes[ns_info->id][id] = g_strdup (attribute);
-
- attr_id = MAKE_ATTR_ID (ns_info->id, id);
-
- g_hash_table_insert (attribute_hash, attributes[ns_info->id][id], GUINT_TO_POINTER (attr_id));
-
- G_UNLOCK (attribute_hash);
-
- return attr_id;
-}
-
-static void
-g_file_info_finalize (GObject *object)
-{
- GFileInfo *info;
- int i;
- GFileAttribute *attrs;
-
- info = G_FILE_INFO (object);
-
- attrs = (GFileAttribute *)info->attributes->data;
- for (i = 0; i < info->attributes->len; i++)
- g_file_attribute_value_clear (&attrs[i].value);
- g_array_free (info->attributes, TRUE);
-
- if (info->mask != NO_ATTRIBUTE_MASK)
- g_file_attribute_matcher_unref (info->mask);
-
- if (G_OBJECT_CLASS (g_file_info_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_file_info_parent_class)->finalize) (object);
-}
-
-static void
-g_file_info_class_init (GFileInfoClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_file_info_finalize;
-}
-
-static void
-g_file_info_init (GFileInfo *info)
-{
- info->mask = NO_ATTRIBUTE_MASK;
- info->attributes = g_array_new (FALSE, FALSE,
- sizeof (GFileAttribute));
-}
-
-GFileInfo *
-g_file_info_new (void)
-{
- return g_object_new (G_TYPE_FILE_INFO, NULL);
-}
-
-void
-g_file_info_copy_into (GFileInfo *src_info, GFileInfo *dest_info)
-{
- GFileAttribute *source, *dest;
- int i;
-
- dest = (GFileAttribute *)dest_info->attributes->data;
- for (i = 0; i < dest_info->attributes->len; i++)
- g_file_attribute_value_clear (&dest[i].value);
-
- g_array_set_size (dest_info->attributes,
- src_info->attributes->len);
-
- source = (GFileAttribute *)src_info->attributes->data;
- dest = (GFileAttribute *)dest_info->attributes->data;
-
- for (i = 0; i < src_info->attributes->len; i++)
- {
- dest[i].attribute = source[i].attribute;
- dest[i].value.type = G_FILE_ATTRIBUTE_TYPE_INVALID;
- g_file_attribute_value_set (&dest[i].value, &source[i].value);
- }
-
- if (src_info->mask == NO_ATTRIBUTE_MASK)
- dest_info->mask = NO_ATTRIBUTE_MASK;
- else
- dest_info->mask = g_file_attribute_matcher_ref (src_info->mask);
-}
-
-GFileInfo *
-g_file_info_dup (GFileInfo *other)
-{
- GFileInfo *new;
-
- new = g_file_info_new ();
- g_file_info_copy_into (other, new);
- return new;
-}
-
-void
-g_file_info_set_attribute_mask (GFileInfo *info,
- GFileAttributeMatcher *mask)
-{
- GFileAttribute *attr;
- int i;
-
- if (mask != info->mask)
- {
- if (info->mask != NO_ATTRIBUTE_MASK)
- g_file_attribute_matcher_unref (info->mask);
- info->mask = g_file_attribute_matcher_ref (mask);
-
- /* Remove non-matching attributes */
- for (i = 0; i < info->attributes->len; i++)
- {
- attr = &g_array_index (info->attributes, GFileAttribute, i);
- if (!g_file_attribute_matcher_matches_id (mask,
- attr->attribute))
- {
- g_file_attribute_value_clear (&attr->value);
- g_array_remove_index (info->attributes, i);
- i--;
- }
- }
- }
-}
-
-void
-g_file_info_unset_attribute_mask (GFileInfo *info)
-{
- if (info->mask != NO_ATTRIBUTE_MASK)
- g_file_attribute_matcher_unref (info->mask);
- info->mask = NO_ATTRIBUTE_MASK;
-}
-
-void
-g_file_info_clear_status (GFileInfo *info)
-{
- GFileAttribute *attrs;
- int i;
-
- attrs = (GFileAttribute *)info->attributes->data;
- for (i = 0; i < info->attributes->len; i++)
- attrs[i].value.status = G_FILE_ATTRIBUTE_STATUS_UNSET;
-}
-
-static int
-g_file_info_find_place (GFileInfo *info,
- guint32 attribute)
-{
- int min, max, med;
- GFileAttribute *attrs;
- /* Binary search for the place where attribute would be, if its
- in the array */
-
- min = 0;
- max = info->attributes->len;
-
- attrs = (GFileAttribute *)info->attributes->data;
-
- while (min < max)
- {
- med = min + (max - min) / 2;
- if (attrs[med].attribute == attribute)
- {
- min = med;
- break;
- }
- else if (attrs[med].attribute < attribute)
- min = med + 1;
- else /* attrs[med].attribute > attribute */
- max = med;
- }
-
- return min;
-}
-
-static GFileAttributeValue *
-g_file_info_find_value (GFileInfo *info,
- guint32 attr_id)
-{
- GFileAttribute *attrs;
- int i;
-
- i = g_file_info_find_place (info, attr_id);
- attrs = (GFileAttribute *)info->attributes->data;
- if (i < info->attributes->len &&
- attrs[i].attribute == attr_id)
- return &attrs[i].value;
-
- return NULL;
-}
-
-static GFileAttributeValue *
-g_file_info_find_value_by_name (GFileInfo *info,
- const char *attribute)
-{
- guint32 attr_id;
-
- attr_id = lookup_attribute (attribute);
- return g_file_info_find_value (info, attr_id);
-}
-
-
-gboolean
-g_file_info_has_attribute (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return value != NULL;
-}
-
-char **
-g_file_info_list_attributes (GFileInfo *info,
- const char *name_space)
-{
- GPtrArray *names;
- GFileAttribute *attrs;
- guint32 attribute;
- int i;
-
- names = g_ptr_array_new ();
- attrs = (GFileAttribute *)info->attributes->data;
- for (i = 0; i < info->attributes->len; i++)
- {
- attribute = attrs[i].attribute;
- g_ptr_array_add (names, g_strdup (get_attribute_for_id (attribute)));
- }
-
- /* NULL terminate */
- g_ptr_array_add (names, NULL);
-
- return (char **)g_ptr_array_free (names, FALSE);
-}
-
-
-GFileAttributeType
-g_file_info_get_attribute_type (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- if (value)
- return value->type;
- else
- return G_FILE_ATTRIBUTE_TYPE_INVALID;
-}
-
-void
-g_file_info_remove_attribute (GFileInfo *info,
- const char *attribute)
-{
- guint32 attr_id;
- GFileAttribute *attrs;
- int i;
-
- attr_id = lookup_attribute (attribute);
-
- i = g_file_info_find_place (info, attr_id);
- attrs = (GFileAttribute *)info->attributes->data;
- if (i < info->attributes->len &&
- attrs[i].attribute == attr_id)
- {
- g_file_attribute_value_clear (&attrs[i].value);
- g_array_remove_index (info->attributes, i);
- }
-}
-
-GFileAttributeValue *
-g_file_info_get_attribute (GFileInfo *info,
- const char *attribute)
-
-{
- return g_file_info_find_value_by_name (info, attribute);
-}
-
-GObject *
-g_file_info_get_attribute_object (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_object (value);
-}
-
-const char *
-g_file_info_get_attribute_string (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_string (value);
-}
-
-const char *
-g_file_info_get_attribute_byte_string (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_byte_string (value);
-}
-
-gboolean
-g_file_info_get_attribute_boolean (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_boolean (value);
-}
-
-guint32
-g_file_info_get_attribute_uint32 (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_uint32 (value);
-}
-
-gint32
-g_file_info_get_attribute_int32 (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_int32 (value);
-}
-
-guint64
-g_file_info_get_attribute_uint64 (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_uint64 (value);
-}
-
-gint64
-g_file_info_get_attribute_int64 (GFileInfo *info,
- const char *attribute)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_find_value_by_name (info, attribute);
- return g_file_attribute_value_get_int64 (value);
-}
-
-static GFileAttributeValue *
-g_file_info_create_value (GFileInfo *info,
- guint32 attr_id)
-{
- GFileAttribute *attrs;
- GFileAttribute attr;
- int i;
-
- if (info->mask != NO_ATTRIBUTE_MASK &&
- !g_file_attribute_matcher_matches_id (info->mask, attr_id))
- return NULL;
-
- i = g_file_info_find_place (info, attr_id);
-
- attrs = (GFileAttribute *)info->attributes->data;
- if (i < info->attributes->len &&
- attrs[i].attribute == attr_id)
- return &attrs[i].value;
- else
- {
- attr.attribute = attr_id;
- attr.value.type = G_FILE_ATTRIBUTE_TYPE_INVALID;
- g_array_insert_val (info->attributes, i, attr);
-
- attrs = (GFileAttribute *)info->attributes->data;
- return &attrs[i].value;
- }
-}
-
-static GFileAttributeValue *
-g_file_info_create_value_by_name (GFileInfo *info,
- const char *attribute)
-{
- guint32 attr_id;
-
- attr_id = lookup_attribute (attribute);
-
- return g_file_info_create_value (info, attr_id);
-}
-
-void
-g_file_info_set_attribute (GFileInfo *info,
- const char *attribute,
- const GFileAttributeValue *attr_value)
-{
- GFileAttributeValue *value;
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_object (GFileInfo *info,
- const char *attribute,
- GObject *attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_object (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_string (GFileInfo *info,
- const char *attribute,
- const char *attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_string (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_byte_string (GFileInfo *info,
- const char *attribute,
- const char *attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_byte_string (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_boolean (GFileInfo *info,
- const char *attribute,
- gboolean attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_boolean (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_uint32 (GFileInfo *info,
- const char *attribute,
- guint32 attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_uint32 (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_int32 (GFileInfo *info,
- const char *attribute,
- gint32 attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_int32 (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_uint64 (GFileInfo *info,
- const char *attribute,
- guint64 attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_uint64 (value, attr_value);
-}
-
-void
-g_file_info_set_attribute_int64 (GFileInfo *info,
- const char *attribute,
- gint64 attr_value)
-{
- GFileAttributeValue *value;
-
- value = g_file_info_create_value_by_name (info, attribute);
- if (value)
- g_file_attribute_value_set_int64 (value, attr_value);
-}
-
-/* Helper getters */
-GFileType
-g_file_info_get_file_type (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_TYPE);
-
- value = g_file_info_find_value (info, attr);
- return (GFileType)g_file_attribute_value_get_uint32 (value);
-}
-
-gboolean
-g_file_info_get_is_hidden (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_HIDDEN);
-
- value = g_file_info_find_value (info, attr);
- return (GFileType)g_file_attribute_value_get_boolean (value);
-}
-
-gboolean
-g_file_info_get_is_symlink (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_SYMLINK);
-
- value = g_file_info_find_value (info, attr);
- return (GFileType)g_file_attribute_value_get_boolean (value);
-}
-
-const char *
-g_file_info_get_name (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_NAME);
-
- value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_byte_string (value);
-}
-
-const char *
-g_file_info_get_display_name (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_DISPLAY_NAME);
-
- value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
-}
-
-const char *
-g_file_info_get_edit_name (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_EDIT_NAME);
-
- value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
-}
-
-GIcon *
-g_file_info_get_icon (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
- GObject *obj;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_ICON);
-
- value = g_file_info_find_value (info, attr);
- obj = g_file_attribute_value_get_object (value);
- if (G_IS_ICON (obj))
- return G_ICON (obj);
- return NULL;
-}
-
-const char *
-g_file_info_get_content_type (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_CONTENT_TYPE);
-
- value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
-}
-
-goffset
-g_file_info_get_size (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SIZE);
-
- value = g_file_info_find_value (info, attr);
- return (goffset) g_file_attribute_value_get_uint64 (value);
-}
-
-void
-g_file_info_get_modification_time (GFileInfo *info,
- GTimeVal *result)
-{
- static guint32 attr_mtime = 0, attr_mtime_usec;
- GFileAttributeValue *value;
-
- if (attr_mtime == 0)
- {
- attr_mtime = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED);
- attr_mtime_usec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
- }
-
- value = g_file_info_find_value (info, attr_mtime);
- result->tv_sec = g_file_attribute_value_get_uint64 (value);
- value = g_file_info_find_value (info, attr_mtime_usec);
- result->tv_usec = g_file_attribute_value_get_uint32 (value);
-}
-
-const char *
-g_file_info_get_symlink_target (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
-
- value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_byte_string (value);
-}
-
-const char *
-g_file_info_get_etag (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_ETAG_VALUE);
-
- value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_string (value);
-}
-
-gint32
-g_file_info_get_sort_order (GFileInfo *info)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SORT_ORDER);
-
- value = g_file_info_find_value (info, attr);
- return g_file_attribute_value_get_int32 (value);
-}
-
-/* Helper setters: */
-
-void
-g_file_info_set_file_type (GFileInfo *info,
- GFileType type)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_TYPE);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_uint32 (value, type);
-}
-
-
-void
-g_file_info_set_is_hidden (GFileInfo *info,
- gboolean is_hidden)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_HIDDEN);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_boolean (value, is_hidden);
-}
-
-void
-g_file_info_set_is_symlink (GFileInfo *info,
- gboolean is_symlink)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_IS_SYMLINK);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_boolean (value, is_symlink);
-}
-
-void
-g_file_info_set_name (GFileInfo *info,
- const char *name)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_NAME);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_byte_string (value, name);
-}
-
-void
-g_file_info_set_display_name (GFileInfo *info,
- const char *display_name)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_DISPLAY_NAME);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_string (value, display_name);
-}
-
-void
-g_file_info_set_edit_name (GFileInfo *info,
- const char *edit_name)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_EDIT_NAME);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_string (value, edit_name);
-}
-
-void
-g_file_info_set_icon (GFileInfo *info,
- GIcon *icon)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_ICON);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_object (value, G_OBJECT (icon));
-}
-
-void
-g_file_info_set_content_type (GFileInfo *info,
- const char *content_type)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_CONTENT_TYPE);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_string (value, content_type);
-}
-
-void
-g_file_info_set_size (GFileInfo *info,
- goffset size)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SIZE);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_uint64 (value, size);
-}
-
-void
-g_file_info_set_modification_time (GFileInfo *info,
- GTimeVal *mtime)
-{
- static guint32 attr_mtime = 0, attr_mtime_usec;
- GFileAttributeValue *value;
-
- if (attr_mtime == 0)
- {
- attr_mtime = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED);
- attr_mtime_usec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
- }
-
- value = g_file_info_create_value (info, attr_mtime);
- if (value)
- g_file_attribute_value_set_uint64 (value, mtime->tv_sec);
- value = g_file_info_create_value (info, attr_mtime_usec);
- if (value)
- g_file_attribute_value_set_uint32 (value, mtime->tv_usec);
-}
-
-void
-g_file_info_set_symlink_target (GFileInfo *info,
- const char *symlink_target)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_byte_string (value, symlink_target);
-}
-
-void
-g_file_info_set_sort_order (GFileInfo *info,
- gint32 sort_order)
-{
- static guint32 attr = 0;
- GFileAttributeValue *value;
-
- if (attr == 0)
- attr = lookup_attribute (G_FILE_ATTRIBUTE_STD_SORT_ORDER);
-
- value = g_file_info_create_value (info, attr);
- if (value)
- g_file_attribute_value_set_int32 (value, sort_order);
-}
-
-#define ON_STACK_MATCHERS 5
-
-typedef struct {
- guint32 id;
- guint32 mask;
-} SubMatcher;
-
-struct _GFileAttributeMatcher {
- gboolean all;
- SubMatcher sub_matchers[ON_STACK_MATCHERS];
- GArray *more_sub_matchers;
-
- /* Interator */
- guint32 iterator_ns;
- int iterator_pos;
- int ref;
-};
-
-static void
-matcher_add (GFileAttributeMatcher *matcher,
- guint id, guint mask)
-{
- SubMatcher *sub_matchers;
- int i;
- SubMatcher s;
-
- for (i = 0; i < ON_STACK_MATCHERS; i++)
- {
- /* First empty spot, not found, use this */
- if (matcher->sub_matchers[i].id == 0)
- {
- matcher->sub_matchers[i].id = id;
- matcher->sub_matchers[i].mask = mask;
- return;
- }
-
- /* Already added */
- if (matcher->sub_matchers[i].id == id &&
- matcher->sub_matchers[i].mask == mask)
- return;
- }
-
- if (matcher->more_sub_matchers == NULL)
- matcher->more_sub_matchers = g_array_new (FALSE, FALSE, sizeof (SubMatcher));
-
- sub_matchers = (SubMatcher *)matcher->more_sub_matchers->data;
- for (i = 0; i < matcher->more_sub_matchers->len; i++)
- {
- /* Already added */
- if (sub_matchers[i].id == id &&
- sub_matchers[i].mask == mask)
- return;
- }
-
- s.id = id;
- s.mask = mask;
-
- g_array_append_val (matcher->more_sub_matchers, s);
-}
-
-
-GFileAttributeMatcher *
-g_file_attribute_matcher_new (const char *attributes)
-{
- char **split;
- char *colon;
- int i;
- GFileAttributeMatcher *matcher;
-
- if (attributes == NULL || *attributes == 0)
- return NULL;
-
- matcher = g_malloc0 (sizeof (GFileAttributeMatcher));
- matcher->ref = 1;
-
- split = g_strsplit (attributes, ",", -1);
-
- for (i = 0; split[i] != NULL; i++)
- {
- if (strcmp (split[i], "*") == 0)
- matcher->all = TRUE;
- else
- {
- guint32 id, mask;
-
- colon = strchr (split[i], ':');
- if (colon != NULL &&
- !(colon[1] == 0 ||
- (colon[1] == '*' &&
- colon[2] == 0)))
- {
- id = lookup_attribute (split[i]);
- mask = 0xffffffff;
- }
- else
- {
- if (colon)
- *colon = 0;
-
- id = lookup_namespace (split[i]) << NS_POS;
- mask = NS_MASK << NS_POS;
- }
-
- matcher_add (matcher, id, mask);
- }
- }
-
- g_strfreev (split);
-
- return matcher;
-}
-
-GFileAttributeMatcher *
-g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher)
-{
- if (matcher)
- matcher->ref++;
-
- return matcher;
-}
-
-void
-g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher)
-{
- if (matcher == NULL)
- return;
-
- matcher->ref--;
-
- if (matcher->ref == 0)
- {
- if (matcher->more_sub_matchers)
- g_array_free (matcher->more_sub_matchers, TRUE);
-
- g_free (matcher);
- }
-}
-
-gboolean
-g_file_attribute_matcher_matches_only (GFileAttributeMatcher *matcher,
- const char *attribute)
-{
- guint32 id;
-
- if (matcher == NULL)
- return FALSE;
-
- if (matcher->all)
- return FALSE;
-
- id = lookup_attribute (attribute);
-
- if (matcher->sub_matchers[0].id != 0 &&
- matcher->sub_matchers[1].id == 0 &&
- matcher->sub_matchers[0].mask == 0xffffffff &&
- matcher->sub_matchers[0].id == id)
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-matcher_matches_id (GFileAttributeMatcher *matcher,
- guint32 id)
-{
- SubMatcher *sub_matchers;
- int i;
-
- for (i = 0; i < ON_STACK_MATCHERS; i++)
- {
- if (matcher->sub_matchers[i].id == 0)
- return FALSE;
-
- if (matcher->sub_matchers[i].id == (id & matcher->sub_matchers[i].mask))
- return TRUE;
- }
-
- if (matcher->more_sub_matchers)
- {
- sub_matchers = (SubMatcher *)matcher->more_sub_matchers->data;
- for (i = 0; i < matcher->more_sub_matchers->len; i++)
- {
- if (sub_matchers[i].id == (id & sub_matchers[i].mask))
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gboolean
-g_file_attribute_matcher_matches_id (GFileAttributeMatcher *matcher,
- guint32 id)
-{
- if (matcher == NULL)
- return FALSE;
-
- if (matcher->all)
- return TRUE;
-
- return matcher_matches_id (matcher, id);
-}
-
-gboolean
-g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,
- const char *attribute)
-{
- if (matcher == NULL)
- return FALSE;
-
- if (matcher->all)
- return TRUE;
-
- return matcher_matches_id (matcher, lookup_attribute (attribute));
-}
-
-/* return TRUE -> all */
-gboolean
-g_file_attribute_matcher_enumerate_namespace (GFileAttributeMatcher *matcher,
- const char *namespace)
-{
- SubMatcher *sub_matchers;
- int ns_id;
- int i;
-
- if (matcher == NULL)
- return FALSE;
-
- if (matcher->all)
- return TRUE;
-
- ns_id = lookup_namespace (namespace) << NS_POS;
-
- for (i = 0; i < ON_STACK_MATCHERS; i++)
- {
- if (matcher->sub_matchers[i].id == ns_id)
- return TRUE;
- }
-
- if (matcher->more_sub_matchers)
- {
- sub_matchers = (SubMatcher *)matcher->more_sub_matchers->data;
- for (i = 0; i < matcher->more_sub_matchers->len; i++)
- {
- if (sub_matchers[i].id == ns_id)
- return TRUE;
- }
- }
-
- matcher->iterator_ns = ns_id;
- matcher->iterator_pos = 0;
-
- return FALSE;
-}
-
-const const char *
-g_file_attribute_matcher_enumerate_next (GFileAttributeMatcher *matcher)
-{
- int i;
- SubMatcher *sub_matcher;
-
- if (matcher == NULL)
- return NULL;
-
- while (1)
- {
- i = matcher->iterator_pos++;
-
- if (i < ON_STACK_MATCHERS)
- {
- if (matcher->sub_matchers[i].id == 0)
- return NULL;
-
- sub_matcher = &matcher->sub_matchers[i];
- }
- else
- {
- if (matcher->more_sub_matchers == NULL)
- return NULL;
-
- i -= ON_STACK_MATCHERS;
- if (i < matcher->more_sub_matchers->len)
- sub_matcher = &g_array_index (matcher->more_sub_matchers, SubMatcher, i);
- else
- return NULL;
- }
-
- if (sub_matcher->mask == 0xffffffff &&
- (sub_matcher->id & (NS_MASK << NS_POS)) == matcher->iterator_ns)
- return get_attribute_for_id (sub_matcher->id);
- }
-}
diff --git a/gio/gfileinfo.h b/gio/gfileinfo.h
deleted file mode 100644
index e43f3fa6..00000000
--- a/gio/gfileinfo.h
+++ /dev/null
@@ -1,244 +0,0 @@
-#ifndef __G_FILE_INFO_H__
-#define __G_FILE_INFO_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gfileattribute.h>
-#include <gio/gicon.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILE_INFO (g_file_info_get_type ())
-#define G_FILE_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_INFO, GFileInfo))
-#define G_FILE_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_INFO, GFileInfoClass))
-#define G_IS_FILE_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_INFO))
-#define G_IS_FILE_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_INFO))
-#define G_FILE_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_INFO, GFileInfoClass))
-
-typedef struct _GFileInfo GFileInfo;
-typedef struct _GFileInfoClass GFileInfoClass;
-typedef struct _GFileAttributeMatcher GFileAttributeMatcher;
-
-typedef enum {
- G_FILE_TYPE_UNKNOWN = 0,
- G_FILE_TYPE_REGULAR,
- G_FILE_TYPE_DIRECTORY,
- G_FILE_TYPE_SYMBOLIC_LINK,
- G_FILE_TYPE_SPECIAL, /* socket, fifo, blockdev, chardev */
- G_FILE_TYPE_SHORTCUT,
- G_FILE_TYPE_MOUNTABLE
-} GFileType;
-
-struct _GFileInfoClass
-{
- GObjectClass parent_class;
-};
-
-/* Common Attributes: */
-
-#define G_FILE_ATTRIBUTE_STD_TYPE "std:type" /* uint32 (GFileType) */
-#define G_FILE_ATTRIBUTE_STD_IS_HIDDEN "std:is_hidden" /* boolean */
-#define G_FILE_ATTRIBUTE_STD_IS_BACKUP "std:is_backup" /* boolean */
-#define G_FILE_ATTRIBUTE_STD_IS_SYMLINK "std:is_symlink" /* boolean */
-#define G_FILE_ATTRIBUTE_STD_IS_VIRTUAL "std:is_virtual" /* boolean */
-#define G_FILE_ATTRIBUTE_STD_NAME "std:name" /* byte string */
-#define G_FILE_ATTRIBUTE_STD_DISPLAY_NAME "std:display_name" /* string */
-#define G_FILE_ATTRIBUTE_STD_EDIT_NAME "std:edit_name" /* string */
-#define G_FILE_ATTRIBUTE_STD_ICON "std:icon" /* object (GIcon) */
-#define G_FILE_ATTRIBUTE_STD_CONTENT_TYPE "std:content_type" /* string */
-#define G_FILE_ATTRIBUTE_STD_FAST_CONTENT_TYPE "std:fast_content_type" /* string */
-#define G_FILE_ATTRIBUTE_STD_SIZE "std:size" /* uint64 */
-#define G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET "std:symlink_target" /* byte string */
-#define G_FILE_ATTRIBUTE_STD_TARGET_URI "std:target_uri" /* string */
-#define G_FILE_ATTRIBUTE_STD_SORT_ORDER "std:sort_order" /* int32 */
-
-/* Entity tags, used to avoid missing updates on save */
-
-#define G_FILE_ATTRIBUTE_ETAG_VALUE "etag:value" /* string */
-
-/* Calculated Access Rights for current user */
-
-#define G_FILE_ATTRIBUTE_ACCESS_CAN_READ "access:can_read" /* boolean */
-#define G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE "access:can_write" /* boolean */
-#define G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE "access:can_execute" /* boolean */
-#define G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE "access:can_delete" /* boolean */
-#define G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME "access:can_rename" /* boolean */
-
-/* Mountable attributes */
-
-#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT "mountable:can_mount" /* boolean */
-#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT "mountable:can_unmount" /* boolean */
-#define G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT "mountable:can_eject" /* boolean */
-#define G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE "mountable:unix_device" /* uint32 */
-#define G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI "mountable:hal_udi" /* string */
-
-/* Time attributes */
-
- /* The last time the file content or an attribute was modified */
-#define G_FILE_ATTRIBUTE_TIME_MODIFIED "time:modified" /* uint64 */
-#define G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC "time:modified_usec" /* uint32 */
- /* The last time the file was read */
-#define G_FILE_ATTRIBUTE_TIME_ACCESS "time:access" /* uint64 */
-#define G_FILE_ATTRIBUTE_TIME_ACCESS_USEC "time:access_usec" /* uint32 */
- /* The last time a file attribute was changed (e.g. unix ctime) */
-#define G_FILE_ATTRIBUTE_TIME_CHANGED "time:changed" /* uint64 */
-#define G_FILE_ATTRIBUTE_TIME_CHANGED_USEC "time:changed_usec" /* uint32 */
- /* When the file was originally created (e.g. ntfs ctime) */
-#define G_FILE_ATTRIBUTE_TIME_CREATED "time:created" /* uint64 */
-#define G_FILE_ATTRIBUTE_TIME_CREATED_USEC "time:created_usec" /* uint32 */
-
-/* Unix specific attributes */
-
-#define G_FILE_ATTRIBUTE_UNIX_DEVICE "unix:device" /* uint32 */
-#define G_FILE_ATTRIBUTE_UNIX_INODE "unix:inode" /* uint64 */
-#define G_FILE_ATTRIBUTE_UNIX_MODE "unix:mode" /* uint32 */
-#define G_FILE_ATTRIBUTE_UNIX_NLINK "unix:nlink" /* uint32 */
-#define G_FILE_ATTRIBUTE_UNIX_UID "unix:uid" /* uint32 */
-#define G_FILE_ATTRIBUTE_UNIX_GID "unix:gid" /* uint32 */
-#define G_FILE_ATTRIBUTE_UNIX_RDEV "unix:rdev" /* uint32 */
-#define G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE "unix:block_size" /* uint32 */
-#define G_FILE_ATTRIBUTE_UNIX_BLOCKS "unix:blocks" /* uint64 */
-
-/* DOS specific attributes */
-
-#define G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE "dos:is_archive" /* boolean */
-#define G_FILE_ATTRIBUTE_DOS_IS_SYSTEM "dos:is_system" /* boolean */
-
-/* Owner attributes */
-
-#define G_FILE_ATTRIBUTE_OWNER_USER "owner:user" /* string */
-#define G_FILE_ATTRIBUTE_OWNER_USER_REAL "owner:user_real" /* string */
-#define G_FILE_ATTRIBUTE_OWNER_GROUP "owner:group" /* string */
-
-/* File system info (for g_file_get_filesystem_info) */
-
-#define G_FILE_ATTRIBUTE_FS_SIZE "fs:size" /* uint64 */
-#define G_FILE_ATTRIBUTE_FS_FREE "fs:free" /* uint64 */
-#define G_FILE_ATTRIBUTE_FS_TYPE "fs:type" /* string */
-
-#define G_FILE_ATTRIBUTE_GVFS_BACKEND "gvfs:backend" /* string */
-
-GType g_file_info_get_type (void) G_GNUC_CONST;
-
-GFileInfo * g_file_info_new (void);
-GFileInfo * g_file_info_dup (GFileInfo *info);
-void g_file_info_copy_into (GFileInfo *src,
- GFileInfo *dest);
-gboolean g_file_info_has_attribute (GFileInfo *info,
- const char *attribute);
-char ** g_file_info_list_attributes (GFileInfo *info,
- const char *name_space);
-GFileAttributeType g_file_info_get_attribute_type (GFileInfo *info,
- const char *attribute);
-void g_file_info_remove_attribute (GFileInfo *info,
- const char *attribute);
-GFileAttributeValue * g_file_info_get_attribute (GFileInfo *info,
- const char *attribute);
-const char * g_file_info_get_attribute_string (GFileInfo *info,
- const char *attribute);
-const char * g_file_info_get_attribute_byte_string (GFileInfo *info,
- const char *attribute);
-gboolean g_file_info_get_attribute_boolean (GFileInfo *info,
- const char *attribute);
-guint32 g_file_info_get_attribute_uint32 (GFileInfo *info,
- const char *attribute);
-gint32 g_file_info_get_attribute_int32 (GFileInfo *info,
- const char *attribute);
-guint64 g_file_info_get_attribute_uint64 (GFileInfo *info,
- const char *attribute);
-gint64 g_file_info_get_attribute_int64 (GFileInfo *info,
- const char *attribute);
-GObject * g_file_info_get_attribute_object (GFileInfo *info,
- const char *attribute);
-
-void g_file_info_set_attribute (GFileInfo *info,
- const char *attribute,
- const GFileAttributeValue *value);
-void g_file_info_set_attribute_string (GFileInfo *info,
- const char *attribute,
- const char *value);
-void g_file_info_set_attribute_byte_string (GFileInfo *info,
- const char *attribute,
- const char *value);
-void g_file_info_set_attribute_boolean (GFileInfo *info,
- const char *attribute,
- gboolean value);
-void g_file_info_set_attribute_uint32 (GFileInfo *info,
- const char *attribute,
- guint32 value);
-void g_file_info_set_attribute_int32 (GFileInfo *info,
- const char *attribute,
- gint32 value);
-void g_file_info_set_attribute_uint64 (GFileInfo *info,
- const char *attribute,
- guint64 value);
-void g_file_info_set_attribute_int64 (GFileInfo *info,
- const char *attribute,
- gint64 value);
-void g_file_info_set_attribute_object (GFileInfo *info,
- const char *attribute,
- GObject *value);
-
-void g_file_info_clear_status (GFileInfo *info);
-
-/* Helper getters: */
-GFileType g_file_info_get_file_type (GFileInfo *info);
-gboolean g_file_info_get_is_hidden (GFileInfo *info);
-gboolean g_file_info_get_is_symlink (GFileInfo *info);
-const char * g_file_info_get_name (GFileInfo *info);
-const char * g_file_info_get_display_name (GFileInfo *info);
-const char * g_file_info_get_edit_name (GFileInfo *info);
-GIcon * g_file_info_get_icon (GFileInfo *info);
-const char * g_file_info_get_content_type (GFileInfo *info);
-goffset g_file_info_get_size (GFileInfo *info);
-void g_file_info_get_modification_time (GFileInfo *info,
- GTimeVal *result);
-const char * g_file_info_get_symlink_target (GFileInfo *info);
-const char * g_file_info_get_etag (GFileInfo *info);
-gint32 g_file_info_get_sort_order (GFileInfo *info);
-
-void g_file_info_set_attribute_mask (GFileInfo *info,
- GFileAttributeMatcher *mask);
-void g_file_info_unset_attribute_mask (GFileInfo *info);
-
-/* Helper setters: */
-void g_file_info_set_file_type (GFileInfo *info,
- GFileType type);
-void g_file_info_set_is_hidden (GFileInfo *info,
- gboolean is_hidden);
-void g_file_info_set_is_symlink (GFileInfo *info,
- gboolean is_symlink);
-void g_file_info_set_name (GFileInfo *info,
- const char *name);
-void g_file_info_set_display_name (GFileInfo *info,
- const char *display_name);
-void g_file_info_set_edit_name (GFileInfo *info,
- const char *edit_name);
-void g_file_info_set_icon (GFileInfo *info,
- GIcon *icon);
-void g_file_info_set_content_type (GFileInfo *info,
- const char *content_type);
-void g_file_info_set_size (GFileInfo *info,
- goffset size);
-void g_file_info_set_modification_time (GFileInfo *info,
- GTimeVal *mtime);
-void g_file_info_set_symlink_target (GFileInfo *info,
- const char *symlink_target);
-void g_file_info_set_sort_order (GFileInfo *info,
- gint32 sort_order);
-
-GFileAttributeMatcher *g_file_attribute_matcher_new (const char *attributes);
-GFileAttributeMatcher *g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher);
-void g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher);
-gboolean g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,
- const char *full_name);
-gboolean g_file_attribute_matcher_matches_only (GFileAttributeMatcher *matcher,
- const char *full_name);
-gboolean g_file_attribute_matcher_enumerate_namespace (GFileAttributeMatcher *matcher,
- const char *namespace);
-const char * g_file_attribute_matcher_enumerate_next (GFileAttributeMatcher *matcher);
-
-G_END_DECLS
-
-
-#endif /* __G_FILE_INFO_H__ */
diff --git a/gio/gfileinputstream.c b/gio/gfileinputstream.c
deleted file mode 100644
index 5d90e224..00000000
--- a/gio/gfileinputstream.c
+++ /dev/null
@@ -1,227 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <gfileinputstream.h>
-#include <gseekable.h>
-
-static void g_file_input_stream_seekable_iface_init (GSeekableIface *iface);
-static goffset g_file_input_stream_seekable_tell (GSeekable *seekable);
-static gboolean g_file_input_stream_seekable_can_seek (GSeekable *seekable);
-static gboolean g_file_input_stream_seekable_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_file_input_stream_seekable_can_truncate (GSeekable *seekable);
-static gboolean g_file_input_stream_seekable_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error);
-
-G_DEFINE_TYPE_WITH_CODE (GFileInputStream, g_file_input_stream, G_TYPE_INPUT_STREAM,
- G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
- g_file_input_stream_seekable_iface_init))
-
-struct _GFileInputStreamPrivate {
- guint dummy;
-};
-
-static void
-g_file_input_stream_class_init (GFileInputStreamClass *klass)
-{
- g_type_class_add_private (klass, sizeof (GFileInputStreamPrivate));
-}
-
-static void
-g_file_input_stream_seekable_iface_init (GSeekableIface *iface)
-{
- iface->tell = g_file_input_stream_seekable_tell;
- iface->can_seek = g_file_input_stream_seekable_can_seek;
- iface->seek = g_file_input_stream_seekable_seek;
- iface->can_truncate = g_file_input_stream_seekable_can_truncate;
- iface->truncate = g_file_input_stream_seekable_truncate;
-}
-
-static void
-g_file_input_stream_init (GFileInputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_FILE_INPUT_STREAM,
- GFileInputStreamPrivate);
-}
-
-GFileInfo *
-g_file_input_stream_get_file_info (GFileInputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error)
-{
- GFileInputStreamClass *class;
- GInputStream *input_stream;
- GFileInfo *info;
-
- g_return_val_if_fail (G_IS_FILE_INPUT_STREAM (stream), NULL);
- g_return_val_if_fail (stream != NULL, NULL);
-
- input_stream = G_INPUT_STREAM (stream);
-
- if (g_input_stream_is_closed (input_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return NULL;
- }
-
- if (g_input_stream_has_pending (input_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return NULL;
- }
-
- info = NULL;
-
- g_input_stream_set_pending (input_stream, TRUE);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- class = G_FILE_INPUT_STREAM_GET_CLASS (stream);
- if (class->get_file_info)
- info = class->get_file_info (stream, attributes, cancellable, error);
- else
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Stream doesn't support get_file_info"));
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- g_input_stream_set_pending (input_stream, FALSE);
-
- return info;
-}
-
-goffset
-g_file_input_stream_tell (GFileInputStream *stream)
-{
- GFileInputStreamClass *class;
- goffset offset;
-
- class = G_FILE_INPUT_STREAM_GET_CLASS (stream);
-
- offset = 0;
- if (class->tell)
- offset = class->tell (stream);
-
- return offset;
-}
-
-static goffset
-g_file_input_stream_seekable_tell (GSeekable *seekable)
-{
- return g_file_input_stream_tell (G_FILE_INPUT_STREAM (seekable));
-}
-
-gboolean
-g_file_input_stream_can_seek (GFileInputStream *stream)
-{
- GFileInputStreamClass *class;
- gboolean can_seek;
-
- class = G_FILE_INPUT_STREAM_GET_CLASS (stream);
-
- can_seek = FALSE;
- if (class->seek)
- {
- can_seek = TRUE;
- if (class->can_seek)
- can_seek = class->can_seek (stream);
- }
-
- return can_seek;
-}
-
-static gboolean
-g_file_input_stream_seekable_can_seek (GSeekable *seekable)
-{
- return g_file_input_stream_can_seek (G_FILE_INPUT_STREAM (seekable));
-}
-
-gboolean
-g_file_input_stream_seek (GFileInputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- GFileInputStreamClass *class;
- GInputStream *input_stream;
- gboolean res;
-
- input_stream = G_INPUT_STREAM (stream);
- class = G_FILE_INPUT_STREAM_GET_CLASS (stream);
-
- if (g_input_stream_is_closed (input_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return FALSE;
- }
-
- if (g_input_stream_has_pending (input_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return FALSE;
- }
-
- if (!class->seek)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Seek not supported on stream"));
- return FALSE;
- }
-
- g_input_stream_set_pending (input_stream, TRUE);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- res = class->seek (stream, offset, type, cancellable, error);
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- g_input_stream_set_pending (input_stream, FALSE);
-
- return res;
-}
-
-static gboolean
-g_file_input_stream_seekable_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- return g_file_input_stream_seek (G_FILE_INPUT_STREAM (seekable),
- offset, type, cancellable, error);
-}
-
-static gboolean
-g_file_input_stream_seekable_can_truncate (GSeekable *seekable)
-{
- return FALSE;
-}
-
-static gboolean
-g_file_input_stream_seekable_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error)
-{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Truncate not allowed on input stream"));
- return FALSE;
-}
diff --git a/gio/gfileinputstream.h b/gio/gfileinputstream.h
deleted file mode 100644
index f44578f0..00000000
--- a/gio/gfileinputstream.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef __G_FILE_INPUT_STREAM_H__
-#define __G_FILE_INPUT_STREAM_H__
-
-#include <gio/ginputstream.h>
-#include <gio/gfileinfo.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILE_INPUT_STREAM (g_file_input_stream_get_type ())
-#define G_FILE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_INPUT_STREAM, GFileInputStream))
-#define G_FILE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_INPUT_STREAM, GFileInputStreamClass))
-#define G_IS_FILE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_INPUT_STREAM))
-#define G_IS_FILE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_INPUT_STREAM))
-#define G_FILE_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_INPUT_STREAM, GFileInputStreamClass))
-
-typedef struct _GFileInputStream GFileInputStream;
-typedef struct _GFileInputStreamClass GFileInputStreamClass;
-typedef struct _GFileInputStreamPrivate GFileInputStreamPrivate;
-
-struct _GFileInputStream
-{
- GInputStream parent;
-
- /*< private >*/
- GFileInputStreamPrivate *priv;
-};
-
-struct _GFileInputStreamClass
-{
- GInputStreamClass parent_class;
-
- goffset (*tell) (GFileInputStream *stream);
- gboolean (*can_seek) (GFileInputStream *stream);
- gboolean (*seek) (GFileInputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
- GFileInfo *(*get_file_info) (GFileInputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error);
-
- /* Padding for future expansion */
- void (*_g_reserved1) (void);
- void (*_g_reserved2) (void);
- void (*_g_reserved3) (void);
- void (*_g_reserved4) (void);
- void (*_g_reserved5) (void);
-};
-
-GType g_file_input_stream_get_type (void) G_GNUC_CONST;
-
-GFileInfo *g_file_input_stream_get_file_info (GFileInputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error);
-goffset g_file_input_stream_tell (GFileInputStream *stream);
-gboolean g_file_input_stream_can_seek (GFileInputStream *stream);
-gboolean g_file_input_stream_seek (GFileInputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __G_FILE_FILE_INPUT_STREAM_H__ */
diff --git a/gio/gfilemonitor.c b/gio/gfilemonitor.c
deleted file mode 100644
index 6382ff33..00000000
--- a/gio/gfilemonitor.c
+++ /dev/null
@@ -1,321 +0,0 @@
-#include <config.h>
-#include <string.h>
-
-#include "gfilemonitorpriv.h"
-#include "gvfs-marshal.h"
-#include "gvfs.h"
-
-enum {
- CHANGED,
- LAST_SIGNAL
-};
-
-G_DEFINE_TYPE (GFileMonitor, g_file_monitor, G_TYPE_OBJECT);
-
-struct _GFileMonitorPrivate {
- gboolean cancelled;
- int rate_limit_msec;
-
- /* Rate limiting change events */
- guint32 last_sent_change_time; /* Some monitonic clock in msecs */
- GFile *last_sent_change_file;
-
- guint send_delayed_change_timeout;
-
- /* Virtual CHANGES_DONE_HINT emission */
- GSource *virtual_changes_done_timeout;
- GFile *virtual_changes_done_file;
-};
-
-#define DEFAULT_RATE_LIMIT_MSECS 800
-#define DEFAULT_VIRTUAL_CHANGES_DONE_DELAY_SECS 2
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void
-g_file_monitor_finalize (GObject *object)
-{
- GFileMonitor *monitor;
-
- monitor = G_FILE_MONITOR (object);
-
- if (monitor->priv->last_sent_change_file)
- g_object_unref (monitor->priv->last_sent_change_file);
-
- if (monitor->priv->send_delayed_change_timeout != 0)
- g_source_remove (monitor->priv->send_delayed_change_timeout);
-
- if (monitor->priv->virtual_changes_done_file)
- g_object_unref (monitor->priv->virtual_changes_done_file);
-
- if (monitor->priv->virtual_changes_done_timeout)
- g_source_destroy (monitor->priv->virtual_changes_done_timeout);
-
- if (G_OBJECT_CLASS (g_file_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_file_monitor_parent_class)->finalize) (object);
-}
-
-static void
-g_file_monitor_dispose (GObject *object)
-{
- GFileMonitor *monitor;
-
- monitor = G_FILE_MONITOR (object);
-
- /* Make sure we cancel on last unref */
- if (!monitor->priv->cancelled)
- g_file_monitor_cancel (monitor);
-
- if (G_OBJECT_CLASS (g_file_monitor_parent_class)->dispose)
- (*G_OBJECT_CLASS (g_file_monitor_parent_class)->dispose) (object);
-}
-
-static void
-g_file_monitor_class_init (GFileMonitorClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GFileMonitorPrivate));
-
- gobject_class->finalize = g_file_monitor_finalize;
- gobject_class->dispose = g_file_monitor_dispose;
-
- signals[CHANGED] =
- g_signal_new (I_("changed"),
- G_TYPE_FILE_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GFileMonitorClass, changed),
- NULL, NULL,
- _gvfs_marshal_VOID__OBJECT_OBJECT_INT,
- G_TYPE_NONE,3,
- G_TYPE_FILE,
- G_TYPE_FILE,
- G_TYPE_INT);
-}
-
-static void
-g_file_monitor_init (GFileMonitor *monitor)
-{
- monitor->priv = G_TYPE_INSTANCE_GET_PRIVATE (monitor,
- G_TYPE_FILE_MONITOR,
- GFileMonitorPrivate);
- monitor->priv->rate_limit_msec = DEFAULT_RATE_LIMIT_MSECS;
-}
-
-
-gboolean
-g_file_monitor_is_cancelled (GFileMonitor *monitor)
-{
- return monitor->priv->cancelled;
-}
-
-gboolean
-g_file_monitor_cancel (GFileMonitor* monitor)
-{
- GFileMonitorClass *class;
-
- if (monitor->priv->cancelled)
- return TRUE;
-
- monitor->priv->cancelled = TRUE;
-
- class = G_FILE_MONITOR_GET_CLASS (monitor);
- return (* class->cancel) (monitor);
-}
-
-void
-g_file_monitor_set_rate_limit (GFileMonitor *monitor,
- int limit_msecs)
-{
- monitor->priv->rate_limit_msec = limit_msecs;
-}
-
-static guint32
-get_time_msecs (void)
-{
- return g_thread_gettime() / (1000 * 1000);
-}
-
-static guint32
-time_difference (guint32 from, guint32 to)
-{
- if (from > to)
- return 0;
- return to - from;
-}
-
-/* Change event rate limiting support: */
-
-static void
-update_last_sent_change (GFileMonitor *monitor, GFile *file, guint32 time_now)
-{
- if (monitor->priv->last_sent_change_file != file)
- {
- if (monitor->priv->last_sent_change_file)
- {
- g_object_unref (monitor->priv->last_sent_change_file);
- monitor->priv->last_sent_change_file = NULL;
- }
- if (file)
- monitor->priv->last_sent_change_file = g_object_ref (file);
- }
-
- monitor->priv->last_sent_change_time = time_now;
-}
-
-static void
-send_delayed_change_now (GFileMonitor *monitor)
-{
- if (monitor->priv->send_delayed_change_timeout)
- {
- g_print ("emitting delayed changed event\n");
- g_signal_emit (monitor, signals[CHANGED], 0,
- monitor->priv->last_sent_change_file, NULL,
- G_FILE_MONITOR_EVENT_CHANGED);
-
- g_source_remove (monitor->priv->send_delayed_change_timeout);
- monitor->priv->send_delayed_change_timeout = 0;
-
- /* Same file, new last_sent time */
- monitor->priv->last_sent_change_time = get_time_msecs ();
- }
-}
-
-static gboolean
-delayed_changed_event_timeout (gpointer data)
-{
- GFileMonitor *monitor = data;
-
- send_delayed_change_now (monitor);
-
- return FALSE;
-}
-
-static void
-schedule_delayed_change (GFileMonitor *monitor, GFile *file, guint32 delay_msec)
-{
- if (monitor->priv->send_delayed_change_timeout == 0) /* Only set the timeout once */
- {
- monitor->priv->send_delayed_change_timeout =
- g_timeout_add (delay_msec, delayed_changed_event_timeout, monitor);
- }
-}
-
-static void
-cancel_delayed_change (GFileMonitor *monitor)
-{
- if (monitor->priv->send_delayed_change_timeout != 0)
- {
- g_source_remove (monitor->priv->send_delayed_change_timeout);
- monitor->priv->send_delayed_change_timeout = 0;
- }
-}
-
-/* Virtual changes_done_hint support: */
-
-static void
-send_virtual_changes_done_now (GFileMonitor *monitor)
-{
- if (monitor->priv->virtual_changes_done_timeout)
- {
- g_signal_emit (monitor, signals[CHANGED], 0,
- monitor->priv->virtual_changes_done_file, NULL,
- G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT);
-
- g_source_destroy (monitor->priv->virtual_changes_done_timeout);
- monitor->priv->virtual_changes_done_timeout = NULL;
-
- g_object_unref (monitor->priv->virtual_changes_done_file);
- monitor->priv->virtual_changes_done_file = NULL;
- }
-}
-
-static gboolean
-virtual_changes_done_timeout (gpointer data)
-{
- GFileMonitor *monitor = data;
-
- send_virtual_changes_done_now (monitor);
-
- return FALSE;
-}
-
-static void
-schedule_virtual_change_done (GFileMonitor *monitor, GFile *file)
-{
- GSource *source;
-
- source = g_timeout_source_new_seconds (DEFAULT_VIRTUAL_CHANGES_DONE_DELAY_SECS);
-
- g_source_set_callback (source, virtual_changes_done_timeout, monitor, NULL);
- g_source_attach (source, NULL);
- monitor->priv->virtual_changes_done_timeout = source;
- monitor->priv->virtual_changes_done_file = g_object_ref (file);
- g_source_unref (source);
-}
-
-static void
-cancel_virtual_changes_done (GFileMonitor *monitor)
-{
- if (monitor->priv->virtual_changes_done_timeout)
- {
- g_source_destroy (monitor->priv->virtual_changes_done_timeout);
- monitor->priv->virtual_changes_done_timeout = NULL;
-
- g_object_unref (monitor->priv->virtual_changes_done_file);
- monitor->priv->virtual_changes_done_file = NULL;
- }
-}
-
-void
-g_file_monitor_emit_event (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type)
-{
- guint32 time_now, since_last;
- gboolean emit_now;
-
- if (event_type != G_FILE_MONITOR_EVENT_CHANGED)
- {
- send_delayed_change_now (monitor);
- update_last_sent_change (monitor, NULL, 0);
- if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
- cancel_virtual_changes_done (monitor);
- else
- send_virtual_changes_done_now (monitor);
- g_signal_emit (monitor, signals[CHANGED], 0, file, other_file, event_type);
- }
- else
- {
- time_now = get_time_msecs ();
- emit_now = TRUE;
-
- if (monitor->priv->last_sent_change_file)
- {
- since_last = time_difference (monitor->priv->last_sent_change_time, time_now);
- if (since_last < monitor->priv->rate_limit_msec)
- {
- /* We ignore this change, but arm a timer so that we can fire it later if we
- don't get any other events (that kill this timeout) */
- emit_now = FALSE;
- schedule_delayed_change (monitor, file,
- monitor->priv->rate_limit_msec - since_last);
- }
- }
-
- if (emit_now)
- {
- g_print ("emitting real changed event\n");
- g_signal_emit (monitor, signals[CHANGED], 0, file, other_file, event_type);
-
- cancel_delayed_change (monitor);
- update_last_sent_change (monitor, file, time_now);
- }
-
- /* Schedule a virtual change done. This is removed if we get a real one, and
- postponed if we get more change events. */
- cancel_virtual_changes_done (monitor);
- schedule_virtual_change_done (monitor, file);
- }
-}
diff --git a/gio/gfilemonitor.h b/gio/gfilemonitor.h
deleted file mode 100644
index 1c4884d3..00000000
--- a/gio/gfilemonitor.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef __G_FILE_MONITOR_H__
-#define __G_FILE_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gfile.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILE_MONITOR (g_file_monitor_get_type ())
-#define G_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_MONITOR, GFileMonitor))
-#define G_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_MONITOR, GFileMonitorClass))
-#define G_IS_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_MONITOR))
-#define G_IS_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_MONITOR))
-#define G_FILE_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_MONITOR, GFileMonitorClass))
-
-typedef enum {
- G_FILE_MONITOR_EVENT_CHANGED,
- G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT,
- G_FILE_MONITOR_EVENT_DELETED,
- G_FILE_MONITOR_EVENT_CREATED,
- G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED,
- G_FILE_MONITOR_EVENT_PRE_UNMOUNT,
- G_FILE_MONITOR_EVENT_UNMOUNTED
-} GFileMonitorEvent;
-
-typedef struct _GFileMonitorClass GFileMonitorClass;
-typedef struct _GFileMonitorPrivate GFileMonitorPrivate;
-
-struct _GFileMonitor
-{
- GObject parent;
-
- /*< private >*/
- GFileMonitorPrivate *priv;
-};
-
-struct _GFileMonitorClass
-{
- GObjectClass parent_class;
-
- /* Signals */
- void (* changed) (GFileMonitor* monitor,
- GFile* file,
- GFile* other_file,
- GFileMonitorEvent event_type);
-
- /* Virtual Table */
- gboolean (*cancel)(GFileMonitor* monitor);
-};
-
-GType g_file_monitor_get_type (void) G_GNUC_CONST;
-
-gboolean g_file_monitor_cancel (GFileMonitor *monitor);
-gboolean g_file_monitor_is_cancelled (GFileMonitor *monitor);
-void g_file_monitor_set_rate_limit (GFileMonitor *monitor,
- int limit_msecs);
-
-G_END_DECLS
-
-#endif /* __G_FILE_MONITOR_H__ */
diff --git a/gio/gfilemonitorpriv.h b/gio/gfilemonitorpriv.h
deleted file mode 100644
index 81df8922..00000000
--- a/gio/gfilemonitorpriv.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __G_FILE_MONITOR_PRIV_H__
-#define __G_FILE_MONITOR_PRIV_H__
-
-#include <gio/gfilemonitor.h>
-
-G_BEGIN_DECLS
-
-void g_file_monitor_emit_event (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type);
-
-G_END_DECLS
-
-#endif /* __G_FILE_MONITOR_PRIV_H__ */
diff --git a/gio/gfileoutputstream.c b/gio/gfileoutputstream.c
deleted file mode 100644
index a7864d77..00000000
--- a/gio/gfileoutputstream.c
+++ /dev/null
@@ -1,345 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <gfileoutputstream.h>
-#include <gseekable.h>
-
-static void g_file_output_stream_seekable_iface_init (GSeekableIface *iface);
-static goffset g_file_output_stream_seekable_tell (GSeekable *seekable);
-static gboolean g_file_output_stream_seekable_can_seek (GSeekable *seekable);
-static gboolean g_file_output_stream_seekable_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_file_output_stream_seekable_can_truncate (GSeekable *seekable);
-static gboolean g_file_output_stream_seekable_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error);
-
-G_DEFINE_TYPE_WITH_CODE (GFileOutputStream, g_file_output_stream, G_TYPE_OUTPUT_STREAM,
- G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
- g_file_output_stream_seekable_iface_init));
-
-struct _GFileOutputStreamPrivate {
- int dummy;
-};
-
-static void
-g_file_output_stream_class_init (GFileOutputStreamClass *klass)
-{
- g_type_class_add_private (klass, sizeof (GFileOutputStreamPrivate));
-}
-
-static void
-g_file_output_stream_seekable_iface_init (GSeekableIface *iface)
-{
- iface->tell = g_file_output_stream_seekable_tell;
- iface->can_seek = g_file_output_stream_seekable_can_seek;
- iface->seek = g_file_output_stream_seekable_seek;
- iface->can_truncate = g_file_output_stream_seekable_can_truncate;
- iface->truncate = g_file_output_stream_seekable_truncate;
-}
-
-static void
-g_file_output_stream_init (GFileOutputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_FILE_OUTPUT_STREAM,
- GFileOutputStreamPrivate);
-}
-
-GFileInfo *
-g_file_output_stream_get_file_info (GFileOutputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error)
-{
- GFileOutputStreamClass *class;
- GOutputStream *output_stream;
- GFileInfo *info;
-
- g_return_val_if_fail (G_IS_FILE_OUTPUT_STREAM (stream), NULL);
- g_return_val_if_fail (stream != NULL, NULL);
-
- output_stream = G_OUTPUT_STREAM (stream);
-
- if (g_output_stream_is_closed (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return NULL;
- }
-
- if (g_output_stream_has_pending (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return NULL;
- }
-
- info = NULL;
-
- g_output_stream_set_pending (output_stream, TRUE);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
- if (class->get_file_info)
- info = class->get_file_info (stream, attributes, cancellable, error);
- else
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Stream doesn't support get_file_info"));
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- g_output_stream_set_pending (output_stream, FALSE);
-
- return info;
-}
-
-char *
-g_file_output_stream_get_etag (GFileOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GFileOutputStreamClass *class;
- GOutputStream *output_stream;
- char *etag;
-
- g_return_val_if_fail (G_IS_FILE_OUTPUT_STREAM (stream), NULL);
- g_return_val_if_fail (stream != NULL, NULL);
-
- output_stream = G_OUTPUT_STREAM (stream);
-
- if (!g_output_stream_is_closed (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream isn't closed yet, can't get etag"));
- return NULL;
- }
-
- if (g_output_stream_has_pending (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return NULL;
- }
-
- etag = NULL;
-
- g_output_stream_set_pending (output_stream, TRUE);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
- if (class->get_etag)
- etag = class->get_etag (stream, cancellable, error);
- else
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("etag not supported on stream"));
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- g_output_stream_set_pending (output_stream, FALSE);
-
- return etag;
-}
-
-goffset
-g_file_output_stream_tell (GFileOutputStream *stream)
-{
- GFileOutputStreamClass *class;
- goffset offset;
-
- class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
-
- offset = 0;
- if (class->tell)
- offset = class->tell (stream);
-
- return offset;
-}
-
-static goffset
-g_file_output_stream_seekable_tell (GSeekable *seekable)
-{
- return g_file_output_stream_tell (G_FILE_OUTPUT_STREAM (seekable));
-}
-
-gboolean
-g_file_output_stream_can_seek (GFileOutputStream *stream)
-{
- GFileOutputStreamClass *class;
- gboolean can_seek;
-
- class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
-
- can_seek = FALSE;
- if (class->seek)
- {
- can_seek = TRUE;
- if (class->can_seek)
- can_seek = class->can_seek (stream);
- }
-
- return can_seek;
-}
-
-static gboolean
-g_file_output_stream_seekable_can_seek (GSeekable *seekable)
-{
- return g_file_output_stream_can_seek (G_FILE_OUTPUT_STREAM (seekable));
-}
-
-gboolean
-g_file_output_stream_seek (GFileOutputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- GFileOutputStreamClass *class;
- GOutputStream *output_stream;
- gboolean res;
-
- output_stream = G_OUTPUT_STREAM (stream);
- class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
-
- if (g_output_stream_is_closed (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return FALSE;
- }
-
- if (g_output_stream_has_pending (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return FALSE;
- }
-
- if (!class->seek)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Seek not supported on stream"));
- return FALSE;
- }
-
- g_output_stream_set_pending (output_stream, TRUE);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- res = class->seek (stream, offset, type, cancellable, error);
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- g_output_stream_set_pending (output_stream, FALSE);
-
- return res;
-}
-
-static gboolean
-g_file_output_stream_seekable_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- return g_file_output_stream_seek (G_FILE_OUTPUT_STREAM (seekable),
- offset, type, cancellable, error);
-}
-
-gboolean
-g_file_output_stream_can_truncate (GFileOutputStream *stream)
-{
- GFileOutputStreamClass *class;
- gboolean can_truncate;
-
- class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
-
- can_truncate = FALSE;
- if (class->truncate)
- {
- can_truncate = TRUE;
- if (class->can_truncate)
- can_truncate = class->can_truncate (stream);
- }
-
- return can_truncate;
-}
-
-static gboolean
-g_file_output_stream_seekable_can_truncate (GSeekable *seekable)
-{
- return g_file_output_stream_can_truncate (G_FILE_OUTPUT_STREAM (seekable));
-}
-
-
-gboolean
-g_file_output_stream_truncate (GFileOutputStream *stream,
- goffset size,
- GCancellable *cancellable,
- GError **error)
-{
- GFileOutputStreamClass *class;
- GOutputStream *output_stream;
- gboolean res;
-
- output_stream = G_OUTPUT_STREAM (stream);
- class = G_FILE_OUTPUT_STREAM_GET_CLASS (stream);
-
- if (g_output_stream_is_closed (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return FALSE;
- }
-
- if (g_output_stream_has_pending (output_stream))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return FALSE;
- }
-
- if (!class->truncate)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Truncate not supported on stream"));
- return FALSE;
- }
-
- g_output_stream_set_pending (output_stream, TRUE);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- res = class->truncate (stream, size, cancellable, error);
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- g_output_stream_set_pending (output_stream, FALSE);
-
- return res;
-}
-
-static gboolean
-g_file_output_stream_seekable_truncate (GSeekable *seekable,
- goffset size,
- GCancellable *cancellable,
- GError **error)
-{
- return g_file_output_stream_truncate (G_FILE_OUTPUT_STREAM (seekable),
- size, cancellable, error);
-}
diff --git a/gio/gfileoutputstream.h b/gio/gfileoutputstream.h
deleted file mode 100644
index e5427ad3..00000000
--- a/gio/gfileoutputstream.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef __G_FILE_OUTPUT_STREAM_H__
-#define __G_FILE_OUTPUT_STREAM_H__
-
-#include <gio/goutputstream.h>
-#include <gio/gfileinfo.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILE_OUTPUT_STREAM (g_file_output_stream_get_type ())
-#define G_FILE_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILE_OUTPUT_STREAM, GFileOutputStream))
-#define G_FILE_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILE_OUTPUT_STREAM, GFileOutputStreamClass))
-#define G_IS_FILE_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILE_OUTPUT_STREAM))
-#define G_IS_FILE_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILE_OUTPUT_STREAM))
-#define G_FILE_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILE_OUTPUT_STREAM, GFileOutputStreamClass))
-
-typedef struct _GFileOutputStream GFileOutputStream;
-typedef struct _GFileOutputStreamClass GFileOutputStreamClass;
-typedef struct _GFileOutputStreamPrivate GFileOutputStreamPrivate;
-
-struct _GFileOutputStream
-{
- GOutputStream parent;
-
- /*< private >*/
- GFileOutputStreamPrivate *priv;
-};
-
-struct _GFileOutputStreamClass
-{
- GOutputStreamClass parent_class;
-
- goffset (*tell) (GFileOutputStream *stream);
- gboolean (*can_seek) (GFileOutputStream *stream);
- gboolean (*seek) (GFileOutputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
- gboolean (*can_truncate) (GFileOutputStream *stream);
- gboolean (*truncate) (GFileOutputStream *stream,
- goffset size,
- GCancellable *cancellable,
- GError **error);
- GFileInfo *(*get_file_info) (GFileOutputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error);
- char *(*get_etag) (GFileOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-
- /* Padding for future expansion */
- void (*_g_reserved1) (void);
- void (*_g_reserved2) (void);
- void (*_g_reserved3) (void);
- void (*_g_reserved4) (void);
- void (*_g_reserved5) (void);
-};
-
-GType g_file_output_stream_get_type (void) G_GNUC_CONST;
-
-
-GFileInfo *g_file_output_stream_get_file_info (GFileOutputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error);
-char * g_file_output_stream_get_etag (GFileOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-goffset g_file_output_stream_tell (GFileOutputStream *stream);
-gboolean g_file_output_stream_can_seek (GFileOutputStream *stream);
-gboolean g_file_output_stream_seek (GFileOutputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-gboolean g_file_output_stream_can_truncate (GFileOutputStream *stream);
-gboolean g_file_output_stream_truncate (GFileOutputStream *stream,
- goffset size,
- GCancellable *cancellable,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __G_FILE_FILE_OUTPUT_STREAM_H__ */
diff --git a/gio/gfilterinputstream.c b/gio/gfilterinputstream.c
deleted file mode 100644
index 87735b85..00000000
--- a/gio/gfilterinputstream.c
+++ /dev/null
@@ -1,367 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-
-#include "gfilterinputstream.h"
-#include "ginputstream.h"
-
-/* TODO: Real P_() */
-#define P_(_x) (_x)
-
-
-enum {
- PROP_0,
- PROP_BASE_STREAM
-};
-
-static void g_filter_input_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void g_filter_input_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void g_filter_input_stream_finalize (GObject *object);
-
-
-static gssize g_filter_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gssize g_filter_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_filter_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static void g_filter_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static gssize g_filter_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_filter_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer datae);
-static gssize g_filter_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_filter_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_filter_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-G_DEFINE_TYPE (GFilterInputStream, g_filter_input_stream, G_TYPE_INPUT_STREAM)
-
-
-static void
-g_filter_input_stream_class_init (GFilterInputStreamClass *klass)
-{
- GObjectClass *object_class;
- GInputStreamClass *istream_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = g_filter_input_stream_get_property;
- object_class->set_property = g_filter_input_stream_set_property;
- object_class->finalize = g_filter_input_stream_finalize;
-
- istream_class = G_INPUT_STREAM_CLASS (klass);
- istream_class->read = g_filter_input_stream_read;
- istream_class->skip = g_filter_input_stream_skip;
- istream_class->close = g_filter_input_stream_close;
-
- istream_class->read_async = g_filter_input_stream_read_async;
- istream_class->read_finish = g_filter_input_stream_read_finish;
- istream_class->skip_async = g_filter_input_stream_skip_async;
- istream_class->skip_finish = g_filter_input_stream_skip_finish;
- istream_class->close_async = g_filter_input_stream_close_async;
- istream_class->close_finish = g_filter_input_stream_close_finish;
-
- g_object_class_install_property (object_class,
- PROP_BASE_STREAM,
- g_param_spec_object ("base-stream",
- P_("The Filter Base Stream"),
- P_("The underlying base stream the io ops will be done on"),
- G_TYPE_INPUT_STREAM,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
-
-}
-
-static void
-g_filter_input_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GFilterInputStream *filter_stream;
- GObject *obj;
-
- filter_stream = G_FILTER_INPUT_STREAM (object);
-
- switch (prop_id)
- {
- case PROP_BASE_STREAM:
- obj = g_value_dup_object (value);
- filter_stream->base_stream = G_INPUT_STREAM (obj);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_filter_input_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GFilterInputStream *filter_stream;
-
- filter_stream = G_FILTER_INPUT_STREAM (object);
-
- switch (prop_id)
- {
- case PROP_BASE_STREAM:
- g_value_set_object (value, filter_stream->base_stream);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_filter_input_stream_finalize (GObject *object)
-{
- GFilterInputStream *stream;
-
- stream = G_FILTER_INPUT_STREAM (object);
-
- g_object_unref (stream->base_stream);
-
- if (G_OBJECT_CLASS (g_filter_input_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_filter_input_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_filter_input_stream_init (GFilterInputStream *stream)
-{
-
-}
-
-
-GInputStream *
-g_filter_input_stream_get_base_stream (GFilterInputStream *stream)
-{
- return stream->base_stream;
-}
-
-static gssize
-g_filter_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
- gssize nread;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- nread = g_input_stream_read (base_stream,
- buffer,
- count,
- cancellable,
- error);
-
- return nread;
-}
-static gssize
-g_filter_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
- gssize nskipped;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- nskipped = g_input_stream_skip (base_stream,
- count,
- cancellable,
- error);
- return nskipped;
-}
-
-static gboolean
-g_filter_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
- gboolean res;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- res = g_input_stream_close (base_stream,
- cancellable,
- error);
-
- return res;
-}
-
-static void
-g_filter_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- g_input_stream_read_async (base_stream,
- buffer,
- count,
- io_priority,
- cancellable,
- callback,
- user_data);
-}
-
-static gssize
-g_filter_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
- gssize nread;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- nread = g_input_stream_read_finish (base_stream,
- result,
- error);
-
- return nread;
-}
-
-static void
-g_filter_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- g_input_stream_skip_async (base_stream,
- count,
- io_priority,
- cancellable,
- callback,
- user_data);
-
-}
-
-static gssize
-g_filter_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
- gssize nskipped;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- nskipped = g_input_stream_skip_finish (base_stream,
- result,
- error);
-
- return nskipped;
-}
-
-static void
-g_filter_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- g_input_stream_close_async (base_stream,
- io_priority,
- cancellable,
- callback,
- user_data);
-
-
-}
-
-static gboolean
-g_filter_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GFilterInputStream *filter_stream;
- GInputStream *base_stream;
- gboolean res;
-
- filter_stream = G_FILTER_INPUT_STREAM (stream);
- base_stream = filter_stream->base_stream;
-
- res = g_input_stream_close_finish (stream,
- result,
- error);
-
- return res;
-}
-
-/* vim: ts=2 sw=2 et */
diff --git a/gio/gfilterinputstream.h b/gio/gfilterinputstream.h
deleted file mode 100644
index 95864b00..00000000
--- a/gio/gfilterinputstream.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __G_FILTER_INPUT_STREAM_H__
-#define __G_FILTER_INPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/ginputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILTER_INPUT_STREAM (g_filter_input_stream_get_type ())
-#define G_FILTER_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILTER_INPUT_STREAM, GFilterInputStream))
-#define G_FILTER_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILTER_INPUT_STREAM, GFilterInputStreamClass))
-#define G_IS_FILTER_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILTER_INPUT_STREAM))
-#define G_IS_FILTER_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILTER_INPUT_STREAM))
-#define G_FILTER_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILTER_INPUT_STREAM, GFilterInputStreamClass))
-
-typedef struct _GFilterInputStream GFilterInputStream;
-typedef struct _GFilterInputStreamClass GFilterInputStreamClass;
-typedef struct _GFilterInputStreamPrivate GFilterInputStreamPrivate;
-
-struct _GFilterInputStream
-{
- GInputStream parent;
-
- /*<protected >*/
- GInputStream *base_stream;
-};
-
-struct _GFilterInputStreamClass
-{
- GInputStreamClass parent_class;
-};
-
-
-GType g_filter_input_stream_get_type (void) G_GNUC_CONST;
-GInputStream *g_filter_input_stream_get_base_stream (GFilterInputStream *stream);
-G_END_DECLS
-
-#endif /* __G_FILTER_INPUT_STREAM_H__ */
diff --git a/gio/gfilteroutputstream.c b/gio/gfilteroutputstream.c
deleted file mode 100644
index 7b333b93..00000000
--- a/gio/gfilteroutputstream.c
+++ /dev/null
@@ -1,347 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-
-#include "gfilteroutputstream.h"
-#include "goutputstream.h"
-
-/* TODO: Real P_() */
-#define P_(_x) (_x)
-
-enum {
- PROP_0,
- PROP_BASE_STREAM
-};
-
-static void g_filter_output_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void g_filter_output_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void g_filter_output_stream_dispose (GObject *object);
-
-
-static gssize g_filter_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_filter_output_stream_flush (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_filter_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static void g_filter_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_filter_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_filter_output_stream_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_filter_output_stream_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_filter_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_filter_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-
-
-G_DEFINE_TYPE (GFilterOutputStream, g_filter_output_stream, G_TYPE_OUTPUT_STREAM)
-
-
-
-static void
-g_filter_output_stream_class_init (GFilterOutputStreamClass *klass)
-{
- GObjectClass *object_class;
- GOutputStreamClass *ostream_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = g_filter_output_stream_get_property;
- object_class->set_property = g_filter_output_stream_set_property;
- object_class->dispose = g_filter_output_stream_dispose;
-
- ostream_class = G_OUTPUT_STREAM_CLASS (klass);
- ostream_class->write = g_filter_output_stream_write;
- ostream_class->flush = g_filter_output_stream_flush;
- ostream_class->close = g_filter_output_stream_close;
- ostream_class->write_async = g_filter_output_stream_write_async;
- ostream_class->write_finish = g_filter_output_stream_write_finish;
- ostream_class->flush_async = g_filter_output_stream_flush_async;
- ostream_class->flush_finish = g_filter_output_stream_flush_finish;
- ostream_class->close_async = g_filter_output_stream_close_async;
- ostream_class->close_finish = g_filter_output_stream_close_finish;
-
- g_object_class_install_property (object_class,
- PROP_BASE_STREAM,
- g_param_spec_object ("base-stream",
- P_("The Filter Base Stream"),
- P_("The underlying base stream the io ops will be done on"),
- G_TYPE_OUTPUT_STREAM,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
-
-}
-
-static void
-g_filter_output_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GFilterOutputStream *filter_stream;
- GObject *obj;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (object);
-
- switch (prop_id)
- {
- case PROP_BASE_STREAM:
- obj = g_value_dup_object (value);
- filter_stream->base_stream = G_OUTPUT_STREAM (obj);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_filter_output_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GFilterOutputStream *filter_stream;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (object);
-
- switch (prop_id)
- {
- case PROP_BASE_STREAM:
- g_value_set_object (value, filter_stream->base_stream);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
-}
-
-static void
-g_filter_output_stream_dispose (GObject *object)
-{
- GFilterOutputStream *stream;
-
- stream = G_FILTER_OUTPUT_STREAM (object);
-
- G_OBJECT_CLASS (g_filter_output_stream_parent_class)->dispose (object);
-
- if (stream->base_stream)
- {
- g_object_unref (stream->base_stream);
- stream->base_stream = NULL;
- }
-}
-
-
-static void
-g_filter_output_stream_init (GFilterOutputStream *stream)
-{
-}
-
-GOutputStream *
-g_filter_output_stream_get_base_stream (GFilterOutputStream *stream)
-{
- return stream->base_stream;
-}
-
-static gssize
-g_filter_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GFilterOutputStream *filter_stream;
- gssize nwritten;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- nwritten = g_output_stream_write (filter_stream->base_stream,
- buffer,
- count,
- cancellable,
- error);
-
- return nwritten;
-}
-
-static gboolean
-g_filter_output_stream_flush (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GFilterOutputStream *filter_stream;
- gboolean res;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- res = g_output_stream_flush (filter_stream->base_stream,
- cancellable,
- error);
-
- return res;
-}
-
-static gboolean
-g_filter_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GFilterOutputStream *filter_stream;
- gboolean res;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- res = g_output_stream_close (filter_stream->base_stream,
- cancellable,
- error);
-
- return res;
-}
-
-static void
-g_filter_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GFilterOutputStream *filter_stream;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- g_output_stream_write_async (filter_stream->base_stream,
- buffer,
- count,
- io_priority,
- cancellable,
- callback,
- data);
-
-}
-
-static gssize
-g_filter_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GFilterOutputStream *filter_stream;
- gssize nwritten;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- nwritten = g_output_stream_write_finish (filter_stream->base_stream,
- result,
- error);
-
- return nwritten;
-}
-
-static void
-g_filter_output_stream_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GFilterOutputStream *filter_stream;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- g_output_stream_flush_async (filter_stream->base_stream,
- io_priority,
- cancellable,
- callback,
- data);
-}
-
-static gboolean
-g_filter_output_stream_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GFilterOutputStream *filter_stream;
- gboolean res;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- res = g_output_stream_flush_finish (filter_stream->base_stream,
- result,
- error);
-
- return res;
-}
-
-static void
-g_filter_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GFilterOutputStream *filter_stream;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- g_output_stream_close_async (filter_stream->base_stream,
- io_priority,
- cancellable,
- callback,
- data);
-}
-
-static gboolean
-g_filter_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GFilterOutputStream *filter_stream;
- gboolean res;
-
- filter_stream = G_FILTER_OUTPUT_STREAM (stream);
-
- res = g_output_stream_close_finish (filter_stream->base_stream,
- result,
- error);
-
- return res;
-}
-
-
-/* vim: ts=2 sw=2 et */
diff --git a/gio/gfilteroutputstream.h b/gio/gfilteroutputstream.h
deleted file mode 100644
index 43014df4..00000000
--- a/gio/gfilteroutputstream.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __G_FILTER_OUTPUT_STREAM_H__
-#define __G_FILTER_OUTPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/goutputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_FILTER_OUTPUT_STREAM (g_filter_output_stream_get_type ())
-#define G_FILTER_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_FILTER_OUTPUT_STREAM, GFilterOutputStream))
-#define G_FILTER_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_FILTER_OUTPUT_STREAM, GFilterOutputStreamClass))
-#define G_IS_FILTER_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_FILTER_OUTPUT_STREAM))
-#define G_IS_FILTER_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_FILTER_OUTPUT_STREAM))
-#define G_FILTER_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_FILTER_OUTPUT_STREAM, GFilterOutputStreamClass))
-
-typedef struct _GFilterOutputStream GFilterOutputStream;
-typedef struct _GFilterOutputStreamClass GFilterOutputStreamClass;
-typedef struct _GFilterOutputStreamPrivate GFilterOutputStreamPrivate;
-
-struct _GFilterOutputStream
-{
- GOutputStream parent;
-
- /*< protected >*/
- GOutputStream *base_stream;
-};
-
-struct _GFilterOutputStreamClass
-{
- GOutputStreamClass parent_class;
-};
-
-
-GType g_filter_output_stream_get_type (void) G_GNUC_CONST;
-GOutputStream *g_filter_output_stream_get_base_stream (GFilterOutputStream *stream);
-G_END_DECLS
-
-#endif /* __G_FILTER_OUTPUT_STREAM_H__ */
diff --git a/gio/gicon.c b/gio/gicon.c
deleted file mode 100644
index 94783b49..00000000
--- a/gio/gicon.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <config.h>
-#include "gicon.h"
-
-#include "giotypes.h"
-#include <glib/gi18n-lib.h>
-
-static void g_icon_base_init (gpointer g_class);
-static void g_icon_class_init (gpointer g_class,
- gpointer class_data);
-
-GType
-g_icon_get_type (void)
-{
- static GType icon_type = 0;
-
- if (! icon_type)
- {
- static const GTypeInfo icon_info =
- {
- sizeof (GIconIface), /* class_size */
- g_icon_base_init, /* base_init */
- NULL, /* base_finalize */
- g_icon_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- icon_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GIcon"),
- &icon_info, 0);
-
- g_type_interface_add_prerequisite (icon_type, G_TYPE_OBJECT);
- }
-
- return icon_type;
-}
-
-static void
-g_icon_class_init (gpointer g_class,
- gpointer class_data)
-{
-}
-
-static void
-g_icon_base_init (gpointer g_class)
-{
-}
-
-guint
-g_icon_hash (gconstpointer icon)
-{
- GIconIface *iface;
-
- iface = G_ICON_GET_IFACE (icon);
-
- return (* iface->hash) ((GIcon *)icon);
-}
-
-gboolean
-g_icon_equal (GIcon *icon1,
- GIcon *icon2)
-{
- GIconIface *iface;
-
- if (G_TYPE_FROM_INSTANCE (icon1) != G_TYPE_FROM_INSTANCE (icon2))
- return FALSE;
-
- iface = G_ICON_GET_IFACE (icon1);
-
- return (* iface->equal) (icon1, icon2);
-}
-
diff --git a/gio/gicon.h b/gio/gicon.h
deleted file mode 100644
index e558ef28..00000000
--- a/gio/gicon.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __G_ICON_H__
-#define __G_ICON_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_ICON (g_icon_get_type ())
-#define G_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ICON, GIcon))
-#define G_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ICON))
-#define G_ICON_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_ICON, GIconIface))
-
-typedef struct _GIcon GIcon; /* Dummy typedef */
-typedef struct _GIconIface GIconIface;
-
-
-struct _GIconIface
-{
- GTypeInterface g_iface;
-
- /* Virtual Table */
-
- guint (*hash) (GIcon *icon);
- gboolean (*equal) (GIcon *icon1,
- GIcon *icon2);
-};
-
-GType g_icon_get_type (void) G_GNUC_CONST;
-
-guint g_icon_hash (gconstpointer icon);
-gboolean g_icon_equal (GIcon *icon1,
- GIcon *icon2);
-
-G_END_DECLS
-
-#endif /* __G_ICON_H__ */
diff --git a/gio/ginputstream.c b/gio/ginputstream.c
deleted file mode 100644
index 25a65765..00000000
--- a/gio/ginputstream.c
+++ /dev/null
@@ -1,1113 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-#include <glib.h>
-
-#include "ginputstream.h"
-#include "gseekable.h"
-#include "gsimpleasyncresult.h"
-
-G_DEFINE_TYPE (GInputStream, g_input_stream, G_TYPE_OBJECT);
-
-struct _GInputStreamPrivate {
- guint closed : 1;
- guint pending : 1;
- GAsyncReadyCallback outstanding_callback;
-};
-
-static gssize g_input_stream_real_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static void g_input_stream_real_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static gssize g_input_stream_real_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_input_stream_real_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_input_stream_real_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_input_stream_real_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_input_stream_real_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-static void
-g_input_stream_finalize (GObject *object)
-{
- GInputStream *stream;
-
- stream = G_INPUT_STREAM (object);
-
- if (!stream->priv->closed)
- g_input_stream_close (stream, NULL, NULL);
-
- if (G_OBJECT_CLASS (g_input_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_input_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_input_stream_dispose (GObject *object)
-{
- GInputStream *stream;
-
- stream = G_INPUT_STREAM (object);
-
- if (!stream->priv->closed)
- g_input_stream_close (stream, NULL, NULL);
-
- if (G_OBJECT_CLASS (g_input_stream_parent_class)->dispose)
- (*G_OBJECT_CLASS (g_input_stream_parent_class)->dispose) (object);
-}
-
-
-static void
-g_input_stream_class_init (GInputStreamClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GInputStreamPrivate));
-
- gobject_class->finalize = g_input_stream_finalize;
- gobject_class->dispose = g_input_stream_dispose;
-
- klass->skip = g_input_stream_real_skip;
- klass->read_async = g_input_stream_real_read_async;
- klass->read_finish = g_input_stream_real_read_finish;
- klass->skip_async = g_input_stream_real_skip_async;
- klass->skip_finish = g_input_stream_real_skip_finish;
- klass->close_async = g_input_stream_real_close_async;
- klass->close_finish = g_input_stream_real_close_finish;
-}
-
-static void
-g_input_stream_init (GInputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_INPUT_STREAM,
- GInputStreamPrivate);
-}
-
-/**
- * g_input_stream_read:
- * @stream: a #GInputStream.
- * @buffer: a buffer to read data into (which should be at least count bytes long).
- * @count: the number of bytes that will be read from the stream
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Tries to read @count bytes from the stream into the buffer starting at
- * @buffer. Will block during this read.
- *
- * If count is zero returns zero and does nothing. A value of @count
- * larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
- *
- * On success, the number of bytes read into the buffer is returned.
- * It is not an error if this is not the same as the requested size, as it
- * can happen e.g. near the end of a file. Zero is returned on end of file
- * (or if @count is zero), but never otherwise.
- *
- * 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. If an
- * operation was partially finished when the operation was cancelled the
- * partial result will be returned, without an error.
- *
- * On error -1 is returned and @error is set accordingly.
- *
- * Return value: Number of bytes read, or -1 on error
- **/
-gssize
-g_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GInputStreamClass *class;
- gssize res;
-
- g_return_val_if_fail (G_IS_INPUT_STREAM (stream), -1);
- g_return_val_if_fail (stream != NULL, -1);
- g_return_val_if_fail (buffer != NULL, 0);
-
- if (count == 0)
- return 0;
-
- if (((gssize) count) < 0)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Too large count value passed to g_input_stream_read"));
- return -1;
- }
-
- if (stream->priv->closed)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return -1;
- }
-
- if (stream->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return -1;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
-
- if (class->read == NULL)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Input stream doesn't implement read"));
- return -1;
- }
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- stream->priv->pending = TRUE;
- res = class->read (stream, buffer, count, cancellable, error);
- stream->priv->pending = FALSE;
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- return res;
-}
-
-/**
- * g_input_stream_read_all:
- * @stream: a #GInputStream.
- * @buffer: a buffer to read data into (which should be at least count bytes long).
- * @count: the number of bytes that will be read from the stream
- * @bytes_read: location to store the number of bytes that was read from the stream
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Tries to read @count bytes from the stream into the buffer starting at
- * @buffer. Will block during this read.
- *
- * This function is similar to g_input_stream_read(), except it tries to
- * read as many bytes as requested, only stopping on an error or end of stream.
- *
- * On a successful read of @count bytes, or if we reached the end of the
- * stream, TRUE is returned, and @bytes_read is set to the number of bytes
- * read into @buffer.
- *
- * If there is an error during the operation FALSE is returned and @error
- * is set to indicate the error status, @bytes_read is updated to contain
- * the number of bytes read into @buffer before the error occured.
- *
- * Return value: TRUE on success, FALSE if there was an error
- **/
-gboolean
-g_input_stream_read_all (GInputStream *stream,
- void *buffer,
- gsize count,
- gsize *bytes_read,
- GCancellable *cancellable,
- GError **error)
-{
- gsize _bytes_read;
- gssize res;
-
- _bytes_read = 0;
- while (_bytes_read < count)
- {
- res = g_input_stream_read (stream, (char *)buffer + _bytes_read, count - _bytes_read,
- cancellable, error);
- if (res == -1)
- {
- *bytes_read = _bytes_read;
- return FALSE;
- }
-
- if (res == 0)
- break;
-
- _bytes_read += res;
- }
-
- *bytes_read = _bytes_read;
- return TRUE;
-}
-
-/**
- * g_input_stream_skip:
- * @stream: a #GInputStream.
- * @count: the number of bytes that will be skipped from the stream
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Tries to skip @count bytes from the stream. Will block during the operation.
- *
- * This is identical to g_input_stream_read(), from a behaviour standpoint,
- * but the bytes that are skipped are not returned to the user. Some
- * streams have an implementation that is more efficient than reading the data.
- *
- * This function is optional for inherited classes, as the default implementation
- * emulates it using read.
- *
- * 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. If an
- * operation was partially finished when the operation was cancelled the
- * partial result will be returned, without an error.
- *
- * Return value: Number of bytes skipped, or -1 on error
- **/
-gssize
-g_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GInputStreamClass *class;
- gssize res;
-
- g_return_val_if_fail (G_IS_INPUT_STREAM (stream), -1);
- g_return_val_if_fail (stream != NULL, -1);
-
- if (count == 0)
- return 0;
-
- if (((gssize) count) < 0)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Too large count value passed to g_input_stream_skip"));
- return -1;
- }
-
- if (stream->priv->closed)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return -1;
- }
-
- if (stream->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return -1;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- stream->priv->pending = TRUE;
- res = class->skip (stream, count, cancellable, error);
- stream->priv->pending = FALSE;
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- return res;
-}
-
-static gssize
-g_input_stream_real_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GInputStreamClass *class;
- gssize ret, read_bytes;
- char buffer[8192];
- GError *my_error;
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
-
- if (G_IS_SEEKABLE (stream) && g_seekable_can_seek (G_SEEKABLE (stream)))
- {
- if (g_seekable_seek (G_SEEKABLE (stream),
- count,
- G_SEEK_CUR,
- cancellable,
- NULL))
- return count;
- }
-
- /* If not seekable, or seek failed, fall back to reading data: */
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
-
- read_bytes = 0;
- while (1)
- {
- my_error = NULL;
-
- ret = class->read (stream, buffer, MIN (sizeof (buffer), count),
- cancellable, &my_error);
- if (ret == -1)
- {
- if (read_bytes > 0 &&
- my_error->domain == G_IO_ERROR &&
- my_error->code == G_IO_ERROR_CANCELLED)
- {
- g_error_free (my_error);
- return read_bytes;
- }
-
- g_propagate_error (error, my_error);
- return -1;
- }
-
- count -= ret;
- read_bytes += ret;
-
- if (ret == 0 || count == 0)
- return read_bytes;
- }
-}
-
-/**
- * g_input_stream_close:
- * @stream: A #GInputStream.
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Closes the stream, releasing resources related to it.
- *
- * Once the stream is closed, all other operations will return %G_IO_ERROR_CLOSED.
- * Closing a stream multiple times will not return an error.
- *
- * Streams will be automatically closed when the last reference
- * is dropped, but you might want to call make sure resources
- * are released as early as possible.
- *
- * Some streams might keep the backing store of the stream (e.g. a file descriptor)
- * open after the stream is closed. See the documentation for the individual
- * stream for details.
- *
- * On failure the first error that happened will be reported, but the close
- * operation will finish as much as possible. A stream that failed to
- * close will still return %G_IO_ERROR_CLOSED all operations. Still, it
- * is important to check and report the error to the user.
- *
- * 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.
- * Cancelling a close will still leave the stream closed, but some streams
- * can use a faster close that doesn't block to e.g. check errors.
- *
- * Return value: %TRUE on success, %FALSE on failure
- **/
-gboolean
-g_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GInputStreamClass *class;
- gboolean res;
-
- g_return_val_if_fail (G_IS_INPUT_STREAM (stream), -1);
- g_return_val_if_fail (stream != NULL, -1);
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
-
- if (stream->priv->closed)
- return TRUE;
-
- if (stream->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return FALSE;
- }
-
- res = TRUE;
-
- stream->priv->pending = TRUE;
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- if (class->close)
- res = class->close (stream, cancellable, error);
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- stream->priv->closed = TRUE;
-
- stream->priv->pending = FALSE;
-
- return res;
-}
-
-static void
-async_ready_callback_wrapper (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GInputStream *stream = G_INPUT_STREAM (source_object);
-
- stream->priv->pending = FALSE;
- (*stream->priv->outstanding_callback) (source_object, res, user_data);
- g_object_unref (stream);
-}
-
-static void
-async_ready_close_callback_wrapper (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GInputStream *stream = G_INPUT_STREAM (source_object);
-
- stream->priv->pending = FALSE;
- stream->priv->closed = TRUE;
- (*stream->priv->outstanding_callback) (source_object, res, user_data);
- g_object_unref (stream);
-}
-
-/**
- * g_input_stream_read_async:
- * @stream: A #GInputStream.
- * @buffer: a buffer to read data into (which should be at least count bytes long).
- * @count: the number of bytes that will be read from the stream
- * @io_priority: the io priority of the request
- * @cancellable: optional cancellable object
- * @callback: callback to call when the request is satisfied
- * @user_data: the data to pass to callback function
- *
- * Request an asynchronous read of @count bytes from the stream into the buffer
- * starting at @buffer. When the operation is finished @callback will be called,
- * giving the results.
- *
- * During an async request no other sync and async calls are allowed, and will
- * result in %G_IO_ERROR_PENDING errors.
- *
- * A value of @count larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
- *
- * On success, the number of bytes read into the buffer will be passed to the
- * callback. It is not an error if this is not the same as the requested size, as it
- * can happen e.g. near the end of a file, but generally we try to read
- * as many bytes as requested. Zero is returned on end of file
- * (or if @count is zero), but never otherwise.
- *
- * Any outstanding i/o request with higher priority (lower numerical value) will
- * be executed before an outstanding request with lower priority. Default
- * priority is %G_PRIORITY_DEFAULT.
- *
- * The asyncronous methods have a default fallback that uses threads to implement
- * asynchronicity, so they are optional for inheriting classes. However, if you
- * override one you must override all.
- **/
-void
-g_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GInputStreamClass *class;
- GSimpleAsyncResult *simple;
-
- g_return_if_fail (G_IS_INPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
- g_return_if_fail (buffer != NULL);
-
- if (count == 0)
- {
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_input_stream_read_async);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- if (((gssize) count) < 0)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Too large count value passed to g_input_stream_read_async"));
- return;
- }
-
- if (stream->priv->closed)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return;
- }
-
- if (stream->priv->pending)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
-
- stream->priv->pending = TRUE;
- stream->priv->outstanding_callback = callback;
- g_object_ref (stream);
- class->read_async (stream, buffer, count, io_priority, cancellable,
- async_ready_callback_wrapper, user_data);
-}
-
-gssize
-g_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- GInputStreamClass *class;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
-
- /* Special case read of 0 bytes */
- if (g_simple_async_result_get_source_tag (simple) == g_input_stream_read_async)
- return 0;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
- return class->read_finish (stream, result, error);
-}
-
-/**
- * g_input_stream_skip_async:
- * @stream: A #GInputStream.
- * @count: the number of bytes that will be skipped from the stream
- * @io_priority: the io priority of the request
- * @cancellable: optional cancellable object
- * @callback: callback to call when the request is satisfied
- * @user_data: the data to pass to callback function
- *
- * Request an asynchronous skip of @count bytes from the stream into the buffer
- * starting at @buffer. When the operation is finished @callback will be called,
- * giving the results.
- *
- * During an async request no other sync and async calls are allowed, and will
- * result in %G_IO_ERROR_PENDING errors.
- *
- * A value of @count larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
- *
- * On success, the number of bytes skipped will be passed to the
- * callback. It is not an error if this is not the same as the requested size, as it
- * can happen e.g. near the end of a file, but generally we try to skip
- * as many bytes as requested. Zero is returned on end of file
- * (or if @count is zero), but never otherwise.
- *
- * Any outstanding i/o request with higher priority (lower numerical value) will
- * be executed before an outstanding request with lower priority. Default
- * priority is %G_PRIORITY_DEFAULT.
- *
- * The asyncronous methods have a default fallback that uses threads to implement
- * asynchronicity, so they are optional for inheriting classes. However, if you
- * override one you must override all.
- **/
-void
-g_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GInputStreamClass *class;
- GSimpleAsyncResult *simple;
-
- g_return_if_fail (G_IS_INPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
-
- if (count == 0)
- {
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_input_stream_skip_async);
-
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- if (((gssize) count) < 0)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Too large count value passed to g_input_stream_skip_async"));
- return;
- }
-
- if (stream->priv->closed)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return;
- }
-
- if (stream->priv->pending)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
- stream->priv->pending = TRUE;
- stream->priv->outstanding_callback = callback;
- g_object_ref (stream);
- class->skip_async (stream, count, io_priority, cancellable,
- async_ready_callback_wrapper, user_data);
-}
-
-gssize
-g_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- GInputStreamClass *class;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
-
- /* Special case skip of 0 bytes */
- if (g_simple_async_result_get_source_tag (simple) == g_input_stream_skip_async)
- return 0;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
- return class->skip_finish (stream, result, error);
-}
-
-/**
- * g_input_stream_close_async:
- * @stream: A #GInputStream.
- * @io_priority: the io priority of the request
- * @cancellable: optional cancellable object
- * @callback: callback to call when the request is satisfied
- * @user_data: the data to pass to callback function
- *
- * Requests an asynchronous closes of the stream, releasing resources related to it.
- * When the operation is finished @callback will be called, giving the results.
- *
- * For behaviour details see g_input_stream_close().
- *
- * The asyncronous methods have a default fallback that uses threads to implement
- * asynchronicity, so they are optional for inheriting classes. However, if you
- * override one you must override all.
- **/
-void
-g_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GInputStreamClass *class;
- GSimpleAsyncResult *simple;
-
- g_return_if_fail (G_IS_INPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
-
- if (stream->priv->closed)
- {
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_input_stream_close_async);
-
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- if (stream->priv->pending)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
- stream->priv->pending = TRUE;
- stream->priv->outstanding_callback = callback;
- g_object_ref (stream);
- class->close_async (stream, io_priority, cancellable,
- async_ready_close_callback_wrapper, user_data);
-}
-
-gboolean
-g_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- GInputStreamClass *class;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- /* Special case already closed */
- if (g_simple_async_result_get_source_tag (simple) == g_input_stream_close_async)
- return TRUE;
- }
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
- return class->close_finish (stream, result, error);
-}
-
-
-gboolean
-g_input_stream_is_closed (GInputStream *stream)
-{
- g_return_val_if_fail (G_IS_INPUT_STREAM (stream), TRUE);
- g_return_val_if_fail (stream != NULL, TRUE);
-
- return stream->priv->closed;
-}
-
-gboolean
-g_input_stream_has_pending (GInputStream *stream)
-{
- g_return_val_if_fail (G_IS_INPUT_STREAM (stream), TRUE);
- g_return_val_if_fail (stream != NULL, TRUE);
-
- return stream->priv->pending;
-}
-
-void
-g_input_stream_set_pending (GInputStream *stream,
- gboolean pending)
-{
- g_return_if_fail (G_IS_INPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
-
- stream->priv->pending = pending;
-}
-
-/********************************************
- * Default implementation of async ops *
- ********************************************/
-
-typedef struct {
- void *buffer;
- gsize count_requested;
- gssize count_read;
-} ReadData;
-
-static void
-read_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- ReadData *op;
- GInputStreamClass *class;
- GError *error = NULL;
-
- op = g_simple_async_result_get_op_res_gpointer (res);
-
- class = G_INPUT_STREAM_GET_CLASS (object);
-
- op->count_read = class->read (G_INPUT_STREAM (object),
- op->buffer, op->count_requested,
- cancellable, &error);
- if (op->count_read == -1)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
-}
-
-static void
-g_input_stream_real_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
- ReadData *op;
-
- op = g_new (ReadData, 1);
- res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_input_stream_real_read_async);
- g_simple_async_result_set_op_res_gpointer (res, op, g_free);
- op->buffer = buffer;
- op->count_requested = count;
-
- g_simple_async_result_run_in_thread (res, read_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static gssize
-g_input_stream_real_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- ReadData *op;
-
- g_assert (g_simple_async_result_get_source_tag (simple) ==
- g_input_stream_real_read_async);
-
- op = g_simple_async_result_get_op_res_gpointer (simple);
-
- return op->count_read;
-}
-
-typedef struct {
- gsize count_requested;
- gssize count_skipped;
-} SkipData;
-
-
-static void
-skip_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- SkipData *op;
- GInputStreamClass *class;
- GError *error = NULL;
-
- class = G_INPUT_STREAM_GET_CLASS (object);
- op = g_simple_async_result_get_op_res_gpointer (res);
- op->count_skipped = class->skip (G_INPUT_STREAM (object),
- op->count_requested,
- cancellable, &error);
- if (op->count_skipped == -1)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
-}
-
-typedef struct {
- char buffer[8192];
- gsize count;
- gsize count_skipped;
- int io_prio;
- GCancellable *cancellable;
- gpointer user_data;
- GAsyncReadyCallback callback;
-} SkipFallbackAsyncData;
-
-static void
-skip_callback_wrapper (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GInputStreamClass *class;
- SkipFallbackAsyncData *data = user_data;
- SkipData *op;
- GSimpleAsyncResult *simple;
- GError *error = NULL;
- gssize ret;
-
- ret = g_input_stream_read_finish (G_INPUT_STREAM (source_object), res, &error);
-
- if (ret > 0)
- {
- data->count -= ret;
- data->count_skipped += ret;
-
- if (data->count > 0)
- {
- class = G_INPUT_STREAM_GET_CLASS (source_object);
- class->read_async (G_INPUT_STREAM (source_object), data->buffer, MIN (8192, data->count), data->io_prio, data->cancellable,
- skip_callback_wrapper, data);
- return;
- }
- }
-
- op = g_new0 (SkipData, 1);
- op->count_skipped = data->count_skipped;
- simple = g_simple_async_result_new (source_object,
- data->callback, data->user_data,
- g_input_stream_real_skip_async);
-
- g_simple_async_result_set_op_res_gpointer (simple, op, g_free);
-
- if (ret == -1)
- {
- if (data->count_skipped &&
- error->domain == G_IO_ERROR &&
- error->code == G_IO_ERROR_CANCELLED)
- { /* No error, return partial read */ }
- else
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
- }
-
- /* Complete immediately, not in idle, since we're already in a mainloop callout */
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-
- g_free (data);
- }
-
-static void
-g_input_stream_real_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GInputStreamClass *class;
- SkipData *op;
- SkipFallbackAsyncData *data;
- GSimpleAsyncResult *res;
-
- class = G_INPUT_STREAM_GET_CLASS (stream);
-
- if (class->read_async == g_input_stream_real_read_async)
- {
- /* Read is thread-using async fallback.
- * Make skip use threads too, so that we can use a possible sync skip
- * implementation. */
- op = g_new0 (SkipData, 1);
-
- res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data,
- g_input_stream_real_skip_async);
-
- g_simple_async_result_set_op_res_gpointer (res, op, g_free);
-
- op->count_requested = count;
-
- g_simple_async_result_run_in_thread (res, skip_async_thread, io_priority, cancellable);
- g_object_unref (res);
- }
- else
- {
- /* TODO: Skip fallback uses too much memory, should do multiple read calls */
-
- /* There is a custom async read function, lets use that. */
- data = g_new (SkipFallbackAsyncData, 1);
- data->count = count;
- data->count_skipped = 0;
- data->io_prio = io_priority;
- data->cancellable = cancellable;
- data->callback = callback;
- data->user_data = user_data;
- class->read_async (stream, data->buffer, MIN (8192, count), io_priority, cancellable,
- skip_callback_wrapper, data);
- }
-
-}
-
-static gssize
-g_input_stream_real_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- SkipData *op;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_skip_async);
- op = g_simple_async_result_get_op_res_gpointer (simple);
- return op->count_skipped;
-}
-
-static void
-close_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GInputStreamClass *class;
- GError *error = NULL;
- gboolean result;
-
- /* Auto handling of cancelation disabled, and ignore
- cancellation, since we want to close things anyway, although
- possibly in a quick-n-dirty way. At least we never want to leak
- open handles */
-
- class = G_INPUT_STREAM_GET_CLASS (object);
- result = class->close (G_INPUT_STREAM (object), cancellable, &error);
- if (!result)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
-}
-
-static void
-g_input_stream_real_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_input_stream_real_close_async);
-
- g_simple_async_result_set_handle_cancellation (res, FALSE);
-
- g_simple_async_result_run_in_thread (res,
- close_async_thread,
- io_priority,
- cancellable);
- g_object_unref (res);
-}
-
-static gboolean
-g_input_stream_real_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- g_assert (g_simple_async_result_get_source_tag (simple) == g_input_stream_real_close_async);
- return TRUE;
-}
diff --git a/gio/ginputstream.h b/gio/ginputstream.h
deleted file mode 100644
index 7f407c31..00000000
--- a/gio/ginputstream.h
+++ /dev/null
@@ -1,144 +0,0 @@
-#ifndef __G_INPUT_STREAM_H__
-#define __G_INPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gioerror.h>
-#include <gio/gcancellable.h>
-#include <gio/gasyncresult.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_INPUT_STREAM (g_input_stream_get_type ())
-#define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream))
-#define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass))
-#define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM))
-#define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM))
-#define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass))
-
-typedef struct _GInputStream GInputStream;
-typedef struct _GInputStreamClass GInputStreamClass;
-typedef struct _GInputStreamPrivate GInputStreamPrivate;
-
-struct _GInputStream
-{
- GObject parent;
-
- /*< private >*/
- GInputStreamPrivate *priv;
-};
-
-struct _GInputStreamClass
-{
- GObjectClass parent_class;
-
- /* Sync ops: */
-
- gssize (* read) (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
- gssize (* skip) (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
- gboolean (* close) (GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-
- /* Async ops: (optional in derived classes) */
- void (* read_async) (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gssize (* read_finish) (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
- void (* skip_async) (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gssize (* skip_finish) (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
- void (* close_async) (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (* close_finish)(GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
- /* Padding for future expansion */
- void (*_g_reserved1) (void);
- void (*_g_reserved2) (void);
- void (*_g_reserved3) (void);
- void (*_g_reserved4) (void);
- void (*_g_reserved5) (void);
-};
-
-GType g_input_stream_get_type (void) G_GNUC_CONST;
-
-gssize g_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-gboolean g_input_stream_read_all (GInputStream *stream,
- void *buffer,
- gsize count,
- gsize *bytes_read,
- GCancellable *cancellable,
- GError **error);
-gssize g_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-gboolean g_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-void g_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gssize g_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-void g_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gssize g_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-void g_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-/* For implementations: */
-
-gboolean g_input_stream_is_closed (GInputStream *stream);
-gboolean g_input_stream_has_pending (GInputStream *stream);
-void g_input_stream_set_pending (GInputStream *stream,
- gboolean pending);
-
-G_END_DECLS
-
-#endif /* __G_INPUT_STREAM_H__ */
diff --git a/gio/gioerror.c b/gio/gioerror.c
deleted file mode 100644
index b6482545..00000000
--- a/gio/gioerror.c
+++ /dev/null
@@ -1,127 +0,0 @@
-#include <config.h>
-#include <errno.h>
-#include "gioerror.h"
-
-/**
- * g_io_error_quark:
- *
- * Return value: The quark used as %G_IO_ERROR
- **/
-GQuark
-g_io_error_quark (void)
-{
- return g_quark_from_static_string ("g-io-error-quark");
-}
-
-GIOErrorEnum
-g_io_error_from_errno (gint err_no)
-{
- switch (err_no)
- {
-#ifdef EEXIST
- case EEXIST:
- return G_IO_ERROR_EXISTS;
- break;
-#endif
-
-#ifdef EISDIR
- case EISDIR:
- return G_IO_ERROR_IS_DIRECTORY;
- break;
-#endif
-
-#ifdef EACCES
- case EACCES:
- return G_IO_ERROR_PERMISSION_DENIED;
- break;
-#endif
-
-#ifdef ENAMETOOLONG
- case ENAMETOOLONG:
- return G_IO_ERROR_FILENAME_TOO_LONG;
- break;
-#endif
-
-#ifdef ENOENT
- case ENOENT:
- return G_IO_ERROR_NOT_FOUND;
- break;
-#endif
-
-#ifdef ENOTDIR
- case ENOTDIR:
- return G_IO_ERROR_NOT_DIRECTORY;
- break;
-#endif
-
-#ifdef EROFS
- case EROFS:
- return G_IO_ERROR_READ_ONLY;
- break;
-#endif
-
-#ifdef ELOOP
- case ELOOP:
- return G_IO_ERROR_TOO_MANY_LINKS;
- break;
-#endif
-
-#ifdef ENOSPC
- case ENOSPC:
- return G_IO_ERROR_NO_SPACE;
- break;
-#endif
-
-#ifdef ENOMEM
- case ENOMEM:
- return G_IO_ERROR_NO_SPACE;
- break;
-#endif
-
-#ifdef EINVAL
- case EINVAL:
- return G_IO_ERROR_INVALID_ARGUMENT;
- break;
-#endif
-
-#ifdef EPERM
- case EPERM:
- return G_IO_ERROR_PERMISSION_DENIED;
- break;
-#endif
-
-#ifdef ECANCELED
- case ECANCELED:
- return G_IO_ERROR_CANCELLED;
- break;
-#endif
-
-#ifdef ENOTEMPTY
- case ENOTEMPTY:
- return G_IO_ERROR_NOT_EMPTY;
- break;
-#endif
-
-#ifdef ENOTSUP
- case ENOTSUP:
- return G_IO_ERROR_NOT_SUPPORTED;
- break;
-#endif
-
-#ifdef ETIMEDOUT
- case ETIMEDOUT:
- return G_IO_ERROR_TIMED_OUT;
- break;
-#endif
-
-#ifdef EBUSY
- case EBUSY:
- return G_IO_ERROR_BUSY;
- break;
-#endif
-
- default:
- return G_IO_ERROR_FAILED;
- break;
- }
-}
diff --git a/gio/gioerror.h b/gio/gioerror.h
deleted file mode 100644
index a4cd2731..00000000
--- a/gio/gioerror.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef __G_IO_ERROR_H__
-#define __G_IO_ERROR_H__
-
-#include <glib/gerror.h>
-
-G_BEGIN_DECLS
-
-GQuark g_io_error_quark (void);
-
-#define G_IO_ERROR g_io_error_quark()
-
-/* This enumeration conflicts with GIOError in giochannel.h. However,
- * that is only used as a return value in some deprecated functions.
- * So, we reuse the same prefix for the enumeration values, but call
- * the actual enumeration (which is rarely used) GIOErrorEnum.
- */
-
-typedef enum
-{
- G_IO_ERROR_FAILED,
- G_IO_ERROR_NOT_FOUND,
- G_IO_ERROR_EXISTS,
- G_IO_ERROR_IS_DIRECTORY,
- G_IO_ERROR_NOT_DIRECTORY,
- G_IO_ERROR_NOT_EMPTY,
- G_IO_ERROR_NOT_REGULAR_FILE,
- G_IO_ERROR_NOT_SYMBOLIC_LINK,
- G_IO_ERROR_NOT_MOUNTABLE,
- G_IO_ERROR_FILENAME_TOO_LONG,
- G_IO_ERROR_INVALID_FILENAME,
- G_IO_ERROR_TOO_MANY_LINKS,
- G_IO_ERROR_NO_SPACE,
- G_IO_ERROR_INVALID_ARGUMENT,
- G_IO_ERROR_PERMISSION_DENIED,
- G_IO_ERROR_NOT_SUPPORTED,
- G_IO_ERROR_NOT_MOUNTED,
- G_IO_ERROR_ALREADY_MOUNTED,
- G_IO_ERROR_CLOSED,
- G_IO_ERROR_CANCELLED,
- G_IO_ERROR_PENDING,
- G_IO_ERROR_READ_ONLY,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- G_IO_ERROR_WRONG_ETAG,
- G_IO_ERROR_TIMED_OUT,
- G_IO_ERROR_WOULD_RECURSE,
- G_IO_ERROR_BUSY,
-} GIOErrorEnum;
-
-GIOErrorEnum g_io_error_from_errno (gint err_no);
-
-#endif /* __G_IO_ERROR_H__ */
diff --git a/gio/giomodule.c b/gio/giomodule.c
deleted file mode 100644
index 304e6dec..00000000
--- a/gio/giomodule.c
+++ /dev/null
@@ -1,208 +0,0 @@
-#include <config.h>
-
-#include "giomodule.h"
-#include <gmodule.h>
-
-struct _GIOModule {
- GTypeModule parent_instance;
-
- gchar *filename;
- GModule *library;
-
- void (* load) (GIOModule *module);
- void (* unload) (GIOModule *module);
-};
-
-struct _GIOModuleClass
-{
- GTypeModuleClass parent_class;
-
-};
-
-static void g_io_module_finalize (GObject *object);
-static gboolean g_io_module_load_module (GTypeModule *gmodule);
-static void g_io_module_unload_module (GTypeModule *gmodule);
-
-G_DEFINE_TYPE (GIOModule, g_io_module, G_TYPE_TYPE_MODULE);
-
-static void
-g_io_module_class_init (GIOModuleClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS (class);
-
- object_class->finalize = g_io_module_finalize;
-
- type_module_class->load = g_io_module_load_module;
- type_module_class->unload = g_io_module_unload_module;
-}
-
-static void
-g_io_module_init (GIOModule *module)
-{
-}
-
-static void
-g_io_module_finalize (GObject *object)
-{
- GIOModule *module = G_IO_MODULE (object);
-
- g_free (module->filename);
-
- G_OBJECT_CLASS (g_io_module_parent_class)->finalize (object);
-}
-
-static gboolean
-g_io_module_load_module (GTypeModule *gmodule)
-{
- GIOModule *module = G_IO_MODULE (gmodule);
-
- if (!module->filename)
- {
- g_warning ("GIOModule path not set");
- return FALSE;
- }
-
- module->library = g_module_open (module->filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
-
- if (!module->library)
- {
- g_printerr ("%s\n", g_module_error ());
- return FALSE;
- }
-
- /* Make sure that the loaded library contains the required methods */
- if (! g_module_symbol (module->library,
- "g_io_module_load",
- (gpointer *) &module->load) ||
- ! g_module_symbol (module->library,
- "g_io_module_unload",
- (gpointer *) &module->unload))
- {
- g_printerr ("%s\n", g_module_error ());
- g_module_close (module->library);
-
- return FALSE;
- }
-
- /* Initialize the loaded module */
- module->load (module);
-
- return TRUE;
-}
-
-static void
-g_io_module_unload_module (GTypeModule *gmodule)
-{
- GIOModule *module = G_IO_MODULE (gmodule);
-
- module->unload (module);
-
- g_module_close (module->library);
- module->library = NULL;
-
- module->load = NULL;
- module->unload = NULL;
-}
-
-GIOModule *
-g_io_module_new (const gchar *filename)
-{
- GIOModule *module;
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- module = g_object_new (G_IO_TYPE_MODULE, NULL);
- module->filename = g_strdup (filename);
-
- return module;
-}
-
-static gboolean
-is_valid_module_name (const gchar *basename)
-{
-#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
- return
- g_str_has_prefix (basename, "lib") &&
- g_str_has_suffix (basename, ".so");
-#else
- return g_str_has_suffix (basename, ".dll");
-#endif
-}
-
-static GList *
-load_modules (const char *dirname)
-{
- const gchar *name;
- GDir *dir;
- GError *error = NULL;
- GList *modules;
-
- if (!g_module_supported ())
- return NULL;
-
- dir = g_dir_open (dirname, 0, &error);
-
- if (!dir)
- {
- g_printerr ("Error while opening module dir: %s\n", error->message);
- g_clear_error (&error);
- return NULL;
- }
-
- modules = NULL;
- while ((name = g_dir_read_name (dir)))
- {
- if (is_valid_module_name (name))
- {
- GIOModule *module;
- gchar *path;
-
- path = g_build_filename (dirname, name, NULL);
- module = g_io_module_new (path);
-
- if (!g_type_module_use (G_TYPE_MODULE (module)))
- {
- g_printerr ("Failed to load module: %s\n", path);
- g_object_unref (module);
- g_free (path);
- continue;
- }
-
- g_free (path);
-
- g_type_module_unuse (G_TYPE_MODULE (module));
-
- modules = g_list_prepend (modules, module);
- }
- }
-
- g_dir_close (dir);
-
- return modules;
-}
-
-G_LOCK_DEFINE_STATIC (loaded_dirs);
-static GHashTable *loaded_dirs = NULL;
-
-void
-g_io_modules_ensure_loaded (const char *directory)
-{
- GList *modules;
-
- G_LOCK (loaded_dirs);
-
- if (loaded_dirs == NULL)
- loaded_dirs = g_hash_table_new (g_str_hash, g_str_equal);
-
- if (!g_hash_table_lookup_extended (loaded_dirs, directory,
- NULL, NULL))
- {
- modules = load_modules (directory);
- g_hash_table_insert (loaded_dirs,
- g_strdup (directory),
- modules);
- }
-
- G_UNLOCK (loaded_dirs);
-}
diff --git a/gio/giomodule.h b/gio/giomodule.h
deleted file mode 100644
index 91398163..00000000
--- a/gio/giomodule.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __G_IO_MODULE_H__
-#define __G_IO_MODULE_H__
-
-#include <glib-object.h>
-#include <gmodule.h>
-
-G_BEGIN_DECLS
-
-#define G_IO_TYPE_MODULE (g_io_module_get_type ())
-#define G_IO_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_IO_TYPE_MODULE, GIOModule))
-#define G_IO_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_IO_TYPE_MODULE, GIOModuleClass))
-#define G_IO_IS_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_IO_TYPE_MODULE))
-#define G_IO_IS_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_IO_TYPE_MODULE))
-#define G_IO_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_IO_TYPE_MODULE, GIOModuleClass))
-
-typedef struct _GIOModule GIOModule;
-typedef struct _GIOModuleClass GIOModuleClass;
-
-GType g_io_module_get_type (void) G_GNUC_CONST;
-GIOModule *g_io_module_new (const gchar *filename);
-
-void g_io_modules_ensure_loaded (const char *directory);
-
-/* API for the modules to implement */
-void g_io_module_load (GIOModule *module);
-void g_io_module_unload (GIOModule *module);
-
-G_END_DECLS
-
-#endif /* __G_IO_MODULE_H__ */
diff --git a/gio/gioscheduler.c b/gio/gioscheduler.c
deleted file mode 100644
index 64d3a205..00000000
--- a/gio/gioscheduler.c
+++ /dev/null
@@ -1,312 +0,0 @@
-#include <config.h>
-
-#include "gioscheduler.h"
-
-struct _GIOJob {
- GSList *active_link;
- GIOJobFunc job_func;
- GIODataFunc cancel_func; /* Runs under job map lock */
- gpointer data;
- GDestroyNotify destroy_notify;
-
- gint io_priority;
- GCancellable *cancellable;
-
- guint idle_tag;
-};
-
-G_LOCK_DEFINE_STATIC(active_jobs);
-static GSList *active_jobs = NULL;
-
-static GThreadPool *job_thread_pool = NULL;
-
-static void io_job_thread (gpointer data,
- gpointer user_data);
-
-static void
-g_io_job_free (GIOJob *job)
-{
- if (job->cancellable)
- g_object_unref (job->cancellable);
- g_free (job);
-}
-
-static gint
-g_io_job_compare (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
-{
- const GIOJob *aa = a;
- const GIOJob *bb = b;
-
- /* Cancelled jobs are set prio == -1, so that
- they are executed as quickly as possible */
-
- /* Lower value => higher priority */
- if (aa->io_priority < bb->io_priority)
- return -1;
- if (aa->io_priority == bb->io_priority)
- return 0;
- return 1;
-}
-
-static gpointer
-init_scheduler (gpointer arg)
-{
- if (job_thread_pool == NULL)
- {
- /* TODO: thread_pool_new can fail */
- job_thread_pool = g_thread_pool_new (io_job_thread,
- NULL,
- 10,
- FALSE,
- NULL);
- g_thread_pool_set_sort_function (job_thread_pool,
- g_io_job_compare,
- NULL);
- }
- return NULL;
-}
-
-static void
-remove_active_job (GIOJob *job)
-{
- GIOJob *other_job;
- GSList *l;
- gboolean resort_jobs;
-
- G_LOCK (active_jobs);
- active_jobs = g_slist_delete_link (active_jobs, job->active_link);
-
- resort_jobs = FALSE;
- for (l = active_jobs; l != NULL; l = l->next)
- {
- other_job = l->data;
- if (other_job->io_priority >= 0 &&
- g_cancellable_is_cancelled (other_job->cancellable))
- {
- other_job->io_priority = -1;
- resort_jobs = TRUE;
- }
- }
- G_UNLOCK (active_jobs);
-
- if (resort_jobs &&
- job_thread_pool != NULL)
- g_thread_pool_set_sort_function (job_thread_pool,
- g_io_job_compare,
- NULL);
-
-}
-
-static void
-io_job_thread (gpointer data,
- gpointer user_data)
-{
- GIOJob *job = data;
-
- if (job->cancellable)
- g_push_current_cancellable (job->cancellable);
- job->job_func (job, job->cancellable, job->data);
- if (job->cancellable)
- g_pop_current_cancellable (job->cancellable);
-
- if (job->destroy_notify)
- job->destroy_notify (job->data);
-
- remove_active_job (job);
- g_io_job_free (job);
-
-}
-
-static gboolean
-run_job_at_idle (gpointer data)
-{
- GIOJob *job = data;
-
- if (job->cancellable)
- g_push_current_cancellable (job->cancellable);
-
- job->job_func (job, job->cancellable, job->data);
-
- if (job->cancellable)
- g_pop_current_cancellable (job->cancellable);
-
- if (job->destroy_notify)
- job->destroy_notify (job->data);
-
- remove_active_job (job);
- g_io_job_free (job);
-
- return FALSE;
-}
-
-void
-g_schedule_io_job (GIOJobFunc job_func,
- gpointer user_data,
- GDestroyNotify notify,
- gint io_priority,
- GCancellable *cancellable)
-{
- static GOnce once_init = G_ONCE_INIT;
- GIOJob *job;
-
- job = g_new0 (GIOJob, 1);
- job->job_func = job_func;
- job->data = user_data;
- job->destroy_notify = notify;
- job->io_priority = io_priority;
-
- if (cancellable)
- job->cancellable = g_object_ref (cancellable);
-
- G_LOCK (active_jobs);
- active_jobs = g_slist_prepend (active_jobs, job);
- job->active_link = active_jobs;
- G_UNLOCK (active_jobs);
-
- if (g_thread_supported())
- {
- g_once (&once_init, init_scheduler, NULL);
- g_thread_pool_push (job_thread_pool, job, NULL);
- }
- else
- {
- /* Threads not availible, instead do the i/o sync inside a
- * low prio idle handler
- */
- job->idle_tag = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE + 1 + io_priority / 10,
- run_job_at_idle,
- job, NULL);
- }
-}
-
-
-/* Only cancels the cancellable jobs */
-void
-g_cancel_all_io_jobs (void)
-{
- GSList *cancellable_list, *l;
-
- G_LOCK (active_jobs);
- cancellable_list = NULL;
- for (l = active_jobs; l != NULL; l = l->next)
- {
- GIOJob *job = l->data;
- if (job->cancellable)
- cancellable_list = g_slist_prepend (cancellable_list,
- g_object_ref (job->cancellable));
- }
- G_UNLOCK (active_jobs);
-
- for (l = cancellable_list; l != NULL; l = l->next)
- {
- GCancellable *c = l->data;
- g_cancellable_cancel (c);
- g_object_unref (c);
- }
- g_slist_free (cancellable_list);
-}
-
-typedef struct {
- GIODataFunc func;
- gpointer data;
- GDestroyNotify notify;
-
- GMutex *ack_lock;
- GCond *ack_condition;
-} MainLoopProxy;
-
-static gboolean
-mainloop_proxy_func (gpointer data)
-{
- MainLoopProxy *proxy = data;
-
- proxy->func (proxy->data);
-
- if (proxy->ack_lock)
- {
- g_mutex_lock (proxy->ack_lock);
- g_cond_signal (proxy->ack_condition);
- g_mutex_unlock (proxy->ack_lock);
- }
-
- return FALSE;
-}
-
-static void
-mainloop_proxy_free (MainLoopProxy *proxy)
-{
- if (proxy->ack_lock)
- {
- g_mutex_free (proxy->ack_lock);
- g_cond_free (proxy->ack_condition);
- }
-
- g_free (proxy);
-}
-
-static void
-mainloop_proxy_notify (gpointer data)
-{
- MainLoopProxy *proxy = data;
-
- if (proxy->notify)
- proxy->notify (proxy->data);
-
- /* If nonblocking we free here, otherwise we free in io thread */
- if (proxy->ack_lock == NULL)
- mainloop_proxy_free (proxy);
-}
-
-void
-g_io_job_send_to_mainloop (GIOJob *job,
- GIODataFunc func,
- gpointer user_data,
- GDestroyNotify notify,
- gboolean block)
-{
- GSource *source;
- MainLoopProxy *proxy;
- guint id;
-
- if (job->idle_tag)
- {
- /* We just immediately re-enter in the case of idles (non-threads)
- * Anything else would just deadlock. If you can't handle this, enable threads.
- */
- func (user_data);
- return;
- }
-
- proxy = g_new0 (MainLoopProxy, 1);
- proxy->func = func;
- proxy->data = user_data;
- proxy->notify = notify;
-
- if (block)
- {
- proxy->ack_lock = g_mutex_new ();
- proxy->ack_condition = g_cond_new ();
- }
-
- source = g_idle_source_new ();
- g_source_set_priority (source, G_PRIORITY_DEFAULT);
-
- g_source_set_callback (source, mainloop_proxy_func, proxy, mainloop_proxy_notify);
-
- if (block)
- g_mutex_lock (proxy->ack_lock);
-
- id = g_source_attach (source, NULL);
- g_source_unref (source);
-
- if (block)
- {
- g_cond_wait (proxy->ack_condition, proxy->ack_lock);
- g_mutex_unlock (proxy->ack_lock);
-
- /* destroy notify didn't free proxy */
- mainloop_proxy_free (proxy);
- }
-}
diff --git a/gio/gioscheduler.h b/gio/gioscheduler.h
deleted file mode 100644
index 1cc00719..00000000
--- a/gio/gioscheduler.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __G_IO_SCHEDULER_H__
-#define __G_IO_SCHEDULER_H__
-
-#include <glib.h>
-#include <gcancellable.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GIOJob GIOJob;
-
-typedef void (*GIOJobFunc) (GIOJob *job,
- GCancellable *cancellable,
- gpointer user_data);
-
-typedef void (*GIODataFunc) (gpointer user_data);
-
-void g_schedule_io_job (GIOJobFunc job_func,
- gpointer user_data,
- GDestroyNotify notify,
- gint io_priority,
- GCancellable *cancellable);
-void g_cancel_all_io_jobs (void);
-
-void g_io_job_send_to_mainloop (GIOJob *job,
- GIODataFunc func,
- gpointer user_data,
- GDestroyNotify notify,
- gboolean block);
-
-
-G_END_DECLS
-
-#endif /* __G_IO_SCHEDULER_H__ */
diff --git a/gio/giotypes.h b/gio/giotypes.h
deleted file mode 100644
index 3d731593..00000000
--- a/gio/giotypes.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __G_IO_TYPES_H__
-#define __G_IO_TYPES_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#define I_(string) g_intern_static_string (string)
-
-G_END_DECLS
-
-#endif /* __G_IO_TYPES_H__ */
diff --git a/gio/gloadableicon.c b/gio/gloadableicon.c
deleted file mode 100644
index 8d5973b3..00000000
--- a/gio/gloadableicon.c
+++ /dev/null
@@ -1,204 +0,0 @@
-#include <config.h>
-
-#include <glib/gi18n-lib.h>
-
-#include "giotypes.h"
-#include "gsimpleasyncresult.h"
-#include "gloadableicon.h"
-
-static void g_loadable_icon_real_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static GInputStream *g_loadable_icon_real_load_finish (GLoadableIcon *icon,
- GAsyncResult *res,
- char **type,
- GError **error);
-static void g_loadable_icon_base_init (gpointer g_class);
-static void g_loadable_icon_class_init (gpointer g_class,
- gpointer class_data);
-
-GType
-g_loadable_icon_get_type (void)
-{
- static GType loadable_icon_type = 0;
-
- if (! loadable_icon_type)
- {
- static const GTypeInfo loadable_icon_info =
- {
- sizeof (GLoadableIconIface), /* class_size */
- g_loadable_icon_base_init, /* base_init */
- NULL, /* base_finalize */
- g_loadable_icon_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- loadable_icon_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GLoadableIcon"),
- &loadable_icon_info, 0);
-
- g_type_interface_add_prerequisite (loadable_icon_type, G_TYPE_ICON);
- }
-
- return loadable_icon_type;
-}
-
-static void
-g_loadable_icon_class_init (gpointer g_class,
- gpointer class_data)
-{
- GLoadableIconIface *iface = g_class;
-
- iface->load_async = g_loadable_icon_real_load_async;
- iface->load_finish = g_loadable_icon_real_load_finish;
-}
-
-static void
-g_loadable_icon_base_init (gpointer g_class)
-{
-}
-
-GInputStream *
-g_loadable_icon_load (GLoadableIcon *icon,
- int size,
- char **type,
- GCancellable *cancellable,
- GError **error)
-{
- GLoadableIconIface *iface;
-
- iface = G_LOADABLE_ICON_GET_IFACE (icon);
-
- return (* iface->load) (icon, size, type, cancellable, error);
-
-}
-
-void
-g_loadable_icon_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GLoadableIconIface *iface;
-
- iface = G_LOADABLE_ICON_GET_IFACE (icon);
-
- (* iface->load_async) (icon, size, cancellable, callback, user_data);
-
-}
-
-GInputStream *
-g_loadable_icon_load_finish (GLoadableIcon *icon,
- GAsyncResult *res,
- char **type,
- GError **error)
-{
- GLoadableIconIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (res))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, error))
- return NULL;
- }
-
- iface = G_LOADABLE_ICON_GET_IFACE (icon);
-
- return (* iface->load_finish) (icon, res, type, error);
-
-}
-
-/********************************************
- * Default implementation of async load *
- ********************************************/
-
-typedef struct {
- int size;
- char *type;
- GInputStream *stream;
-} LoadData;
-
-static void
-load_data_free (LoadData *data)
-{
- if (data->stream)
- g_object_unref (data->stream);
- g_free (data->type);
- g_free (data);
-}
-
-static void
-load_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GLoadableIconIface *iface;
- GInputStream *stream;
- LoadData *data;
- GError *error = NULL;
- char *type = NULL;
-
- data = g_simple_async_result_get_op_res_gpointer (res);
-
- iface = G_LOADABLE_ICON_GET_IFACE (object);
- stream = iface->load (G_LOADABLE_ICON (object), data->size, &type, cancellable, &error);
-
- if (stream == NULL)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
- else
- {
- data->stream = stream;
- data->type = type;
- }
-}
-
-
-
-static void
-g_loadable_icon_real_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
- LoadData *data;
-
- res = g_simple_async_result_new (G_OBJECT (icon), callback, user_data, g_loadable_icon_real_load_async);
- data = g_new0 (LoadData, 1);
- g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify) load_data_free);
- g_simple_async_result_run_in_thread (res, load_async_thread, 0, cancellable);
- g_object_unref (res);
-}
-
-static GInputStream *
-g_loadable_icon_real_load_finish (GLoadableIcon *icon,
- GAsyncResult *res,
- char **type,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- LoadData *data;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_loadable_icon_real_load_async);
-
- data = g_simple_async_result_get_op_res_gpointer (simple);
-
- if (type)
- {
- *type = data->type;
- data->type = NULL;
- }
-
- return g_object_ref (data->stream);
-}
diff --git a/gio/gloadableicon.h b/gio/gloadableicon.h
deleted file mode 100644
index 164d4914..00000000
--- a/gio/gloadableicon.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef __G_LOADABLE_ICON_H__
-#define __G_LOADABLE_ICON_H__
-
-#include <glib-object.h>
-#include <gio/gicon.h>
-#include <gio/ginputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOADABLE_ICON (g_icon_get_type ())
-#define G_LOADABLE_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_LOADABLE_ICON, GLoadableIcon))
-#define G_IS_LOADABLE_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_LOADABLE_ICON))
-#define G_LOADABLE_ICON_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_LOADABLE_ICON, GLoadableIconIface))
-
-typedef struct _GLoadableIcon GLoadableIcon; /* Dummy typedef */
-typedef struct _GLoadableIconIface GLoadableIconIface;
-
-
-struct _GLoadableIconIface
-{
- GTypeInterface g_iface;
-
- /* Virtual Table */
-
- GInputStream * (*load) (GLoadableIcon *icon,
- int size,
- char **type,
- GCancellable *cancellable,
- GError **error);
- void (*load_async) (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- GInputStream * (*load_finish) (GLoadableIcon *icon,
- GAsyncResult *res,
- char **type,
- GError **error);
-};
-
-GType g_loadable_icon_get_type (void) G_GNUC_CONST;
-
-
-GInputStream *g_loadable_icon_load (GLoadableIcon *icon,
- int size,
- char **type,
- GCancellable *cancellable,
- GError **error);
-void g_loadable_icon_load_async (GLoadableIcon *icon,
- int size,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GInputStream *g_loadable_icon_load_finish (GLoadableIcon *icon,
- GAsyncResult *res,
- char **type,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __G_LOADABLE_ICON_H__ */
diff --git a/gio/glocaldirectorymonitor.c b/gio/glocaldirectorymonitor.c
deleted file mode 100644
index 6da85a78..00000000
--- a/gio/glocaldirectorymonitor.c
+++ /dev/null
@@ -1,213 +0,0 @@
-#include <config.h>
-
-#include "glocaldirectorymonitor.h"
-
-#if defined(HAVE_LINUX_INOTIFY_H) || defined(HAVE_SYS_INOTIFY_H)
-#define USE_INOTIFY 1
-#include "inotify/inotify-helper.h"
-#endif
-
-#ifdef HAVE_FAM
-#include "fam/fam-helper.h"
-#endif
-
-#include "gunixmounts.h"
-#include "gdirectorymonitorpriv.h"
-
-static gboolean g_local_directory_monitor_cancel (GDirectoryMonitor* monitor);
-
-typedef enum {
- BACKEND_NONE,
- BACKEND_INOTIFY,
- BACKEND_FAM,
-} LocalMonitorBackend;
-
-struct _GLocalDirectoryMonitor
-{
- GDirectoryMonitor parent_instance;
- gchar *dirname;
- gpointer mount_monitor;
- gboolean was_mounted;
- LocalMonitorBackend active_backend;
- void *private; /* backend stuff goes here */
-};
-
-G_DEFINE_TYPE (GLocalDirectoryMonitor, g_local_directory_monitor, G_TYPE_DIRECTORY_MONITOR)
-
-static void
-g_local_directory_monitor_finalize (GObject* object)
-{
- GLocalDirectoryMonitor* local_monitor;
- local_monitor = G_LOCAL_DIRECTORY_MONITOR (object);
-
- if (local_monitor->dirname)
- g_free (local_monitor->dirname);
-
- if (G_OBJECT_CLASS (g_local_directory_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_local_directory_monitor_parent_class)->finalize) (object);
-}
-
-static void
-g_local_directory_monitor_class_init (GLocalDirectoryMonitorClass* klass)
-{
- GObjectClass* gobject_class = G_OBJECT_CLASS (klass);
- GDirectoryMonitorClass *dir_monitor_class = G_DIRECTORY_MONITOR_CLASS (klass);
-
- gobject_class->finalize = g_local_directory_monitor_finalize;
-
- dir_monitor_class->cancel = g_local_directory_monitor_cancel;
-}
-
-static void
-g_local_directory_monitor_init (GLocalDirectoryMonitor* local_monitor)
-{
- local_monitor->private = NULL;
- local_monitor->dirname = NULL;
-}
-
-static void
-mounts_changed (gpointer user_data)
-{
- GLocalDirectoryMonitor *local_monitor = user_data;
- GUnixMount *mount;
- gboolean is_mounted;
- GFile *file;
-
- /* Emulate unmount detection */
-
- mount = _g_get_unix_mount_at (local_monitor->dirname);
-
- is_mounted = mount != NULL;
-
- if (mount)
- _g_unix_mount_free (mount);
-
- if (local_monitor->was_mounted != is_mounted)
- {
- if (local_monitor->was_mounted && !is_mounted)
- {
- file = g_file_new_for_path (local_monitor->dirname);
- g_directory_monitor_emit_event (G_DIRECTORY_MONITOR (local_monitor),
- file, NULL,
- G_FILE_MONITOR_EVENT_UNMOUNTED);
- g_object_unref (file);
- }
- local_monitor->was_mounted = is_mounted;
- }
-}
-
-GDirectoryMonitor*
-g_local_directory_monitor_new (const char* dirname,
- GFileMonitorFlags flags)
-{
- GLocalDirectoryMonitor* local_monitor;
- LocalMonitorBackend backend;
-
- local_monitor = g_object_new (G_TYPE_LOCAL_DIRECTORY_MONITOR, NULL);
-
- backend = BACKEND_NONE;
-
-#ifdef USE_INOTIFY
- if (backend == BACKEND_NONE)
- {
- inotify_sub* sub;
- if (_ih_startup ())
- {
- sub = _ih_sub_new (dirname, NULL, local_monitor);
- if (sub)
- {
- if (_ih_sub_add (sub))
- {
- local_monitor->private = sub;
- backend = BACKEND_INOTIFY;
- }
- else
- _ih_sub_free (sub);
- }
- }
- }
-#endif
-
-#ifdef HAVE_FAM
- if (backend == BACKEND_NONE)
- {
- fam_sub* sub;
- sub = _fam_sub_add (dirname, TRUE, local_monitor);
- if (sub)
- {
- local_monitor->private = sub;
- backend = BACKEND_FAM;
- }
- }
-#endif
-
- local_monitor->dirname = g_strdup (dirname);
-
- if (backend == BACKEND_NONE)
- {
- g_object_unref (local_monitor);
- return NULL;
- }
-
- if (backend != BACKEND_INOTIFY &&
- ((flags & G_FILE_MONITOR_FLAGS_MONITOR_MOUNTS)))
- {
- GUnixMount *mount;
-
- /* Emulate unmount detection */
-
- mount = _g_get_unix_mount_at (local_monitor->dirname);
-
- local_monitor->was_mounted = mount != NULL;
-
- if (mount)
- _g_unix_mount_free (mount);
-
- local_monitor->mount_monitor = _g_monitor_unix_mounts (NULL, mounts_changed, local_monitor);
-
- }
-
- return G_DIRECTORY_MONITOR (local_monitor);
-}
-
-static gboolean
-g_local_directory_monitor_cancel (GDirectoryMonitor* monitor)
-{
- GLocalDirectoryMonitor *local_monitor = G_LOCAL_DIRECTORY_MONITOR (monitor);
-
-#ifdef USE_INOTIFY
- if (local_monitor->active_backend == BACKEND_INOTIFY)
- {
- inotify_sub* sub = local_monitor->private;
- if (sub)
- {
- _ih_sub_cancel (sub);
- _ih_sub_free (sub);
- local_monitor->private = NULL;
- }
- }
-#endif
-
-#ifdef HAVE_FAM
- if (local_monitor->active_backend == BACKEND_FAM)
- {
- fam_sub* sub = local_monitor->private;
- if (sub)
- {
- if (!_fam_sub_cancel (sub))
- g_warning ("Unexpected error canceling fam monitor");
- _fam_sub_free (sub);
- local_monitor->private = NULL;
- }
- }
-#endif
-
- if (local_monitor->mount_monitor)
- {
- _g_stop_monitoring_unix_mounts (local_monitor->mount_monitor);
- local_monitor->mount_monitor = NULL;
- }
-
- return TRUE;
-}
-
diff --git a/gio/glocaldirectorymonitor.h b/gio/glocaldirectorymonitor.h
deleted file mode 100644
index 3c1680ac..00000000
--- a/gio/glocaldirectorymonitor.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __G_LOCAL_DIRECTORY_MONITOR_H__
-#define __G_LOCAL_DIRECTORY_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/gdirectorymonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOCAL_DIRECTORY_MONITOR (g_local_directory_monitor_get_type ())
-#define G_LOCAL_DIRECTORY_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_LOCAL_DIRECTORY_MONITOR, GLocalDirectoryMonitor))
-#define G_LOCAL_DIRECTORY_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), G_TYPE_LOCAL_DIRECTORY_MONITOR, GLocalDirectoryMonitorClass))
-#define G_IS_LOCAL_DIRECTORY_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_LOCAL_DIRECTORY_MONITOR))
-#define G_IS_LOCAL_DIRECTORY_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_LOCAL_DIRECTORY_MONITOR))
-
-typedef struct _GLocalDirectoryMonitor GLocalDirectoryMonitor;
-typedef struct _GLocalDirectoryMonitorClass GLocalDirectoryMonitorClass;
-
-struct _GLocalDirectoryMonitorClass {
- GDirectoryMonitorClass parent_class;
-};
-
-GType g_local_directory_monitor_get_type (void) G_GNUC_CONST;
-
-GDirectoryMonitor* g_local_directory_monitor_new (const char* dirname,
- GFileMonitorFlags flags);
-
-G_END_DECLS
-
-#endif /* __G_LOCAL_DIRECTORY_MONITOR_H__ */
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
deleted file mode 100644
index f56b3dba..00000000
--- a/gio/glocalfile.c
+++ /dev/null
@@ -1,1550 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#if HAVE_SYS_STATVFS_H
-#include <sys/statvfs.h>
-#endif
-#if HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#elif HAVE_SYS_MOUNT_H
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#include <sys/mount.h>
-#endif
-
-#include "glocalfile.h"
-#include "glocalfileinfo.h"
-#include "glocalfileenumerator.h"
-#include "glocalfileinputstream.h"
-#include "glocalfileoutputstream.h"
-#include "glocaldirectorymonitor.h"
-#include "glocalfilemonitor.h"
-#include <glib/gstdio.h>
-#include <glib/gi18n-lib.h>
-
-static void g_local_file_file_iface_init (GFileIface *iface);
-
-static GFileAttributeInfoList *local_writable_attributes = NULL;
-static GFileAttributeInfoList *local_writable_namespaces = NULL;
-
-struct _GLocalFile
-{
- GObject parent_instance;
-
- char *filename;
-};
-
-G_DEFINE_TYPE_WITH_CODE (GLocalFile, g_local_file, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_FILE,
- g_local_file_file_iface_init))
-
-static void
-g_local_file_finalize (GObject *object)
-{
- GLocalFile *local;
-
- local = G_LOCAL_FILE (object);
-
- g_free (local->filename);
-
- if (G_OBJECT_CLASS (g_local_file_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_local_file_parent_class)->finalize) (object);
-}
-
-static void
-g_local_file_class_init (GLocalFileClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GFileAttributeInfoList *list;
-
- gobject_class->finalize = g_local_file_finalize;
-
- /* Set up attribute lists */
-
- /* Writable attributes: */
-
- list = g_file_attribute_info_list_new ();
-
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_UNIX_MODE,
- G_FILE_ATTRIBUTE_TYPE_UINT32,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
-
-#ifdef HAVE_CHOWN
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_UNIX_UID,
- G_FILE_ATTRIBUTE_TYPE_UINT32,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_UNIX_GID,
- G_FILE_ATTRIBUTE_TYPE_UINT32,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
-#endif
-
-#ifdef HAVE_SYMLINK
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET,
- G_FILE_ATTRIBUTE_TYPE_BYTE_STRING,
- 0);
-#endif
-
-#ifdef HAVE_UTIMES
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_TIME_MODIFIED,
- G_FILE_ATTRIBUTE_TYPE_UINT64,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
- G_FILE_ATTRIBUTE_TYPE_UINT32,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_TIME_ACCESS,
- G_FILE_ATTRIBUTE_TYPE_UINT64,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
- g_file_attribute_info_list_add (list,
- G_FILE_ATTRIBUTE_TIME_ACCESS_USEC,
- G_FILE_ATTRIBUTE_TYPE_UINT32,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
-#endif
-
- local_writable_attributes = list;
-
- /* Writable namespaces: */
-
- list = g_file_attribute_info_list_new ();
-
-#ifdef HAVE_XATTR
- g_file_attribute_info_list_add (list,
- "xattr",
- G_FILE_ATTRIBUTE_TYPE_STRING,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE |
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
- g_file_attribute_info_list_add (list,
- "xattr_sys",
- G_FILE_ATTRIBUTE_TYPE_STRING,
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED);
-#endif
-
- local_writable_namespaces = list;
-}
-
-static void
-g_local_file_init (GLocalFile *local)
-{
-}
-
-
-static char *
-canonicalize_filename (const char *filename)
-{
- char *canon, *start, *p, *q;
- char *cwd;
-
- if (!g_path_is_absolute (filename))
- {
- cwd = g_get_current_dir ();
- canon = g_build_filename (cwd, filename, NULL);
- g_free (cwd);
- }
- else
- canon = g_strdup (filename);
-
- start = (char *)g_path_skip_root (canon);
-
- p = start;
- while (*p != 0)
- {
- if (p[0] == '.' && (p[1] == 0 || G_IS_DIR_SEPARATOR (p[1])))
- {
- memmove (p, p+1, strlen (p+1)+1);
- }
- else if (p[0] == '.' && p[1] == '.' && (p[2] == 0 || G_IS_DIR_SEPARATOR (p[2])))
- {
- q = p + 2;
- /* Skip previous separator */
- p = p - 2;
- if (p < start)
- p = start;
- while (p > start && !G_IS_DIR_SEPARATOR (*p))
- p--;
- if (G_IS_DIR_SEPARATOR (*p))
- *p++ = G_DIR_SEPARATOR;
- memmove (p, q, strlen (q)+1);
- }
- else
- {
- /* Skip until next separator */
- while (*p != 0 && !G_IS_DIR_SEPARATOR (*p))
- p++;
-
- if (*p != 0)
- {
- /* Canonicalize one separator */
- *p++ = G_DIR_SEPARATOR;
- }
- }
-
- /* Remove additional separators */
- q = p;
- while (*q && G_IS_DIR_SEPARATOR (*q))
- q++;
-
- if (p != q)
- memmove (p, q, strlen (q)+1);
- }
-
- /* Remove trailing slashes */
- if (p > start && G_IS_DIR_SEPARATOR (*(p-1)))
- *(p-1) = 0;
-
- return canon;
-}
-
-GFile *
-g_local_file_new (const char *filename)
-{
- GLocalFile *local;
-
- local = g_object_new (G_TYPE_LOCAL_FILE, NULL);
- local->filename = canonicalize_filename (filename);
-
- return G_FILE (local);
-}
-
-static gboolean
-g_local_file_is_native (GFile *file)
-{
- return TRUE;
-}
-
-static char *
-g_local_file_get_basename (GFile *file)
-{
- return g_path_get_basename (G_LOCAL_FILE (file)->filename);
-}
-
-static char *
-g_local_file_get_path (GFile *file)
-{
- return g_strdup (G_LOCAL_FILE (file)->filename);
-}
-
-static char *
-g_local_file_get_uri (GFile *file)
-{
- return g_filename_to_uri (G_LOCAL_FILE (file)->filename, NULL, NULL);
-}
-
-static gboolean
-get_filename_charset (const gchar **filename_charset)
-{
- const gchar **charsets;
- gboolean is_utf8;
-
- is_utf8 = g_get_filename_charsets (&charsets);
-
- if (filename_charset)
- *filename_charset = charsets[0];
-
- return is_utf8;
-}
-
-static gboolean
-name_is_valid_for_display (const char *string,
- gboolean is_valid_utf8)
-{
- char c;
-
- if (!is_valid_utf8 &&
- !g_utf8_validate (string, -1, NULL))
- return FALSE;
-
- while ((c = *string++) != 0)
- {
- if (g_ascii_iscntrl(c))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static char *
-g_local_file_get_parse_name (GFile *file)
-{
- const char *filename;
- char *parse_name;
- const gchar *charset;
- char *utf8_filename;
- char *roundtripped_filename;
- gboolean free_utf8_filename;
- gboolean is_valid_utf8;
-
- filename = G_LOCAL_FILE (file)->filename;
- if (get_filename_charset (&charset))
- {
- utf8_filename = (char *)filename;
- free_utf8_filename = FALSE;
- is_valid_utf8 = FALSE; /* Can't guarantee this */
- }
- else
- {
- utf8_filename = g_convert (filename, -1,
- "UTF-8", charset, NULL, NULL, NULL);
- free_utf8_filename = TRUE;
- is_valid_utf8 = TRUE;
-
- if (utf8_filename != NULL)
- {
- /* Make sure we can roundtrip: */
- roundtripped_filename = g_convert (utf8_filename, -1,
- charset, "UTF-8", NULL, NULL, NULL);
-
- if (roundtripped_filename == NULL ||
- strcmp (utf8_filename, roundtripped_filename) != 0)
- {
- g_free (utf8_filename);
- utf8_filename = NULL;
- }
- }
- }
-
-
- if (utf8_filename != NULL &&
- name_is_valid_for_display (utf8_filename, is_valid_utf8))
- {
- if (free_utf8_filename)
- parse_name = utf8_filename;
- else
- parse_name = g_strdup (utf8_filename);
- }
- else
- {
- parse_name = g_filename_to_uri (filename, NULL, NULL);
- if (free_utf8_filename)
- g_free (utf8_filename);
- }
-
- return parse_name;
-}
-
-static GFile *
-g_local_file_get_parent (GFile *file)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- const char *non_root;
- char *dirname;
- GFile *parent;
-
- /* Check for root */
- non_root = g_path_skip_root (local->filename);
- if (*non_root == 0)
- return NULL;
-
- dirname = g_path_get_dirname (local->filename);
- parent = g_local_file_new (dirname);
- g_free (dirname);
- return parent;
-}
-
-static GFile *
-g_local_file_dup (GFile *file)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
-
- return g_local_file_new (local->filename);
-}
-
-static guint
-g_local_file_hash (GFile *file)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
-
- return g_str_hash (local->filename);
-}
-
-static gboolean
-g_local_file_equal (GFile *file1,
- GFile *file2)
-{
- GLocalFile *local1 = G_LOCAL_FILE (file1);
- GLocalFile *local2 = G_LOCAL_FILE (file2);
-
- return g_str_equal (local1->filename, local2->filename);
-}
-
-static GFile *
-g_local_file_resolve_relative (GFile *file,
- const char *relative_path)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- char *filename;
- GFile *child;
-
- if (g_path_is_absolute (relative_path))
- return g_local_file_new (relative_path);
-
- filename = g_build_filename (local->filename, relative_path, NULL);
- child = g_local_file_new (filename);
- g_free (filename);
-
- return child;
-}
-
-static GFileEnumerator *
-g_local_file_enumerate_children (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- return g_local_file_enumerator_new (local->filename,
- attributes, flags,
- cancellable, error);
-}
-
-static GFile *
-g_local_file_get_child_for_display_name (GFile *file,
- const char *display_name,
- GError **error)
-{
- GFile *parent, *new_file;
- char *basename;
-
- basename = g_filename_from_utf8 (display_name, -1, NULL, NULL, NULL);
- if (basename == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename %s"), display_name);
- return NULL;
- }
-
- parent = g_file_get_parent (file);
- new_file = g_file_get_child (file, basename);
- g_object_unref (parent);
- g_free (basename);
-
- return new_file;
-}
-
-#if HAVE_STATFS
-static const char *
-get_fs_type (long f_type)
-{
-
- /* filesystem ids taken from linux manpage */
- switch (f_type) {
- case 0xadf5:
- return "adfs";
- case 0xADFF:
- return "affs";
- case 0x42465331:
- return "befs";
- case 0x1BADFACE:
- return "bfs";
- case 0xFF534D42:
- return "cifs";
- case 0x73757245:
- return "coda";
- case 0x012FF7B7:
- return "coh";
- case 0x28cd3d45:
- return "cramfs";
- case 0x1373:
- return "devfs";
- case 0x00414A53:
- return "efs";
- case 0x137D:
- return "ext";
- case 0xEF51:
- return "ext2";
- case 0xEF53:
- return "ext3";
- case 0x4244:
- return "hfs";
- case 0xF995E849:
- return "hpfs";
- case 0x958458f6:
- return "hugetlbfs";
- case 0x9660:
- return "isofs";
- case 0x72b6:
- return "jffs2";
- case 0x3153464a:
- return "jfs";
- case 0x137F:
- return "minix";
- case 0x138F:
- return "minix2";
- case 0x2468:
- return "minix2";
- case 0x2478:
- return "minix22";
- case 0x4d44:
- return "msdos";
- case 0x564c:
- return "ncp";
- case 0x6969:
- return "nfs";
- case 0x5346544e:
- return "ntfs";
- case 0x9fa1:
- return "openprom";
- case 0x9fa0:
- return "proc";
- case 0x002f:
- return "qnx4";
- case 0x52654973:
- return "reiserfs";
- case 0x7275:
- return "romfs";
- case 0x517B:
- return "smb";
- case 0x012FF7B6:
- return "sysv2";
- case 0x012FF7B5:
- return "sysv4";
- case 0x01021994:
- return "tmpfs";
- case 0x15013346:
- return "udf";
- case 0x00011954:
- return "ufs";
- case 0x9fa2:
- return "usbdevice";
- case 0xa501FCF5:
- return "vxfs";
- case 0x012FF7B4:
- return "xenix";
- case 0x58465342:
- return "xfs";
- case 0x012FD16D:
- return "xiafs";
- default:
- return NULL;
- }
-}
-#endif
-
-static GFileInfo *
-g_local_file_get_filesystem_info (GFile *file,
- const char *attributes,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- GFileInfo *info;
- int statfs_result;
- gboolean no_size;
- guint64 block_size;
-#if HAVE_STATFS
- struct statfs statfs_buffer;
- const char *fstype;
-#elif HAVE_STATVFS
- struct statvfs statfs_buffer;
-#endif
- GFileAttributeMatcher *attribute_matcher;
-
- no_size = FALSE;
-
-#if HAVE_STATFS
-
-#if STATFS_ARGS == 2
- statfs_result = statfs (local->filename, &statfs_buffer);
-#elif STATFS_ARGS == 4
- statfs_result = statfs (local->filename, &statfs_buffer,
- sizeof (statfs_buffer), 0);
-#endif
- block_size = statfs_buffer.f_bsize;
-
-#if defined(__linux__)
- /* ncpfs does not know the amount of available and free space *
- * assuming ncpfs is linux specific, if you are on a non-linux platform
- * where ncpfs is available, please file a bug about it on bugzilla.gnome.org
- */
- if (statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0 &&
- /* linux/ncp_fs.h: NCP_SUPER_MAGIC == 0x564c */
- statfs_buffer.f_type == 0x564c)
- no_size = TRUE;
-#endif
-
-#elif HAVE_STATVFS
- statfs_result = statvfs (unescaped_path, &statfs_buffer);
- block_size = statfs_buffer.f_frsize;
-#endif
-
- if (statfs_result == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error getting filesystem info: %s"),
- g_strerror (errno));
- return NULL;
- }
-
- info = g_file_info_new ();
-
- attribute_matcher = g_file_attribute_matcher_new (attributes);
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_FS_FREE))
- g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FS_FREE, block_size * statfs_buffer.f_bavail);
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_FS_SIZE))
- g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FS_SIZE, block_size * statfs_buffer.f_blocks);
-
-#if HAVE_STATFS
- fstype = get_fs_type (statfs_buffer.f_type);
- if (fstype &&
- g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_FS_TYPE))
- g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_FS_TYPE, fstype);
-#endif
-
- g_file_attribute_matcher_unref (attribute_matcher);
-
- return info;
-}
-
-static GFile *
-g_local_file_set_display_name (GFile *file,
- const char *display_name,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local, *new_local;
- GFile *new_file;
- struct stat statbuf;
- int errsv;
-
- new_file = g_file_get_child_for_display_name (file, display_name, error);
- if (new_file == NULL)
- return NULL;
-
- local = G_LOCAL_FILE (file);
- new_local = G_LOCAL_FILE (new_file);
-
- if (!(g_stat (new_local->filename, &statbuf) == -1 &&
- errno == ENOENT))
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_EXISTS,
- _("Can't rename file, filename already exist"));
- return NULL;
- }
-
- if (rename (local->filename, new_local->filename) == -1)
- {
- errsv = errno;
-
- if (errsv == EINVAL)
- /* We can't get a rename file into itself error herer,
- so this must be an invalid filename, on e.g. FAT */
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename"));
- else
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error renaming file: %s"),
- g_strerror (errsv));
- g_object_unref (new_file);
- return NULL;
- }
-
- return new_file;
-}
-
-static GFileInfo *
-g_local_file_get_info (GFile *file,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- GFileInfo *info;
- GFileAttributeMatcher *matcher;
- char *basename, *dirname;
- GLocalParentFileInfo parent_info;
-
- matcher = g_file_attribute_matcher_new (attributes);
-
- basename = g_path_get_basename (local->filename);
-
- dirname = g_path_get_dirname (local->filename);
- _g_local_file_info_get_parent_info (dirname, matcher, &parent_info);
- g_free (dirname);
-
- info = _g_local_file_info_get (basename, local->filename,
- matcher, flags, &parent_info,
- error);
-
- g_free (basename);
-
- g_file_attribute_matcher_unref (matcher);
-
- return info;
-}
-
-static GFileAttributeInfoList *
-g_local_file_query_settable_attributes (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- return g_file_attribute_info_list_ref (local_writable_attributes);
-}
-
-static GFileAttributeInfoList *
-g_local_file_query_writable_namespaces (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- return g_file_attribute_info_list_ref (local_writable_namespaces);
-}
-
-static gboolean
-g_local_file_set_attribute (GFile *file,
- const char *attribute,
- const GFileAttributeValue *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
-
- return _g_local_file_info_set_attribute (local->filename,
- attribute,
- value,
- flags,
- cancellable,
- error);
-}
-
-static gboolean
-g_local_file_set_attributes_from_info (GFile *file,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- int res, chained_res;
- GFileIface* default_iface;
-
- res = _g_local_file_info_set_attributes (local->filename,
- info, flags,
- cancellable,
- error);
-
- if (!res)
- error = NULL; /* Don't write over error if further errors */
-
- default_iface = g_type_default_interface_peek (G_TYPE_FILE);
-
- chained_res = (default_iface->set_attributes_from_info) (file, info, flags, cancellable, error);
-
- return res && chained_res;
-}
-
-static GFileInputStream *
-g_local_file_read (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- int fd;
- struct stat buf;
-
- fd = g_open (local->filename, O_RDONLY, 0);
- if (fd == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error opening file: %s"),
- g_strerror (errno));
- return NULL;
- }
-
- if (fstat(fd, &buf) == 0 && S_ISDIR (buf.st_mode))
- {
- close (fd);
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_IS_DIRECTORY,
- _("Can't open directory"));
- return NULL;
- }
-
- return g_local_file_input_stream_new (fd);
-}
-
-static GFileOutputStream *
-g_local_file_append_to (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- return g_local_file_output_stream_append (G_LOCAL_FILE (file)->filename,
- cancellable, error);
-}
-
-static GFileOutputStream *
-g_local_file_create (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- return g_local_file_output_stream_create (G_LOCAL_FILE (file)->filename,
- cancellable, error);
-}
-
-static GFileOutputStream *
-g_local_file_replace (GFile *file,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GError **error)
-{
- return g_local_file_output_stream_replace (G_LOCAL_FILE (file)->filename,
- etag, make_backup,
- cancellable, error);
-}
-
-
-static gboolean
-g_local_file_delete (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
-
- if (g_remove (local->filename) == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error removing file: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-static char *
-strip_trailing_slashes (const char *path)
-{
- char *path_copy;
- int len;
-
- path_copy = g_strdup (path);
- len = strlen (path_copy);
- while (len > 1 && path_copy[len-1] == '/')
- path_copy[--len] = 0;
-
- return path_copy;
- }
-
-static char *
-expand_symlink (const char *link)
-{
- char *resolved, *canonical, *parent, *link2;
- char symlink_value[4096];
- ssize_t res;
-
- res = readlink (link, symlink_value, sizeof (symlink_value) - 1);
- if (res == -1)
- return g_strdup (link);
- symlink_value[res] = 0;
-
- if (g_path_is_absolute (symlink_value))
- return canonicalize_filename (symlink_value);
- else
- {
- link2 = strip_trailing_slashes (link);
- parent = g_path_get_dirname (link2);
- g_free (link2);
-
- resolved = g_build_filename (parent, symlink_value, NULL);
- g_free (parent);
-
- canonical = canonicalize_filename (resolved);
-
- g_free (resolved);
-
- return canonical;
- }
-}
-
-static char *
-get_parent (const char *path, dev_t *parent_dev)
-{
- char *parent, *tmp;
- struct stat parent_stat;
- int num_recursions;
- char *path_copy;
-
- path_copy = strip_trailing_slashes (path);
-
- parent = g_path_get_dirname (path_copy);
- if (strcmp (parent, ".") == 0 ||
- strcmp (parent, path_copy) == 0)
- {
- g_free (path_copy);
- return NULL;
- }
- g_free (path_copy);
-
- num_recursions = 0;
- do {
- if (g_lstat (parent, &parent_stat) != 0)
- {
- g_free (parent);
- return NULL;
- }
-
- if (S_ISLNK (parent_stat.st_mode))
- {
- tmp = parent;
- parent = expand_symlink (parent);
- g_free (tmp);
- }
-
- num_recursions++;
- if (num_recursions > 12)
- {
- g_free (parent);
- return NULL;
- }
- } while (S_ISLNK (parent_stat.st_mode));
-
- *parent_dev = parent_stat.st_dev;
-
- return parent;
-}
-
-static char *
-expand_all_symlinks (const char *path)
-{
- char *parent, *parent_expanded;
- char *basename, *res;
- dev_t parent_dev;
-
- parent = get_parent (path, &parent_dev);
- if (parent)
- {
- parent_expanded = expand_all_symlinks (parent);
- g_free (parent);
- basename = g_path_get_basename (path);
- res = g_build_filename (parent_expanded, basename, NULL);
- g_free (basename);
- g_free (parent_expanded);
- }
- else
- res = g_strdup (path);
-
- return res;
-}
-
-static char *
-find_topdir_for (char *file)
-{
- char *dir, *parent;
- dev_t dir_dev, parent_dev;
-
- dir = get_parent (file, &dir_dev);
- if (dir == NULL)
- return NULL;
-
- while (1) {
- parent = get_parent (dir, &parent_dev);
- if (parent == NULL)
- return dir;
-
- if (parent_dev != dir_dev)
- {
- g_free (parent);
- return dir;
- }
-
- g_free (dir);
- dir = parent;
- }
-}
-
-static char *
-get_unique_filename (const char *basename, int id)
-{
- const char *dot;
-
- if (id == 1)
- return g_strdup (basename);
-
- dot = strchr (basename, '.');
- if (dot)
- return g_strdup_printf ("%.*s.%d%s", dot - basename, basename, id, dot);
- else
- return g_strdup_printf ("%s.%d", basename, id);
-}
-
-static gboolean
-path_has_prefix (const char *path, const char *prefix)
-{
- int prefix_len;
-
- if (prefix == NULL)
- return TRUE;
-
- prefix_len = strlen (prefix);
-
- if (strncmp (path, prefix, prefix_len) == 0 &&
- (prefix_len == 0 || /* empty prefix always matches */
- prefix[prefix_len - 1] == '/' || /* last char in prefix was a /, so it must be in path too */
- path[prefix_len] == 0 ||
- path[prefix_len] == '/'))
- return TRUE;
-
- return FALSE;
-}
-
-static char *
-try_make_relative (const char *path, const char *base)
-{
- char *path2, *base2;
- char *relative;
-
- path2 = expand_all_symlinks (path);
- base2 = expand_all_symlinks (base);
-
- relative = NULL;
- if (path_has_prefix (path2, base2))
- {
- relative = path2 + strlen (base2);
- while (*relative == '/')
- relative ++;
- relative = g_strdup (relative);
- }
- g_free (path2);
- g_free (base2);
-
- if (relative)
- return relative;
-
- /* Failed, use abs path */
- return g_strdup (path);
-}
-
-static char *
-escape_trash_name (char *name)
-{
- GString *str;
- const gchar hex[16] = "0123456789ABCDEF";
-
- str = g_string_new ("");
-
- while (*name != 0)
- {
- char c;
-
- c = *name++;
-
- if (g_ascii_isprint (c))
- g_string_append_c (str, c);
- else
- {
- g_string_append_c (str, '%');
- g_string_append_c (str, hex[((guchar)c) >> 4]);
- g_string_append_c (str, hex[((guchar)c) & 0xf]);
- }
- }
-
- return g_string_free (str, FALSE);
-}
-
-static gboolean
-g_local_file_trash (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
- struct stat file_stat, home_stat, trash_stat, global_stat;
- const char *homedir;
- char *dirname;
- char *trashdir, *globaldir, *topdir, *infodir, *filesdir;
- char *basename, *trashname, *trashfile, *infoname, *infofile;
- char *original_name, *original_name_escaped;
- uid_t uid;
- char uid_str[32];
- int i;
- char *data;
- gboolean is_homedir_trash;
- time_t t;
- struct tm now;
- char delete_time[32];
- int fd;
-
- if (g_lstat (local->filename, &file_stat) != 0)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error trashing file: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- homedir = g_get_home_dir ();
- g_stat (homedir, &home_stat);
-
- is_homedir_trash = FALSE;
- trashdir = NULL;
- if (file_stat.st_dev == home_stat.st_dev)
- {
- is_homedir_trash = TRUE;
- trashdir = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
- if (g_mkdir (trashdir, 0755) == -1 && errno != EEXIST)
- {
- g_free (trashdir);
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_FAILED,
- _("Unable to create trash dir %s"),
- trashdir);
- return FALSE;
- }
- topdir = g_strdup (g_get_user_data_dir ());
- }
- else
- {
- uid = geteuid ();
- snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
-
- topdir = find_topdir_for (local->filename);
- if (topdir == NULL)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Unable to find toplevel directory for trash"));
- return FALSE;
- }
-
- /* Try looking for global trash dir $topdir/.Trash/$uid */
- globaldir = g_build_filename (topdir, ".Trash", NULL);
- if (g_lstat (globaldir, &global_stat) == 0 &&
- S_ISDIR (global_stat.st_mode) &&
- (global_stat.st_mode & S_ISVTX) != 0)
- {
- trashdir = g_build_filename (globaldir, uid_str, NULL);
-
- if (g_lstat (trashdir, &trash_stat) == 0)
- {
- if (!S_ISDIR (trash_stat.st_mode) ||
- trash_stat.st_uid != uid)
- {
- /* Not a directory or not owned by user, ignore */
- g_free (trashdir);
- trashdir = NULL;
- }
- }
- else if (g_mkdir (trashdir, 0700) == -1)
- {
- g_free (trashdir);
- trashdir = NULL;
- }
- }
- g_free (globaldir);
-
- if (trashdir == NULL)
- {
- /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
- dirname = g_strdup_printf (".Trash-%s", uid_str);
- trashdir = g_build_filename (topdir, dirname, NULL);
- g_free (dirname);
-
- if (g_lstat (trashdir, &trash_stat) == 0)
- {
- if (!S_ISDIR (trash_stat.st_mode) ||
- trash_stat.st_uid != uid)
- {
- /* Not a directory or not owned by user, ignore */
- g_free (trashdir);
- trashdir = NULL;
- }
- }
- else if (g_mkdir (trashdir, 0700) == -1)
- {
- g_free (trashdir);
- trashdir = NULL;
- }
- }
-
- if (trashdir == NULL)
- {
- g_free (topdir);
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Unable to find or create trash directory"));
- return FALSE;
- }
- }
-
- /* Trashdir points to the trash dir with the "info" and "files" subdirectories */
-
- infodir = g_build_filename (trashdir, "info", NULL);
- filesdir = g_build_filename (trashdir, "files", NULL);
- g_free (trashdir);
-
- /* Make sure we have the subdirectories */
- if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
- (g_mkdir (filesdir, 0700) == -1 && errno != EEXIST))
- {
- g_free (topdir);
- g_free (infodir);
- g_free (filesdir);
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Unable to find or create trash directory"));
- return FALSE;
- }
-
- basename = g_path_get_basename (local->filename);
- i = 1;
- trashname = NULL;
- trashfile = NULL;
- do {
- g_free (trashname);
- g_free (trashfile);
-
- trashname = get_unique_filename (basename, i++);
- trashfile = g_build_filename (filesdir, trashname, NULL);
-
- fd = open (trashfile, O_CREAT | O_EXCL, 0666);
- } while (fd == -1 && errno == EEXIST);
-
- g_free (filesdir);
-
- if (fd == -1)
- {
- g_free (topdir);
- g_free (infodir);
- g_free (trashname);
- g_free (trashfile);
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Unable to create trashed file: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- close (fd);
-
- /* TODO: Maybe we should verify that you can delete the file from the trash
- before moving it? OTOH, that is hard, as it needs a recursive scan */
-
- if (g_rename (local->filename, trashfile) == -1)
- {
- g_free (topdir);
- g_free (infodir);
- g_free (trashname);
- g_free (trashfile);
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Unable to trash file: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- g_free (trashfile);
-
- /* TODO: Do we need to update mtime/atime here after the move? */
-
- /* Use absolute names for homedir */
- if (is_homedir_trash)
- original_name = g_strdup (local->filename);
- else
- original_name = try_make_relative (local->filename, topdir);
- original_name_escaped = escape_trash_name (original_name);
-
- g_free (original_name);
- g_free (topdir);
-
- t = time (NULL);
- localtime_r (&t, &now);
- delete_time[0] = 0;
- strftime(delete_time, sizeof (delete_time), "%Y-%m-%dT%H:%M:%S", &now);
-
- data = g_strdup_printf ("[Trash Info]\nPath=%s\nDeletionDate=%s\n",
- original_name_escaped, delete_time);
-
- infoname = g_strconcat (trashname, ".trashinfo", NULL);
- infofile = g_build_filename (infodir, infoname, NULL);
- g_free (infoname);
- g_file_set_contents (infofile, data, -1, NULL);
-
- g_free (original_name_escaped);
-
- return TRUE;
-}
-
-static gboolean
-g_local_file_make_directory (GFile *file,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFile *local = G_LOCAL_FILE (file);
-
- if (g_mkdir (local->filename, 0755) == -1)
- {
- int errsv = errno;
-
- if (errsv == EINVAL)
- /* This must be an invalid filename, on e.g. FAT */
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename"));
- else
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error removing file: %s"),
- g_strerror (errsv));
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-g_local_file_make_symbolic_link (GFile *file,
- const char *symlink_value,
- GCancellable *cancellable,
- GError **error)
-{
-#ifdef HAVE_SYMLINK
- GLocalFile *local = G_LOCAL_FILE (file);
-
- if (symlink (symlink_value, local->filename) == -1)
- {
- int errsv = errno;
-
- if (errsv == EINVAL)
- /* This must be an invalid filename, on e.g. FAT */
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename"));
- else
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error making symbolic link: %s"),
- g_strerror (errsv));
- return FALSE;
- }
- return TRUE;
-#else
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symlinks not supported");
- return FALSE;
-#endif
-}
-
-
-static gboolean
-g_local_file_copy (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error)
-{
- /* Fall back to default copy */
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Copy not supported");
- return FALSE;
-}
-
-static gboolean
-g_local_file_move (GFile *source,
- GFile *destination,
- GFileCopyFlags flags,
- GCancellable *cancellable,
- GFileProgressCallback progress_callback,
- gpointer progress_callback_data,
- GError **error)
-{
- GLocalFile *local_source = G_LOCAL_FILE (source);
- GLocalFile *local_destination = G_LOCAL_FILE (destination);
- struct stat statbuf;
- gboolean destination_exist, source_is_dir;
- char *backup_name;
- int res;
-
- res = g_lstat (local_source->filename, &statbuf);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error moving file: %s"),
- g_strerror (errno));
- return FALSE;
- }
- else
- source_is_dir = S_ISDIR (statbuf.st_mode);
-
- destination_exist = FALSE;
- res = g_lstat (local_destination->filename, &statbuf);
- if (res == 0)
- {
- destination_exist = TRUE; /* Target file exists */
-
- if (flags & G_FILE_COPY_OVERWRITE)
- {
- /* Always fail on dirs, even with overwrite */
- if (S_ISDIR (statbuf.st_mode))
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_IS_DIRECTORY,
- _("Can't move over directory"));
- return FALSE;
- }
- }
- else
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_EXISTS,
- _("Target file already exists"));
- return FALSE;
- }
- }
-
- if (flags & G_FILE_COPY_BACKUP && destination_exist)
- {
- backup_name = g_strconcat (local_destination->filename, "~", NULL);
- if (rename (local_destination->filename, backup_name) == -1)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Backup file creation failed"));
- g_free (backup_name);
- return FALSE;
- }
- g_free (backup_name);
- destination_exist = FALSE; /* It did, but no more */
- }
-
- if (source_is_dir && destination_exist && (flags & G_FILE_COPY_OVERWRITE))
- {
- /* Source is a dir, destination exists (and is not a dir, because that would have failed
- earlier), and we're overwriting. Manually remove the target so we can do the rename. */
- res = unlink (local_destination->filename);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error removing target file: %s"),
- g_strerror (errno));
- return FALSE;
- }
- }
-
- if (rename (local_source->filename, local_destination->filename) == -1)
- {
- int errsv = errno;
- if (errsv == EXDEV)
- goto fallback;
-
- if (errsv == EINVAL)
- /* This must be an invalid filename, on e.g. FAT, or
- we're trying to move the file into itself...
- We return invalid filename for both... */
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename"));
- else
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error moving file: %s"),
- g_strerror (errsv));
- return FALSE;
-
- }
- return TRUE;
-
- fallback:
-
- if (!g_file_copy (source, destination, G_FILE_COPY_OVERWRITE | G_FILE_COPY_ALL_METADATA, cancellable,
- progress_callback, progress_callback_data,
- error))
- return FALSE;
-
- return g_file_delete (source, cancellable, error);
-}
-
-
-static GDirectoryMonitor*
-g_local_file_monitor_dir (GFile* file,
- GFileMonitorFlags flags)
-{
- GLocalFile* local_file = G_LOCAL_FILE(file);
- return g_local_directory_monitor_new (local_file->filename, flags);
-}
-
-static GFileMonitor*
-g_local_file_monitor_file (GFile* file,
- GFileMonitorFlags flags)
-{
- GLocalFile* local_file = G_LOCAL_FILE(file);
- GFileMonitor *monitor;
- GFileIface* default_iface;
-
- monitor = g_local_file_monitor_new (local_file->filename, flags);
-
- if (monitor)
- return monitor;
-
- default_iface = g_type_default_interface_peek (G_TYPE_FILE);
-
- return (default_iface->monitor_file) (file, flags);
-}
-
-static void
-g_local_file_file_iface_init (GFileIface *iface)
-{
- iface->dup = g_local_file_dup;
- iface->hash = g_local_file_hash;
- iface->equal = g_local_file_equal;
- iface->is_native = g_local_file_is_native;
- iface->get_basename = g_local_file_get_basename;
- iface->get_path = g_local_file_get_path;
- iface->get_uri = g_local_file_get_uri;
- iface->get_parse_name = g_local_file_get_parse_name;
- iface->get_parent = g_local_file_get_parent;
- iface->resolve_relative = g_local_file_resolve_relative;
- iface->get_child_for_display_name = g_local_file_get_child_for_display_name;
- iface->set_display_name = g_local_file_set_display_name;
- iface->enumerate_children = g_local_file_enumerate_children;
- iface->get_info = g_local_file_get_info;
- iface->get_filesystem_info = g_local_file_get_filesystem_info;
- iface->query_settable_attributes = g_local_file_query_settable_attributes;
- iface->query_writable_namespaces = g_local_file_query_writable_namespaces;
- iface->set_attribute = g_local_file_set_attribute;
- iface->set_attributes_from_info = g_local_file_set_attributes_from_info;
- iface->read = g_local_file_read;
- iface->append_to = g_local_file_append_to;
- iface->create = g_local_file_create;
- iface->replace = g_local_file_replace;
- iface->delete_file = g_local_file_delete;
- iface->trash = g_local_file_trash;
- iface->make_directory = g_local_file_make_directory;
- iface->make_symbolic_link = g_local_file_make_symbolic_link;
- iface->copy = g_local_file_copy;
- iface->move = g_local_file_move;
- iface->monitor_dir = g_local_file_monitor_dir;
- iface->monitor_file = g_local_file_monitor_file;
-}
diff --git a/gio/glocalfile.h b/gio/glocalfile.h
deleted file mode 100644
index 209d640c..00000000
--- a/gio/glocalfile.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __G_LOCAL_FILE_H__
-#define __G_LOCAL_FILE_H__
-
-#include <gio/gfile.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOCAL_FILE (g_local_file_get_type ())
-#define G_LOCAL_FILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_LOCAL_FILE, GLocalFile))
-#define G_LOCAL_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_LOCAL_FILE, GLocalFileClass))
-#define G_IS_LOCAL_FILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_LOCAL_FILE))
-#define G_IS_LOCAL_FILE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_LOCAL_FILE))
-#define G_LOCAL_FILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_LOCAL_FILE, GLocalFileClass))
-
-typedef struct _GLocalFile GLocalFile;
-typedef struct _GLocalFileClass GLocalFileClass;
-
-struct _GLocalFileClass
-{
- GObjectClass parent_class;
-};
-
-GType g_local_file_get_type (void) G_GNUC_CONST;
-
-GFile * g_local_file_new (const char *filename);
-
-G_END_DECLS
-
-#endif /* __G_LOCAL_FILE_H__ */
diff --git a/gio/glocalfileenumerator.c b/gio/glocalfileenumerator.c
deleted file mode 100644
index 8ab27dac..00000000
--- a/gio/glocalfileenumerator.c
+++ /dev/null
@@ -1,168 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glocalfileenumerator.h>
-#include <glocalfileinfo.h>
-
- /* TODO:
- * It would be nice to use the dirent->d_type to check file type without
- * needing to stat each files on linux and other systems that support it.
- * (question: does that following symlink or not?)
- */
-
-
-struct _GLocalFileEnumerator
-{
- GFileEnumerator parent;
-
- GFileAttributeMatcher *matcher;
- GDir *dir;
- char *filename;
- char *attributes;
- GFileGetInfoFlags flags;
-
- gboolean got_parent_info;
- GLocalParentFileInfo parent_info;
-
- gboolean follow_symlinks;
-};
-
-G_DEFINE_TYPE (GLocalFileEnumerator, g_local_file_enumerator, G_TYPE_FILE_ENUMERATOR);
-
-static GFileInfo *g_local_file_enumerator_next_file (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_local_file_enumerator_stop (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error);
-
-
-static void
-g_local_file_enumerator_finalize (GObject *object)
-{
- GLocalFileEnumerator *local;
-
- local = G_LOCAL_FILE_ENUMERATOR (object);
-
- g_free (local->filename);
- g_file_attribute_matcher_unref (local->matcher);
- if (local->dir)
- {
- g_dir_close (local->dir);
- local->dir = NULL;
- }
-
- if (G_OBJECT_CLASS (g_local_file_enumerator_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_local_file_enumerator_parent_class)->finalize) (object);
-}
-
-
-static void
-g_local_file_enumerator_class_init (GLocalFileEnumeratorClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GFileEnumeratorClass *enumerator_class = G_FILE_ENUMERATOR_CLASS (klass);
-
- gobject_class->finalize = g_local_file_enumerator_finalize;
-
- enumerator_class->next_file = g_local_file_enumerator_next_file;
- enumerator_class->stop = g_local_file_enumerator_stop;
-}
-
-static void
-g_local_file_enumerator_init (GLocalFileEnumerator *local)
-{
-}
-
-GFileEnumerator *
-g_local_file_enumerator_new (const char *filename,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileEnumerator *local;
- GDir *dir;
-
- dir = g_dir_open (filename, 0, error);
- if (dir == NULL)
- return NULL;
-
- local = g_object_new (G_TYPE_LOCAL_FILE_ENUMERATOR, NULL);
-
- local->dir = dir;
- local->filename = g_strdup (filename);
- local->matcher = g_file_attribute_matcher_new (attributes);
- local->flags = flags;
-
- return G_FILE_ENUMERATOR (local);
-}
-
-static GFileInfo *
-g_local_file_enumerator_next_file (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileEnumerator *local = G_LOCAL_FILE_ENUMERATOR (enumerator);
- const char *filename;
- char *path;
- GFileInfo *info;
- GError *my_error = NULL;
-
- if (!local->got_parent_info)
- {
- _g_local_file_info_get_parent_info (local->filename, local->matcher, &local->parent_info);
- local->got_parent_info = TRUE;
- }
-
- next_file:
-
- filename = g_dir_read_name (local->dir);
- if (filename == NULL)
- return NULL;
-
- path = g_build_filename (local->filename, filename, NULL);
- info = _g_local_file_info_get (filename, path,
- local->matcher,
- local->flags,
- &local->parent_info,
- &my_error);
- g_free (path);
-
- if (info == NULL)
- {
- /* Failed to get info */
- /* If the file does not exist there might have been a race where
- * the file was removed between the readdir and the stat, so we
- * ignore the file. */
- if (my_error->domain == G_IO_ERROR &&
- my_error->code == G_IO_ERROR_NOT_FOUND)
- {
- g_error_free (my_error);
- goto next_file;
- }
- else
- g_propagate_error (error, my_error);
- }
-
- return info;
-}
-
-static gboolean
-g_local_file_enumerator_stop (GFileEnumerator *enumerator,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileEnumerator *local = G_LOCAL_FILE_ENUMERATOR (enumerator);
-
- if (local->dir)
- {
- g_dir_close (local->dir);
- local->dir = NULL;
- }
-
- return TRUE;
-}
-
-
diff --git a/gio/glocalfileenumerator.h b/gio/glocalfileenumerator.h
deleted file mode 100644
index 5ce0fea8..00000000
--- a/gio/glocalfileenumerator.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __G_LOCAL_FILE_ENUMERATOR_H__
-#define __G_LOCAL_FILE_ENUMERATOR_H__
-
-#include <gfileenumerator.h>
-#include <gfileinfo.h>
-#include <gfile.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOCAL_FILE_ENUMERATOR (g_local_file_enumerator_get_type ())
-#define G_LOCAL_FILE_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_LOCAL_FILE_ENUMERATOR, GLocalFileEnumerator))
-#define G_LOCAL_FILE_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_LOCAL_FILE_ENUMERATOR, GLocalFileEnumeratorClass))
-#define G_IS_LOCAL_FILE_ENUMERATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_LOCAL_FILE_ENUMERATOR))
-#define G_IS_LOCAL_FILE_ENUMERATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_LOCAL_FILE_ENUMERATOR))
-#define G_LOCAL_FILE_ENUMERATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_LOCAL_FILE_ENUMERATOR, GLocalFileEnumeratorClass))
-
-typedef struct _GLocalFileEnumerator GLocalFileEnumerator;
-typedef struct _GLocalFileEnumeratorClass GLocalFileEnumeratorClass;
-typedef struct _GLocalFileEnumeratorPrivate GLocalFileEnumeratorPrivate;
-
-
-struct _GLocalFileEnumeratorClass
-{
- GFileEnumeratorClass parent_class;
-
-};
-
-GType g_local_file_enumerator_get_type (void) G_GNUC_CONST;
-
-GFileEnumerator *g_local_file_enumerator_new (const char *filename,
- const char *attributes,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __G_FILE_LOCAL_FILE_ENUMERATOR_H__ */
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
deleted file mode 100644
index 5aec5198..00000000
--- a/gio/glocalfileinfo.c
+++ /dev/null
@@ -1,1730 +0,0 @@
-#include <config.h>
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <pwd.h>
-#include <grp.h>
-#ifdef HAVE_SELINUX
-#include <selinux/selinux.h>
-#endif
-
-#include <sys/types.h>
-#ifdef HAVE_XATTR
-
-#if defined HAVE_SYS_XATTR_H
- #include <sys/xattr.h>
-#elif defined HAVE_ATTR_XATTR_H
- #include <attr/xattr.h>
-#else
- #error "Neither <sys/xattr.h> nor <attr/xattr.h> is present but extended attribute support is enabled."
-#endif /* defined HAVE_SYS_XATTR_H || HAVE_ATTR_XATTR_H */
-
-#endif /* HAVE_XATTR */
-
-#include <glib/gstdio.h>
-#include <glib/gi18n-lib.h>
-
-#include "glocalfileinfo.h"
-#include "gioerror.h"
-#include "gcontenttype.h"
-#include "gcontenttypeprivate.h"
-
-typedef struct {
- char *user_name;
- char *real_name;
-} UidData;
-
-G_LOCK_DEFINE_STATIC (uid_cache);
-GHashTable *uid_cache = NULL;
-
-G_LOCK_DEFINE_STATIC (gid_cache);
-GHashTable *gid_cache = NULL;
-
-char *
-_g_local_file_info_create_etag (struct stat *statbuf)
-{
- GTimeVal tv;
-
- tv.tv_sec = statbuf->st_mtime;
-#if defined (HAVE_STRUCT_STAT_ST_MTIMENSEC)
- tv.tv_usec = statbuf->st_mtimensec / 1000;
-#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
- tv.tv_usec = statbuf->st_mtim.tv_nsec / 1000;
-#else
- tv.tv_usec = 0;
-#endif
-
- return g_strdup_printf ("%ld:%ld", tv.tv_sec, tv.tv_usec);
-}
-
-static gchar *
-read_link (const gchar *full_name)
-{
-#ifdef HAVE_READLINK
- gchar *buffer;
- guint size;
-
- size = 256;
- buffer = g_malloc (size);
-
- while (1)
- {
- int read_size;
-
- read_size = readlink (full_name, buffer, size);
- if (read_size < 0)
- {
- g_free (buffer);
- return NULL;
- }
- if (read_size < size)
- {
- buffer[read_size] = 0;
- return buffer;
- }
- size *= 2;
- buffer = g_realloc (buffer, size);
- }
-#else
- return NULL;
-#endif
-}
-
-/* Get the SELinux security context */
-static void
-get_selinux_context (const char *path,
- GFileInfo *info,
- GFileAttributeMatcher *attribute_matcher,
- gboolean follow_symlinks)
-{
-#ifdef HAVE_SELINUX
- char *context;
-
- if (!g_file_attribute_matcher_matches (attribute_matcher, "selinux:context"))
- return;
-
- if (is_selinux_enabled ())
- {
- if (follow_symlinks)
- {
- if (lgetfilecon_raw (path, &context) < 0)
- return;
- }
- else
- {
- if (getfilecon_raw (path, &context) < 0)
- return;
- }
-
- if (context)
- {
- g_file_info_set_attribute_string (info, "selinux:context", context);
- freecon(context);
- }
- }
-#endif
-}
-
-#ifdef HAVE_XATTR
-
-static gboolean
-valid_char (char c)
-{
- return c >= 32 && c <= 126 && c != '\\';
-}
-
-static gboolean
-name_is_valid (const char *str)
-{
- while (*str)
- {
- if (!valid_char (*str++))
- return FALSE;
- }
- return TRUE;
-}
-
-static char *
-hex_escape_string (const char *str, gboolean *free_return)
-{
- int num_invalid, i;
- char *escaped_str, *p;
- unsigned char c;
- static char *hex_digits = "0123456789abcdef";
- int len;
-
- len = strlen (str);
-
- num_invalid = 0;
- for (i = 0; i < len; i++)
- {
- if (!valid_char (str[i]))
- num_invalid++;
- }
-
- if (num_invalid == 0)
- {
- *free_return = FALSE;
- return (char *)str;
- }
-
- escaped_str = g_malloc (len + num_invalid*3 + 1);
-
- p = escaped_str;
- for (i = 0; i < len; i++)
- {
- if (valid_char (str[i]))
- *p++ = str[i];
- else
- {
- c = str[i];
- *p++ = '\\';
- *p++ = 'x';
- *p++ = hex_digits[(c >> 4) & 0xf];
- *p++ = hex_digits[c & 0xf];
- }
- }
- *p++ = 0;
-
- *free_return = TRUE;
- return escaped_str;
-}
-
-static char *
-hex_unescape_string (const char *str, int *out_len, gboolean *free_return)
-{
- int i;
- char *unescaped_str, *p;
- unsigned char c;
- int len;
-
- len = strlen (str);
-
- if (strchr (str, '\\') == NULL)
- {
- if (out_len)
- *out_len = len;
- *free_return = FALSE;
- return (char *)str;
- }
-
- unescaped_str = g_malloc (len + 1);
-
- p = unescaped_str;
- for (i = 0; i < len; i++)
- {
- if (str[i] == '\\' &&
- str[i+1] == 'x' &&
- len - i >= 4)
- {
- c =
- (g_ascii_xdigit_value (str[i+2]) << 4) |
- g_ascii_xdigit_value (str[i+3]);
- *p++ = c;
- i += 3;
- }
- else
- *p++ = str[i];
- }
- *p++ = 0;
-
- if (out_len)
- *out_len = p - unescaped_str;
- *free_return = TRUE;
- return unescaped_str;
-}
-
-static void
-escape_xattr (GFileInfo *info,
- const char *gio_attr, /* gio attribute name */
- const char *value, /* Is zero terminated */
- size_t len /* not including zero termination */)
-{
- char *escaped_val;
- gboolean free_escaped_val;
-
- escaped_val = hex_escape_string (value, &free_escaped_val);
-
- g_file_info_set_attribute_string (info, gio_attr, escaped_val);
-
- if (free_escaped_val)
- g_free (escaped_val);
-}
-
-static void
-get_one_xattr (const char *path,
- GFileInfo *info,
- const char *gio_attr,
- const char *xattr,
- gboolean follow_symlinks)
-{
- char value[64];
- char *value_p;
- ssize_t len;
-
- if (follow_symlinks)
- len = getxattr (path, xattr, value, sizeof (value)-1);
- else
- len = lgetxattr (path, xattr,value, sizeof (value)-1);
-
- value_p = NULL;
- if (len >= 0)
- value_p = value;
- else if (len == -1 && errno == ERANGE)
- {
- if (follow_symlinks)
- len = getxattr (path, xattr, NULL, 0);
- else
- len = lgetxattr (path, xattr, NULL, 0);
-
- if (len < 0)
- return;
-
- value_p = g_malloc (len+1);
-
- if (follow_symlinks)
- len = getxattr (path, xattr, value_p, len);
- else
- len = lgetxattr (path, xattr, value_p, len);
-
- if (len < 0)
- {
- g_free (value_p);
- return;
- }
- }
- else
- return;
-
- /* Null terminate */
- value_p[len] = 0;
-
- escape_xattr (info, gio_attr, value_p, len);
-
- if (value_p != value)
- g_free (value_p);
-}
-
-#endif /* defined HAVE_XATTR */
-
-static void
-get_xattrs (const char *path,
- gboolean user,
- GFileInfo *info,
- GFileAttributeMatcher *matcher,
- gboolean follow_symlinks)
-{
-#ifdef HAVE_XATTR
- gboolean all;
- gsize list_size;
- ssize_t list_res_size;
- size_t len;
- char *list;
- const char *attr, *attr2;
-
- if (user)
- all = g_file_attribute_matcher_enumerate_namespace (matcher, "xattr");
- else
- all = g_file_attribute_matcher_enumerate_namespace (matcher, "xattr_sys");
-
- if (all)
- {
- if (follow_symlinks)
- list_res_size = listxattr (path, NULL, 0);
- else
- list_res_size = llistxattr (path, NULL, 0);
-
- if (list_res_size == -1 ||
- list_res_size == 0)
- return;
-
- list_size = list_res_size;
- list = g_malloc (list_size);
-
- retry:
-
- if (follow_symlinks)
- list_res_size = listxattr (path, list, list_size);
- else
- list_res_size = llistxattr (path, list, list_size);
-
- if (list_res_size == -1 && errno == ERANGE)
- {
- list_size = list_size * 2;
- list = g_realloc (list, list_size);
- goto retry;
- }
-
- if (list_res_size == -1)
- return;
-
- attr = list;
- while (list_res_size > 0)
- {
- if ((user && g_str_has_prefix (attr, "user.")) ||
- (!user && !g_str_has_prefix (attr, "user.")))
- {
- char *escaped_attr, *gio_attr;
- gboolean free_escaped_attr;
-
- if (user)
- {
- escaped_attr = hex_escape_string (attr + 5, &free_escaped_attr);
- gio_attr = g_strconcat ("xattr:", escaped_attr, NULL);
- }
- else
- {
- escaped_attr = hex_escape_string (attr, &free_escaped_attr);
- gio_attr = g_strconcat ("xattr_sys:", escaped_attr, NULL);
- }
-
- if (free_escaped_attr)
- g_free (escaped_attr);
-
- get_one_xattr (path, info, gio_attr, attr, follow_symlinks);
- }
-
- len = strlen (attr) + 1;
- attr += len;
- list_res_size -= len;
- }
-
- g_free (list);
- }
- else
- {
- while ((attr = g_file_attribute_matcher_enumerate_next (matcher)) != NULL)
- {
- char *unescaped_attribute, *a;
- gboolean free_unescaped_attribute;
-
- attr2 = strchr (attr, ':');
- if (attr2)
- {
- attr2++; /* Skip ':' */
- unescaped_attribute = hex_unescape_string (attr2, NULL, &free_unescaped_attribute);
- if (user)
- a = g_strconcat ("user.", unescaped_attribute, NULL);
- else
- a = unescaped_attribute;
-
- get_one_xattr (path, info, attr, a, follow_symlinks);
-
- if (user)
- g_free (a);
-
- if (free_unescaped_attribute)
- g_free (unescaped_attribute);
- }
- }
- }
-#endif /* defined HAVE_XATTR */
-}
-
-#ifdef HAVE_XATTR
-static void
-get_one_xattr_from_fd (int fd,
- GFileInfo *info,
- const char *gio_attr,
- const char *xattr)
-{
- char value[64];
- char *value_p;
- ssize_t len;
-
- len = fgetxattr (fd, xattr, value, sizeof (value)-1);
-
- value_p = NULL;
- if (len >= 0)
- value_p = value;
- else if (len == -1 && errno == ERANGE)
- {
- len = fgetxattr (fd, xattr, NULL, 0);
-
- if (len < 0)
- return;
-
- value_p = g_malloc (len+1);
-
- len = fgetxattr (fd, xattr, value_p, len);
-
- if (len < 0)
- {
- g_free (value_p);
- return;
- }
- }
- else
- return;
-
- /* Null terminate */
- value_p[len] = 0;
-
- escape_xattr (info, gio_attr, value_p, len);
-
- if (value_p != value)
- g_free (value_p);
-}
-#endif /* defined HAVE_XATTR */
-
-static void
-get_xattrs_from_fd (int fd,
- gboolean user,
- GFileInfo *info,
- GFileAttributeMatcher *matcher)
-{
-#ifdef HAVE_XATTR
- gboolean all;
- gsize list_size;
- ssize_t list_res_size;
- size_t len;
- char *list;
- const char *attr, *attr2;
-
- if (user)
- all = g_file_attribute_matcher_enumerate_namespace (matcher, "xattr");
- else
- all = g_file_attribute_matcher_enumerate_namespace (matcher, "xattr_sys");
-
- if (all)
- {
- list_res_size = flistxattr (fd, NULL, 0);
-
- if (list_res_size == -1 ||
- list_res_size == 0)
- return;
-
- list_size = list_res_size;
- list = g_malloc (list_size);
-
- retry:
-
- list_res_size = flistxattr (fd, list, list_size);
-
- if (list_res_size == -1 && errno == ERANGE)
- {
- list_size = list_size * 2;
- list = g_realloc (list, list_size);
- goto retry;
- }
-
- if (list_res_size == -1)
- return;
-
- attr = list;
- while (list_res_size > 0)
- {
- if ((user && g_str_has_prefix (attr, "user.")) ||
- (!user && !g_str_has_prefix (attr, "user.")))
- {
- char *escaped_attr, *gio_attr;
- gboolean free_escaped_attr;
-
- if (user)
- {
- escaped_attr = hex_escape_string (attr + 5, &free_escaped_attr);
- gio_attr = g_strconcat ("xattr:", escaped_attr, NULL);
- }
- else
- {
- escaped_attr = hex_escape_string (attr, &free_escaped_attr);
- gio_attr = g_strconcat ("xattr_sys:", escaped_attr, NULL);
- }
-
- if (free_escaped_attr)
- g_free (escaped_attr);
-
- get_one_xattr_from_fd (fd, info, gio_attr, attr);
- }
-
- len = strlen (attr) + 1;
- attr += len;
- list_res_size -= len;
- }
-
- g_free (list);
- }
- else
- {
- while ((attr = g_file_attribute_matcher_enumerate_next (matcher)) != NULL)
- {
- char *unescaped_attribute, *a;
- gboolean free_unescaped_attribute;
-
- attr2 = strchr (attr, ':');
- if (attr2)
- {
- attr2++; /* Skip ':' */
- unescaped_attribute = hex_unescape_string (attr2, NULL, &free_unescaped_attribute);
- if (user)
- a = g_strconcat ("user.", unescaped_attribute, NULL);
- else
- a = unescaped_attribute;
-
- get_one_xattr_from_fd (fd, info, attr, a);
-
- if (user)
- g_free (a);
-
- if (free_unescaped_attribute)
- g_free (unescaped_attribute);
- }
- }
- }
-#endif /* defined HAVE_XATTR */
-}
-
-#ifdef HAVE_XATTR
-static gboolean
-set_xattr (char *filename,
- const char *escaped_attribute,
- const GFileAttributeValue *attr_value,
- GError **error)
-{
- char *attribute, *value;
- gboolean free_attribute, free_value;
- int val_len, res, errsv;
- gboolean is_user;
- char *a;
-
- if (attr_value->type != G_FILE_ATTRIBUTE_TYPE_STRING)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Invalid attribute type (string expected)"));
- return FALSE;
- }
-
- if (!name_is_valid (escaped_attribute))
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Invalid extended attribute name"));
- return FALSE;
- }
-
- if (g_str_has_prefix (escaped_attribute, "xattr:"))
- {
- escaped_attribute += 6;
- is_user = TRUE;
- }
- else
- {
- g_assert (g_str_has_prefix (escaped_attribute, "xattr_sys:"));
- escaped_attribute += 10;
- is_user = FALSE;
- }
-
- attribute = hex_unescape_string (escaped_attribute, NULL, &free_attribute);
- value = hex_unescape_string (attr_value->u.string, &val_len, &free_value);
-
-
- if (is_user)
- a = g_strconcat ("user.", attribute, NULL);
- else
- a = attribute;
-
- res = setxattr (filename, a, value, val_len, 0);
- errsv = errno;
-
- if (is_user)
- g_free (a);
-
- if (free_attribute)
- g_free (attribute);
-
- if (free_value)
- g_free (value);
-
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error setting extended attribute '%s': %s"),
- escaped_attribute, g_strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-#endif
-
-
-void
-_g_local_file_info_get_parent_info (const char *dir,
- GFileAttributeMatcher *attribute_matcher,
- GLocalParentFileInfo *parent_info)
-{
- struct stat statbuf;
- int res;
-
- parent_info->writable = FALSE;
- parent_info->is_sticky = FALSE;
-
- if (g_file_attribute_matcher_matches (attribute_matcher, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME) ||
- g_file_attribute_matcher_matches (attribute_matcher, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE))
- {
- parent_info->writable = (g_access (dir, W_OK) == 0);
-
- if (parent_info->writable)
- {
- res = g_stat (dir, &statbuf);
-
- /*
- * The sticky bit (S_ISVTX) on a directory means that a file in that directory can be
- * renamed or deleted only by the owner of the file, by the owner of the directory, and
- * by a privileged process.
- */
- if (res == 0)
- {
- parent_info->is_sticky = (statbuf.st_mode & S_ISVTX) != 0;
- parent_info->owner = statbuf.st_uid;
- }
- }
- }
-}
-
-static void
-get_access_rights (GFileAttributeMatcher *attribute_matcher,
- GFileInfo *info,
- const gchar *path,
- struct stat *statbuf,
- GLocalParentFileInfo *parent_info)
-{
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_ACCESS_CAN_READ))
- g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
- g_access (path, R_OK) == 0);
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
- g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
- g_access (path, W_OK) == 0);
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE))
- g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE,
- g_access (path, X_OK) == 0);
-
-
- if (parent_info)
- {
- gboolean writable;
-
- writable = FALSE;
- if (parent_info->writable)
- {
- if (parent_info->is_sticky)
- {
- uid_t uid = geteuid ();
-
- if (uid == statbuf->st_uid ||
- uid == parent_info->owner ||
- uid == 0)
- writable = TRUE;
- }
- else
- writable = TRUE;
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME))
- g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME,
- writable);
-
- if (g_file_attribute_matcher_matches (attribute_matcher, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE))
- g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE,
- writable);
- }
-}
-
-static void
-set_info_from_stat (GFileInfo *info, struct stat *statbuf,
- GFileAttributeMatcher *attribute_matcher)
-{
- GFileType file_type;
-
- file_type = G_FILE_TYPE_UNKNOWN;
-
- if (S_ISREG (statbuf->st_mode))
- file_type = G_FILE_TYPE_REGULAR;
- else if (S_ISDIR (statbuf->st_mode))
- file_type = G_FILE_TYPE_DIRECTORY;
- else if (S_ISCHR (statbuf->st_mode) ||
- S_ISBLK (statbuf->st_mode) ||
- S_ISFIFO (statbuf->st_mode)
-#ifdef S_ISSOCK
- || S_ISSOCK (statbuf->st_mode)
-#endif
- )
- file_type = G_FILE_TYPE_SPECIAL;
-#ifdef S_ISLNK
- else if (S_ISLNK (statbuf->st_mode))
- file_type = G_FILE_TYPE_SYMBOLIC_LINK;
-#endif
-
- g_file_info_set_file_type (info, file_type);
- g_file_info_set_size (info, statbuf->st_size);
-
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_DEVICE, statbuf->st_dev);
- g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_INODE, statbuf->st_ino);
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE, statbuf->st_mode);
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_NLINK, statbuf->st_nlink);
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID, statbuf->st_uid);
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID, statbuf->st_uid);
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_RDEV, statbuf->st_rdev);
-#if defined (HAVE_STRUCT_STAT_BLKSIZE)
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE, statbuf->st_blksize);
-#endif
-#if defined (HAVE_STRUCT_STAT_BLOCKS)
- g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_BLOCKS, statbuf->st_blocks);
-#endif
-
- g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED, statbuf->st_mtime);
-#if defined (HAVE_STRUCT_STAT_ST_MTIMENSEC)
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC, statbuf->st_mtimensec / 1000);
-#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC, statbuf->st_mtim.tv_nsec / 1000);
-#endif
-
- g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS, statbuf->st_atime);
-#if defined (HAVE_STRUCT_STAT_ST_ATIMENSEC)
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC, statbuf->st_atimensec / 1000);
-#elif defined (HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC)
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC, statbuf->st_atim.tv_nsec / 1000);
-#endif
-
- g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CHANGED, statbuf->st_ctime);
-#if defined (HAVE_STRUCT_STAT_ST_CTIMENSEC)
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_CHANGED_USEC, statbuf->st_ctimensec / 1000);
-#elif defined (HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC)
- g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_CHANGED_USEC, statbuf->st_ctim.tv_nsec / 1000);
-#endif
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_ETAG_VALUE))
- {
- char *etag = _g_local_file_info_create_etag (statbuf);
- g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_ETAG_VALUE, etag);
- g_free (etag);
- }
-
-}
-
-static char *
-make_valid_utf8 (const char *name)
-{
- GString *string;
- const gchar *remainder, *invalid;
- gint remaining_bytes, valid_bytes;
-
- string = NULL;
- remainder = name;
- remaining_bytes = strlen (name);
-
- while (remaining_bytes != 0)
- {
- if (g_utf8_validate (remainder, remaining_bytes, &invalid))
- break;
- valid_bytes = invalid - remainder;
-
- if (string == NULL)
- string = g_string_sized_new (remaining_bytes);
-
- g_string_append_len (string, remainder, valid_bytes);
- /* append U+FFFD REPLACEMENT CHARACTER */
- g_string_append (string, "\357\277\275");
-
- remaining_bytes -= valid_bytes + 1;
- remainder = invalid + 1;
- }
-
- if (string == NULL)
- return g_strdup (name);
-
- g_string_append (string, remainder);
-
- g_assert (g_utf8_validate (string->str, -1, NULL));
-
- return g_string_free (string, FALSE);
-}
-
-static char *
-convert_pwd_string_to_utf8 (char *pwd_str)
-{
- char *utf8_string;
-
- if (!g_utf8_validate (pwd_str, -1, NULL))
- {
- utf8_string = g_locale_to_utf8 (pwd_str, -1, NULL, NULL, NULL);
- if (utf8_string == NULL)
- utf8_string = make_valid_utf8 (pwd_str);
- }
- else
- utf8_string = g_strdup (pwd_str);
-
- return utf8_string;
-}
-
-static void
-uid_data_free (UidData *data)
-{
- g_free (data->user_name);
- g_free (data->real_name);
- g_free (data);
-}
-
-/* called with lock held */
-static UidData *
-lookup_uid_data (uid_t uid)
-{
- UidData *data;
- char buffer[4096];
- struct passwd pwbuf;
- struct passwd *pwbufp;
- char *gecos, *comma;
-
- if (uid_cache == NULL)
- uid_cache = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)uid_data_free);
-
- data = g_hash_table_lookup (uid_cache, GINT_TO_POINTER (uid));
-
- if (data)
- return data;
-
- data = g_new0 (UidData, 1);
-
- getpwuid_r (uid, &pwbuf, buffer, sizeof(buffer), &pwbufp);
-
- if (pwbufp != NULL)
- {
- if (pwbufp->pw_name != NULL && pwbufp->pw_name[0] != 0)
- data->user_name = convert_pwd_string_to_utf8 (pwbufp->pw_name);
-
- gecos = pwbufp->pw_gecos;
-
- if (gecos)
- {
- comma = strchr (gecos, ',');
- if (comma)
- *comma = 0;
- data->real_name = convert_pwd_string_to_utf8 (gecos);
- }
- }
-
- /* Default fallbacks */
- if (data->real_name == NULL)
- {
- if (data->user_name != NULL)
- data->real_name = g_strdup (data->user_name);
- else
- data->real_name = g_strdup_printf("user #%d", (int)uid);
- }
-
- if (data->user_name == NULL)
- data->user_name = g_strdup_printf("%d", (int)uid);
-
- g_hash_table_replace (uid_cache, GINT_TO_POINTER (uid), data);
-
- return data;
-}
-
-static char *
-get_username_from_uid (uid_t uid)
-{
- char *res;
- UidData *data;
-
- G_LOCK (uid_cache);
- data = lookup_uid_data (uid);
- res = g_strdup (data->user_name);
- G_UNLOCK (uid_cache);
-
- return res;
-}
-
-static char *
-get_realname_from_uid (uid_t uid)
-{
- char *res;
- UidData *data;
-
- G_LOCK (uid_cache);
- data = lookup_uid_data (uid);
- res = g_strdup (data->real_name);
- G_UNLOCK (uid_cache);
-
- return res;
-}
-
-
-/* called with lock held */
-static char *
-lookup_gid_name (gid_t gid)
-{
- char *name;
- char buffer[4096];
- struct group gbuf;
- struct group *gbufp;
-
- if (gid_cache == NULL)
- gid_cache = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_free);
-
- name = g_hash_table_lookup (gid_cache, GINT_TO_POINTER (gid));
-
- if (name)
- return name;
-
- getgrgid_r (gid, &gbuf, buffer, sizeof(buffer), &gbufp);
-
- if (gbufp != NULL &&
- gbufp->gr_name != NULL &&
- gbufp->gr_name[0] != 0)
- name = convert_pwd_string_to_utf8 (gbufp->gr_name);
- else
- name = g_strdup_printf("%d", (int)gid);
-
- g_hash_table_replace (gid_cache, GINT_TO_POINTER (gid), name);
-
- return name;
-}
-
-static char *
-get_groupname_from_gid (gid_t gid)
-{
- char *res;
- char *name;
-
- G_LOCK (gid_cache);
- name = lookup_gid_name (gid);
- res = g_strdup (name);
- G_UNLOCK (gid_cache);
- return res;
-}
-
-static char *
-get_content_type (const char *basename,
- const char *path,
- struct stat *statbuf,
- gboolean is_symlink,
- gboolean symlink_broken,
- GFileGetInfoFlags flags,
- gboolean fast)
-{
- if (is_symlink &&
- (symlink_broken || (flags & G_FILE_GET_INFO_NOFOLLOW_SYMLINKS)))
- return g_strdup ("inode/symlink");
- else if (S_ISDIR(statbuf->st_mode))
- return g_strdup ("inode/directory");
- else if (S_ISCHR(statbuf->st_mode))
- return g_strdup ("inode/chardevice");
- else if (S_ISBLK(statbuf->st_mode))
- return g_strdup ("inode/blockdevice");
- else if (S_ISFIFO(statbuf->st_mode))
- return g_strdup ("inode/fifo");
-#ifdef S_ISSOCK
- else if (S_ISSOCK(statbuf->st_mode))
- return g_strdup ("inode/socket");
-#endif
- else
- {
- char *content_type;
- gboolean result_uncertain;
-
- content_type = g_content_type_guess (basename, NULL, 0, &result_uncertain);
-
-#ifndef G_OS_WIN32
- if (!fast && result_uncertain && path != NULL)
- {
- guchar sniff_buffer[4096];
- gsize sniff_length;
- int fd;
-
- sniff_length = _g_unix_content_type_get_sniff_len ();
- if (sniff_length > 4096)
- sniff_length = 4096;
-
- fd = open (path, O_RDONLY);
- if (fd != -1)
- {
- ssize_t res;
-
- res = read (fd, sniff_buffer, sniff_length);
- close (fd);
- if (res != -1)
- {
- g_free (content_type);
- content_type = g_content_type_guess (basename, sniff_buffer, sniff_length, NULL);
- }
- }
- }
-#endif
-
- return content_type;
- }
-
-}
-
-GFileInfo *
-_g_local_file_info_get (const char *basename,
- const char *path,
- GFileAttributeMatcher *attribute_matcher,
- GFileGetInfoFlags flags,
- GLocalParentFileInfo *parent_info,
- GError **error)
-{
- GFileInfo *info;
- struct stat statbuf;
- struct stat statbuf2;
- int res;
- gboolean is_symlink, symlink_broken;
-
- info = g_file_info_new ();
-
- /* Make sure we don't set any unwanted attributes */
- g_file_info_set_attribute_mask (info, attribute_matcher);
-
- g_file_info_set_name (info, basename);
-
- /* Avoid stat in trivial case */
- if (attribute_matcher == NULL)
- return info;
-
- res = g_lstat (path, &statbuf);
- if (res == -1)
- {
- g_object_unref (info);
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error stating file '%s': %s"),
- path, g_strerror (errno));
- return NULL;
- }
-
-#ifdef S_ISLNK
- is_symlink = S_ISLNK (statbuf.st_mode);
-#else
- is_symlink = FALSE;
-#endif
- symlink_broken = FALSE;
-
- if (is_symlink)
- {
- g_file_info_set_is_symlink (info, TRUE);
-
- /* Unless NOFOLLOW was set we default to following symlinks */
- if (!(flags & G_FILE_GET_INFO_NOFOLLOW_SYMLINKS))
- {
- res = stat (path, &statbuf2);
-
- /* Report broken links as symlinks */
- if (res != -1)
- {
- statbuf = statbuf2;
- symlink_broken = TRUE;
- }
- }
- }
-
- set_info_from_stat (info, &statbuf, attribute_matcher);
-
- if (basename != NULL && basename[0] == '.')
- g_file_info_set_is_hidden (info, TRUE);
-
- if (basename != NULL && basename[strlen (basename) -1] == '~')
- g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_STD_IS_BACKUP, TRUE);
-
- if (is_symlink &&
- g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET))
- {
- char *link = read_link (path);
- g_file_info_set_symlink_target (info, link);
- g_free (link);
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_STD_DISPLAY_NAME))
- {
- char *display_name = g_filename_display_basename (path);
-
- if (strstr (display_name, "\357\277\275") != NULL)
- {
- char *p = display_name;
- display_name = g_strconcat (display_name, _(" (invalid encoding)"), NULL);
- g_free (p);
- }
- g_file_info_set_display_name (info, display_name);
- g_free (display_name);
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_STD_EDIT_NAME))
- {
- char *edit_name = g_filename_display_basename (path);
- g_file_info_set_edit_name (info, edit_name);
- g_free (edit_name);
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_STD_CONTENT_TYPE))
- {
- char *content_type = get_content_type (basename, path, &statbuf, is_symlink, symlink_broken, flags, FALSE);
-
- if (content_type)
- {
- g_file_info_set_content_type (info, content_type);
- g_free (content_type);
- }
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_STD_FAST_CONTENT_TYPE))
- {
- char *content_type = get_content_type (basename, path, &statbuf, is_symlink, symlink_broken, flags, FALSE);
-
- if (content_type)
- {
- g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_STD_FAST_CONTENT_TYPE, content_type);
- g_free (content_type);
- }
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_STD_ICON))
- {
- /* TODO */
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_OWNER_USER))
- {
- char *name;
-
- name = get_username_from_uid (statbuf.st_uid);
- if (name)
- g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_USER, name);
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_OWNER_USER_REAL))
- {
- char *name;
-
- name = get_realname_from_uid (statbuf.st_uid);
- if (name)
- g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_USER_REAL, name);
- }
-
- if (g_file_attribute_matcher_matches (attribute_matcher,
- G_FILE_ATTRIBUTE_OWNER_GROUP))
- {
- char *name;
-
- name = get_groupname_from_gid (statbuf.st_gid);
- if (name)
- g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_GROUP, name);
- }
-
-
- get_access_rights (attribute_matcher, info, path, &statbuf, parent_info);
-
- get_selinux_context (path, info, attribute_matcher, (flags & G_FILE_GET_INFO_NOFOLLOW_SYMLINKS) == 0);
- get_xattrs (path, TRUE, info, attribute_matcher, (flags & G_FILE_GET_INFO_NOFOLLOW_SYMLINKS) == 0);
- get_xattrs (path, FALSE, info, attribute_matcher, (flags & G_FILE_GET_INFO_NOFOLLOW_SYMLINKS) == 0);
-
- g_file_info_unset_attribute_mask (info);
-
- return info;
-}
-
-GFileInfo *
-_g_local_file_info_get_from_fd (int fd,
- char *attributes,
- GError **error)
-{
- struct stat stat_buf;
- GFileAttributeMatcher *matcher;
- GFileInfo *info;
-
- if (fstat (fd, &stat_buf) == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error stating file descriptor: %s"),
- g_strerror (errno));
- return NULL;
- }
-
- info = g_file_info_new ();
-
- matcher = g_file_attribute_matcher_new (attributes);
-
- /* Make sure we don't set any unwanted attributes */
- g_file_info_set_attribute_mask (info, matcher);
-
- set_info_from_stat (info, &stat_buf, matcher);
-
-#ifdef HAVE_SELINUX
- if (g_file_attribute_matcher_matches (matcher, "selinux:context") &&
- is_selinux_enabled ())
- {
- char *context;
- if (fgetfilecon_raw (fd, &context) >= 0)
- {
- g_file_info_set_attribute_string (info, "selinux:context", context);
- freecon(context);
- }
- }
-#endif
-
- get_xattrs_from_fd (fd, TRUE, info, matcher);
- get_xattrs_from_fd (fd, FALSE, info, matcher);
-
- g_file_attribute_matcher_unref (matcher);
-
- g_file_info_unset_attribute_mask (info);
-
- return info;
-}
-
-static gboolean
-get_uint32 (const GFileAttributeValue *value,
- guint32 *val_out,
- GError **error)
-{
- if (value->type != G_FILE_ATTRIBUTE_TYPE_UINT32)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Invalid attribute type (uint32 expected)"));
- return FALSE;
- }
-
- *val_out = value->u.uint32;
-
- return TRUE;
-}
-
-static gboolean
-get_uint64 (const GFileAttributeValue *value,
- guint64 *val_out,
- GError **error)
-{
- if (value->type != G_FILE_ATTRIBUTE_TYPE_UINT64)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Invalid attribute type (uint64 expected)"));
- return FALSE;
- }
-
- *val_out = value->u.uint64;
-
- return TRUE;
-}
-
-#if defined(HAVE_SYMLINK)
-static gboolean
-get_byte_string (const GFileAttributeValue *value,
- const char **val_out,
- GError **error)
-{
- if (value->type != G_FILE_ATTRIBUTE_TYPE_BYTE_STRING)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Invalid attribute type (byte string expected)"));
- return FALSE;
- }
-
- *val_out = value->u.string;
-
- return TRUE;
-}
-#endif
-
-static gboolean
-set_unix_mode (char *filename,
- const GFileAttributeValue *value,
- GError **error)
-{
- guint32 val;
-
- if (!get_uint32 (value, &val, error))
- return FALSE;
-
- if (g_chmod (filename, val) == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error setting permissions: %s"),
- g_strerror (errno));
- return FALSE;
- }
- return TRUE;
-}
-
-#ifdef HAVE_CHOWN
-static gboolean
-set_unix_uid_gid (char *filename,
- const GFileAttributeValue *uid_value,
- const GFileAttributeValue *gid_value,
- GFileGetInfoFlags flags,
- GError **error)
-{
- int res;
- guint32 val;
- uid_t uid;
- gid_t gid;
-
- if (uid_value)
- {
- if (!get_uint32 (uid_value, &val, error))
- return FALSE;
- uid = val;
- }
- else
- uid = -1;
-
- if (gid_value)
- {
- if (!get_uint32 (gid_value, &val, error))
- return FALSE;
- gid = val;
- }
- else
- gid = -1;
-
- if (flags & G_FILE_GET_INFO_NOFOLLOW_SYMLINKS)
- res = lchown (filename, uid, gid);
- else
- res = chown (filename, uid, gid);
-
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error setting owner: %s"),
- g_strerror (errno));
- return FALSE;
- }
- return TRUE;
-}
-#endif
-
-#ifdef HAVE_SYMLINK
-static gboolean
-set_symlink (char *filename,
- const GFileAttributeValue *value,
- GError **error)
-{
- const char *val;
- struct stat statbuf;
-
- if (!get_byte_string (value, &val, error))
- return FALSE;
-
- if (val == NULL)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("symlink must be non-NULL"));
- return FALSE;
- }
-
- if (g_lstat (filename, &statbuf))
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error setting symlink: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- if (!S_ISLNK (statbuf.st_mode))
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_NOT_SYMBOLIC_LINK,
- _("Error setting symlink: file is not a symlink"));
- return FALSE;
- }
-
- if (g_unlink (filename))
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error setting symlink: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- if (symlink (filename, val) != 0)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error setting symlink: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-#endif
-
-static int
-lazy_stat (char *filename, struct stat *statbuf, gboolean *called_stat)
-{
- int res;
-
- if (*called_stat)
- return 0;
-
- res = g_stat (filename, statbuf);
-
- if (res == 0)
- *called_stat = TRUE;
-
- return res;
-}
-
-
-#ifdef HAVE_UTIMES
-static gboolean
-set_mtime_atime (char *filename,
- const GFileAttributeValue *mtime_value,
- const GFileAttributeValue *mtime_usec_value,
- const GFileAttributeValue *atime_value,
- const GFileAttributeValue *atime_usec_value,
- GError **error)
-{
- int res;
- guint64 val;
- guint32 val_usec;
- struct stat statbuf;
- gboolean got_stat = FALSE;
- struct timeval times[2] = { {0, 0}, {0, 0} };
-
- /* ATIME */
- if (atime_value)
- {
- if (!get_uint64 (atime_value, &val, error))
- return FALSE;
- times[0].tv_sec = val;
- }
- else
- {
- if (lazy_stat (filename, &statbuf, &got_stat) == 0)
- {
- times[0].tv_sec = statbuf.st_mtime;
-#if defined (HAVE_STRUCT_STAT_ST_ATIMENSEC)
- times[0].tv_usec = statbuf.st_atimensec / 1000;
-#elif defined (HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC)
- times[0].tv_usec = statbuf.st_atim.tv_nsec / 1000;
-#endif
- }
- }
-
- if (atime_usec_value)
- {
- if (!get_uint32 (atime_usec_value, &val_usec, error))
- return FALSE;
- times[0].tv_usec = val_usec;
- }
-
- /* MTIME */
- if (mtime_value)
- {
- if (!get_uint64 (mtime_value, &val, error))
- return FALSE;
- times[1].tv_sec = val;
- }
- else
- {
- if (lazy_stat (filename, &statbuf, &got_stat) == 0)
- {
- times[1].tv_sec = statbuf.st_mtime;
-#if defined (HAVE_STRUCT_STAT_ST_MTIMENSEC)
- times[1].tv_usec = statbuf.st_mtimensec / 1000;
-#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
- times[1].tv_usec = statbuf.st_mtim.tv_nsec / 1000;
-#endif
- }
- }
-
- if (mtime_usec_value)
- {
- if (!get_uint32 (mtime_usec_value, &val_usec, error))
- return FALSE;
- times[1].tv_usec = val_usec;
- }
-
- res = utimes(filename, times);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error setting owner: %s"),
- g_strerror (errno));
- return FALSE;
- }
- return TRUE;
-}
-#endif
-
-gboolean
-_g_local_file_info_set_attribute (char *filename,
- const char *attribute,
- const GFileAttributeValue *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) == 0)
- return set_unix_mode (filename, value, error);
-
-#ifdef HAVE_CHOWN
- else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_UID) == 0)
- return set_unix_uid_gid (filename, value, NULL, flags, error);
- else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_GID) == 0)
- return set_unix_uid_gid (filename, NULL, value, flags, error);
-#endif
-
-#ifdef HAVE_SYMLINK
- else if (strcmp (attribute, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET) == 0)
- return set_symlink (filename, value, error);
-#endif
-
-#ifdef HAVE_UTIMES
- else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED) == 0)
- return set_mtime_atime (filename, value, NULL, NULL, NULL, error);
- else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) == 0)
- return set_mtime_atime (filename, NULL, value, NULL, NULL, error);
- else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS) == 0)
- return set_mtime_atime (filename, NULL, NULL, value, NULL, error);
- else if (strcmp (attribute, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) == 0)
- return set_mtime_atime (filename, NULL, NULL, NULL, value, error);
-#endif
-
- else if (g_str_has_prefix (attribute, "xattr:") == 0)
- return set_xattr (filename, attribute, value, error);
- else if (g_str_has_prefix (attribute, "xattr_sys:") == 0)
- return set_xattr (filename, attribute, value, error);
-
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Setting attribute %s not supported"), attribute);
- return FALSE;
-}
-
-gboolean
-_g_local_file_info_set_attributes (char *filename,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- GFileAttributeValue *value, *uid, *gid;
- GFileAttributeValue *mtime, *mtime_usec, *atime, *atime_usec;
- GFileAttributeStatus status;
- gboolean res;
-
- /* Handles setting multiple specified data in a single set, and takes care
- of ordering restrictions when setting attributes */
-
- res = TRUE;
-
- /* Set symlink first, since this recreates the file */
-#ifdef HAVE_SYMLINK
- value = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET);
- if (value)
- {
- if (!set_symlink (filename, value, error))
- {
- value->status = G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING;
- res = FALSE;
- /* Don't set error multiple times */
- error = NULL;
- }
- else
- value->status = G_FILE_ATTRIBUTE_STATUS_SET;
-
- }
-#endif
-
-#ifdef HAVE_CHOWN
- /* Group uid and gid setting into one call
- * Change ownership before permissions, since ownership changes can
- change permissions (e.g. setuid)
- */
- uid = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_UID);
- gid = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_GID);
-
- if (uid || gid)
- {
- if (!set_unix_uid_gid (filename, uid, gid, flags, error))
- {
- status = G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING;
- res = FALSE;
- /* Don't set error multiple times */
- error = NULL;
- }
- else
- status = G_FILE_ATTRIBUTE_STATUS_SET;
- if (uid)
- uid->status = status;
- if (gid)
- gid->status = status;
- }
-#endif
-
- value = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE);
- if (value)
- {
- if (!set_unix_mode (filename, value, error))
- {
- value->status = G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING;
- res = FALSE;
- /* Don't set error multiple times */
- error = NULL;
- }
- else
- value->status = G_FILE_ATTRIBUTE_STATUS_SET;
-
- }
-
-#ifdef HAVE_UTIMES
- /* Group all time settings into one call
- * Change times as the last thing to avoid it changing due to metadata changes
- */
-
- mtime = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
- mtime_usec = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
- atime = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
- atime_usec = g_file_info_get_attribute (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC);
-
- if (mtime || mtime_usec || atime || atime_usec)
- {
- if (!set_mtime_atime (filename, mtime, mtime_usec, atime, atime_usec, error))
- {
- status = G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING;
- res = FALSE;
- /* Don't set error multiple times */
- error = NULL;
- }
- else
- status = G_FILE_ATTRIBUTE_STATUS_SET;
-
- if (mtime)
- mtime->status = status;
- if (mtime_usec)
- mtime_usec->status = status;
- if (atime)
- atime->status = status;
- if (atime_usec)
- atime_usec->status = status;
- }
-#endif
-
- /* xattrs are handled by default callback */
-
- return res;
-}
diff --git a/gio/glocalfileinfo.h b/gio/glocalfileinfo.h
deleted file mode 100644
index 575d159f..00000000
--- a/gio/glocalfileinfo.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __G_LOCAL_FILE_INFO_H__
-#define __G_LOCAL_FILE_INFO_H__
-
-#include <gio/gfileinfo.h>
-#include <gio/gfile.h>
-#include <sys/stat.h>
-
-G_BEGIN_DECLS
-
-typedef struct {
- gboolean writable;
- gboolean is_sticky;
- int owner;
-} GLocalParentFileInfo;
-
-void _g_local_file_info_get_parent_info (const char *dir,
- GFileAttributeMatcher *attribute_matcher,
- GLocalParentFileInfo *parent_info);
-GFileInfo *_g_local_file_info_get (const char *basename,
- const char *path,
- GFileAttributeMatcher *attribute_matcher,
- GFileGetInfoFlags flags,
- GLocalParentFileInfo *parent_info,
- GError **error);
-GFileInfo *_g_local_file_info_get_from_fd (int fd,
- char *attributes,
- GError **error);
-char * _g_local_file_info_create_etag (struct stat *statbuf);
-gboolean _g_local_file_info_set_attribute (char *filename,
- const char *attribute,
- const GFileAttributeValue *value,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-gboolean _g_local_file_info_set_attributes (char *filename,
- GFileInfo *info,
- GFileGetInfoFlags flags,
- GCancellable *cancellable,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __G_FILE_LOCAL_FILE_INFO_H__ */
-
-
diff --git a/gio/glocalfileinputstream.c b/gio/glocalfileinputstream.c
deleted file mode 100644
index 3bf8af42..00000000
--- a/gio/glocalfileinputstream.c
+++ /dev/null
@@ -1,291 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n-lib.h>
-#include "gioerror.h"
-#include "glocalfileinputstream.h"
-#include "glocalfileinfo.h"
-
-
-G_DEFINE_TYPE (GLocalFileInputStream, g_local_file_input_stream, G_TYPE_FILE_INPUT_STREAM);
-
-struct _GLocalFileInputStreamPrivate {
- int fd;
-};
-
-static gssize g_local_file_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gssize g_local_file_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_local_file_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static goffset g_local_file_input_stream_tell (GFileInputStream *stream);
-static gboolean g_local_file_input_stream_can_seek (GFileInputStream *stream);
-static gboolean g_local_file_input_stream_seek (GFileInputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-static GFileInfo *g_local_file_input_stream_get_file_info (GFileInputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error);
-
-static void
-g_local_file_input_stream_finalize (GObject *object)
-{
- GLocalFileInputStream *file;
-
- file = G_LOCAL_FILE_INPUT_STREAM (object);
-
- if (G_OBJECT_CLASS (g_local_file_input_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_local_file_input_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_local_file_input_stream_class_init (GLocalFileInputStreamClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
- GFileInputStreamClass *file_stream_class = G_FILE_INPUT_STREAM_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GLocalFileInputStreamPrivate));
-
- gobject_class->finalize = g_local_file_input_stream_finalize;
-
- stream_class->read = g_local_file_input_stream_read;
- stream_class->skip = g_local_file_input_stream_skip;
- stream_class->close = g_local_file_input_stream_close;
- file_stream_class->tell = g_local_file_input_stream_tell;
- file_stream_class->can_seek = g_local_file_input_stream_can_seek;
- file_stream_class->seek = g_local_file_input_stream_seek;
- file_stream_class->get_file_info = g_local_file_input_stream_get_file_info;
-}
-
-static void
-g_local_file_input_stream_init (GLocalFileInputStream *info)
-{
- info->priv = G_TYPE_INSTANCE_GET_PRIVATE (info,
- G_TYPE_LOCAL_FILE_INPUT_STREAM,
- GLocalFileInputStreamPrivate);
-}
-
-GFileInputStream *
-g_local_file_input_stream_new (int fd)
-{
- GLocalFileInputStream *stream;
-
- stream = g_object_new (G_TYPE_LOCAL_FILE_INPUT_STREAM, NULL);
- stream->priv->fd = fd;
-
- return G_FILE_INPUT_STREAM (stream);
-}
-
-static gssize
-g_local_file_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileInputStream *file;
- gssize res;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- res = -1;
- while (1)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- break;
- res = read (file->priv->fd, buffer, count);
- if (res == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error reading from file: %s"),
- g_strerror (errno));
- }
-
- break;
- }
-
- return res;
-}
-
-static gssize
-g_local_file_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- off_t res, start;
- GLocalFileInputStream *file;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return -1;
-
- start = lseek (file->priv->fd, 0, SEEK_CUR);
- if (start == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error seeking in file: %s"),
- g_strerror (errno));
- return -1;
- }
-
- res = lseek (file->priv->fd, count, SEEK_CUR);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error seeking in file: %s"),
- g_strerror (errno));
- return -1;
- }
-
- return res - start;
-}
-
-static gboolean
-g_local_file_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileInputStream *file;
- int res;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- if (file->priv->fd == -1)
- return TRUE;
-
- while (1)
- {
- res = close (file->priv->fd);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing file: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- return res != -1;
-}
-
-
-static goffset
-g_local_file_input_stream_tell (GFileInputStream *stream)
-{
- GLocalFileInputStream *file;
- off_t pos;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- pos = lseek (file->priv->fd, 0, SEEK_CUR);
-
- if (pos == (off_t)-1)
- return 0;
-
- return pos;
-}
-
-static gboolean
-g_local_file_input_stream_can_seek (GFileInputStream *stream)
-{
- GLocalFileInputStream *file;
- off_t pos;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- pos = lseek (file->priv->fd, 0, SEEK_CUR);
-
- if (pos == (off_t)-1 &&
- errno == ESPIPE)
- return FALSE;
-
- return TRUE;
-}
-
-static int
-seek_type_to_lseek (GSeekType type)
-{
- switch (type)
- {
- default:
- case G_SEEK_CUR:
- return SEEK_CUR;
-
- case G_SEEK_SET:
- return SEEK_SET;
-
- case G_SEEK_END:
- return SEEK_END;
- }
-}
-
-static gboolean
-g_local_file_input_stream_seek (GFileInputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileInputStream *file;
- off_t pos;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- pos = lseek (file->priv->fd, offset, seek_type_to_lseek (type));
-
- if (pos == (off_t)-1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error seeking in file: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-static GFileInfo *
-g_local_file_input_stream_get_file_info (GFileInputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileInputStream *file;
-
- file = G_LOCAL_FILE_INPUT_STREAM (stream);
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- return _g_local_file_info_get_from_fd (file->priv->fd,
- attributes,
- error);
-}
diff --git a/gio/glocalfileinputstream.h b/gio/glocalfileinputstream.h
deleted file mode 100644
index c6dead5d..00000000
--- a/gio/glocalfileinputstream.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __G_LOCAL_FILE_INPUT_STREAM_H__
-#define __G_LOCAL_FILE_INPUT_STREAM_H__
-
-#include <gio/gfileinputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOCAL_FILE_INPUT_STREAM (g_local_file_input_stream_get_type ())
-#define G_LOCAL_FILE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_LOCAL_FILE_INPUT_STREAM, GLocalFileInputStream))
-#define G_LOCAL_FILE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_LOCAL_FILE_INPUT_STREAM, GLocalFileInputStreamClass))
-#define G_IS_LOCAL_FILE_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_LOCAL_FILE_INPUT_STREAM))
-#define G_IS_LOCAL_FILE_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_LOCAL_FILE_INPUT_STREAM))
-#define G_LOCAL_FILE_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_LOCAL_FILE_INPUT_STREAM, GLocalFileInputStreamClass))
-
-typedef struct _GLocalFileInputStream GLocalFileInputStream;
-typedef struct _GLocalFileInputStreamClass GLocalFileInputStreamClass;
-typedef struct _GLocalFileInputStreamPrivate GLocalFileInputStreamPrivate;
-
-struct _GLocalFileInputStream
-{
- GFileInputStream parent;
-
- /*< private >*/
- GLocalFileInputStreamPrivate *priv;
-};
-
-struct _GLocalFileInputStreamClass
-{
- GFileInputStreamClass parent_class;
-};
-
-GType g_local_file_input_stream_get_type (void) G_GNUC_CONST;
-
-GFileInputStream *g_local_file_input_stream_new (int fd);
-
-G_END_DECLS
-
-#endif /* __G_LOCAL_FILE_INPUT_STREAM_H__ */
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
deleted file mode 100644
index 49682003..00000000
--- a/gio/glocalfilemonitor.c
+++ /dev/null
@@ -1,161 +0,0 @@
-#include <config.h>
-
-#include "glocalfilemonitor.h"
-
-#if defined(HAVE_LINUX_INOTIFY_H) || defined(HAVE_SYS_INOTIFY_H)
-#define USE_INOTIFY 1
-#include "inotify/inotify-helper.h"
-#endif
-
-#ifdef HAVE_FAM
-#include "fam/fam-helper.h"
-#endif
-
-static gboolean g_local_file_monitor_cancel (GFileMonitor* monitor);
-
-typedef enum {
- BACKEND_NONE,
- BACKEND_INOTIFY,
- BACKEND_FAM,
-} LocalMonitorBackend;
-
-struct _GLocalFileMonitor
-{
- GFileMonitor parent_instance;
- gchar *dirname;
- gchar *filename;
- LocalMonitorBackend active_backend;
- void *private; /* backend stuff goes here */
-};
-
-G_DEFINE_TYPE (GLocalFileMonitor, g_local_file_monitor, G_TYPE_FILE_MONITOR)
-
-static void
-g_local_file_monitor_finalize (GObject* object)
-{
- GLocalFileMonitor* local_monitor;
-
- local_monitor = G_LOCAL_FILE_MONITOR (object);
-
- if (local_monitor->dirname)
- g_free (local_monitor->dirname);
-
- if (local_monitor->filename)
- g_free (local_monitor->filename);
-
- if (G_OBJECT_CLASS (g_local_file_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_local_file_monitor_parent_class)->finalize) (object);
-}
-
-
-static void
-g_local_file_monitor_class_init (GLocalFileMonitorClass* klass)
-{
- GObjectClass* gobject_class = G_OBJECT_CLASS (klass);
- GFileMonitorClass *file_monitor_class = G_FILE_MONITOR_CLASS (klass);
-
- gobject_class->finalize = g_local_file_monitor_finalize;
-
- file_monitor_class->cancel = g_local_file_monitor_cancel;
-}
-
-static void
-g_local_file_monitor_init (GLocalFileMonitor* local_monitor)
-{
- local_monitor->private = NULL;
- local_monitor->dirname = NULL;
- local_monitor->filename = NULL;
-}
-
-GFileMonitor*
-g_local_file_monitor_new (const char* pathname,
- GFileMonitorFlags flags)
-{
- GLocalFileMonitor* local_monitor;
- LocalMonitorBackend backend;
-
- local_monitor = g_object_new (G_TYPE_LOCAL_FILE_MONITOR, NULL);
-
- local_monitor->dirname = g_path_get_dirname (pathname);
- local_monitor->filename = g_path_get_basename (pathname);
-
- backend = BACKEND_NONE;
-
-#ifdef USE_INOTIFY
- if (backend == BACKEND_NONE)
- {
- inotify_sub* sub;
- if (_ih_startup ())
- {
- sub = _ih_sub_new (local_monitor->dirname, local_monitor->filename, local_monitor);
- if (sub)
- {
- if (_ih_sub_add (sub))
- {
- local_monitor->private = sub;
- backend = BACKEND_INOTIFY;
- }
- else
- _ih_sub_free (sub);
- }
- }
- }
-#endif
-
-#ifdef HAVE_FAM
- if (backend == BACKEND_NONE)
- {
- fam_sub* sub;
- sub = _fam_sub_add (pathname, FALSE, local_monitor);
- if (sub)
- {
- local_monitor->private = sub;
- backend = BACKEND_FAM;
- }
- }
-#endif
-
- local_monitor->active_backend = backend;
-
-
- if (backend != BACKEND_NONE)
- return G_FILE_MONITOR (local_monitor);
-
- g_object_unref (local_monitor);
- return NULL;
-}
-
-static gboolean
-g_local_file_monitor_cancel (GFileMonitor* monitor)
-{
- GLocalFileMonitor *local_monitor = G_LOCAL_FILE_MONITOR (monitor);
-
-#ifdef USE_INOTIFY
- if (local_monitor->active_backend == BACKEND_INOTIFY)
- {
- inotify_sub* sub = local_monitor->private;
- if (sub)
- {
- _ih_sub_cancel (sub);
- _ih_sub_free (sub);
- local_monitor->private = NULL;
- }
- }
-#endif
-
-#ifdef HAVE_FAM
- if (local_monitor->active_backend == BACKEND_FAM)
- {
- fam_sub* sub = local_monitor->private;
- if (sub)
- {
- if (!_fam_sub_cancel (sub))
- g_warning ("Unexpected error canceling fam monitor");
- _fam_sub_free (sub);
- local_monitor->private = NULL;
- }
- }
-#endif
-
- return TRUE;
-}
diff --git a/gio/glocalfilemonitor.h b/gio/glocalfilemonitor.h
deleted file mode 100644
index e26761ec..00000000
--- a/gio/glocalfilemonitor.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __G_LOCAL_FILE_MONITOR_H__
-#define __G_LOCAL_FILE_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/gfilemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOCAL_FILE_MONITOR (g_local_file_monitor_get_type ())
-#define G_LOCAL_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_LOCAL_FILE_MONITOR, GLocalFileMonitor))
-#define G_LOCAL_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), G_TYPE_LOCAL_FILE_MONITOR, GLocalFileMonitorClass))
-#define G_IS_LOCAL_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_LOCAL_FILE_MONITOR))
-#define G_IS_LOCAL_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_LOCAL_FILE_MONITOR))
-
-typedef struct _GLocalFileMonitor GLocalFileMonitor;
-typedef struct _GLocalFileMonitorClass GLocalFileMonitorClass;
-
-struct _GLocalFileMonitorClass {
- GFileMonitorClass parent_class;
-};
-
-GType g_local_file_monitor_get_type (void) G_GNUC_CONST;
-
-GFileMonitor* g_local_file_monitor_new (const char* dirname,
- GFileMonitorFlags flags);
-
-G_END_DECLS
-
-#endif /* __G_LOCAL_FILE_MONITOR_H__ */
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
deleted file mode 100644
index 07c54887..00000000
--- a/gio/glocalfileoutputstream.c
+++ /dev/null
@@ -1,840 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n-lib.h>
-#include "gioerror.h"
-#include "glocalfileoutputstream.h"
-#include "glocalfileinfo.h"
-
-G_DEFINE_TYPE (GLocalFileOutputStream, g_local_file_output_stream, G_TYPE_FILE_OUTPUT_STREAM);
-
-/* Some of the file replacement code was based on the code from gedit,
- * relicenced to LGPL with permissions from the authors.
- */
-
-#define BACKUP_EXTENSION "~"
-
-struct _GLocalFileOutputStreamPrivate {
- char *tmp_filename;
- char *original_filename;
- char *backup_filename;
- char *etag;
- int fd;
-};
-
-static gssize g_local_file_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_local_file_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static GFileInfo *g_local_file_output_stream_get_file_info (GFileOutputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error);
-static char * g_local_file_output_stream_get_etag (GFileOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static goffset g_local_file_output_stream_tell (GFileOutputStream *stream);
-static gboolean g_local_file_output_stream_can_seek (GFileOutputStream *stream);
-static gboolean g_local_file_output_stream_seek (GFileOutputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_local_file_output_stream_can_truncate (GFileOutputStream *stream);
-static gboolean g_local_file_output_stream_truncate (GFileOutputStream *stream,
- goffset size,
- GCancellable *cancellable,
- GError **error);
-
-static void
-g_local_file_output_stream_finalize (GObject *object)
-{
- GLocalFileOutputStream *file;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (object);
-
- g_free (file->priv->tmp_filename);
- g_free (file->priv->original_filename);
- g_free (file->priv->backup_filename);
- g_free (file->priv->etag);
-
- if (G_OBJECT_CLASS (g_local_file_output_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_local_file_output_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_local_file_output_stream_class_init (GLocalFileOutputStreamClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GOutputStreamClass *stream_class = G_OUTPUT_STREAM_CLASS (klass);
- GFileOutputStreamClass *file_stream_class = G_FILE_OUTPUT_STREAM_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GLocalFileOutputStreamPrivate));
-
- gobject_class->finalize = g_local_file_output_stream_finalize;
-
- stream_class->write = g_local_file_output_stream_write;
- stream_class->close = g_local_file_output_stream_close;
- file_stream_class->get_file_info = g_local_file_output_stream_get_file_info;
- file_stream_class->get_etag = g_local_file_output_stream_get_etag;
- file_stream_class->tell = g_local_file_output_stream_tell;
- file_stream_class->can_seek = g_local_file_output_stream_can_seek;
- file_stream_class->seek = g_local_file_output_stream_seek;
- file_stream_class->can_truncate = g_local_file_output_stream_can_truncate;
- file_stream_class->truncate = g_local_file_output_stream_truncate;
-}
-
-static void
-g_local_file_output_stream_init (GLocalFileOutputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_LOCAL_FILE_OUTPUT_STREAM,
- GLocalFileOutputStreamPrivate);
-}
-
-static gssize
-g_local_file_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *file;
- gssize res;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- while (1)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return -1;
- res = write (file->priv->fd, buffer, count);
- if (res == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error writing to file': %s"),
- g_strerror (errno));
- }
-
- break;
- }
-
- return res;
-}
-
-static gboolean
-g_local_file_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *file;
- struct stat final_stat;
- int res;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- if (file->priv->tmp_filename)
- {
- /* We need to move the temp file to its final place,
- * and possibly create the backup file
- */
-
- if (file->priv->backup_filename)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- goto err_out;
-
-#ifdef HAVE_LINK
- /* create original -> backup link, the original is then renamed over */
- if (unlink (file->priv->backup_filename) != 0)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Error removing old backup link: %s"),
- g_strerror (errno));
- goto err_out;
- }
-
- if (link (file->priv->original_filename, file->priv->backup_filename) != 0)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Error creating backup link: %s"),
- g_strerror (errno));
- goto err_out;
- }
-#else
- /* If link not supported, just rename... */
- if (!rename (file->priv->original_filename, file->priv->backup_filename) != 0)
- {
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Error creating backup copy: %s"),
- g_strerror (errno));
- goto err_out;
- }
-#endif
- }
-
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- goto err_out;
-
- /* tmp -> original */
- if (rename (file->priv->tmp_filename, file->priv->original_filename) != 0)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error renamining temporary file: %s"),
- g_strerror (errno));
- goto err_out;
- }
- }
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- goto err_out;
-
- if (fstat (file->priv->fd, &final_stat) == 0)
- file->priv->etag = _g_local_file_info_create_etag (&final_stat);
-
- while (1)
- {
- res = close (file->priv->fd);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing file: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- return res != -1;
-
- err_out:
- /* A simple try to close the fd in case we fail before the actual close */
- close (file->priv->fd);
- return FALSE;
-}
-
-static char *
-g_local_file_output_stream_get_etag (GFileOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *file;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- return g_strdup (file->priv->etag);
-}
-
-static goffset
-g_local_file_output_stream_tell (GFileOutputStream *stream)
-{
- GLocalFileOutputStream *file;
- off_t pos;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- pos = lseek (file->priv->fd, 0, SEEK_CUR);
-
- if (pos == (off_t)-1)
- return 0;
-
- return pos;
-}
-
-static gboolean
-g_local_file_output_stream_can_seek (GFileOutputStream *stream)
-{
- GLocalFileOutputStream *file;
- off_t pos;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- pos = lseek (file->priv->fd, 0, SEEK_CUR);
-
- if (pos == (off_t)-1 &&
- errno == ESPIPE)
- return FALSE;
-
- return TRUE;
-}
-
-static int
-seek_type_to_lseek (GSeekType type)
-{
- switch (type)
- {
- default:
- case G_SEEK_CUR:
- return SEEK_CUR;
-
- case G_SEEK_SET:
- return SEEK_SET;
-
- case G_SEEK_END:
- return SEEK_END;
- }
-}
-
-static gboolean
-g_local_file_output_stream_seek (GFileOutputStream *stream,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *file;
- off_t pos;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- pos = lseek (file->priv->fd, offset, seek_type_to_lseek (type));
-
- if (pos == (off_t)-1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error seeking in file: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-g_local_file_output_stream_can_truncate (GFileOutputStream *stream)
-{
- /* We can't truncate pipes and stuff where we can't seek */
- return g_local_file_output_stream_can_seek (stream);
-}
-
-static gboolean
-g_local_file_output_stream_truncate (GFileOutputStream *stream,
- goffset size,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *file;
- int res;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- restart:
- res = ftruncate(file->priv->fd, size);
-
- if (res == -1)
- {
- if (errno == EINTR)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return FALSE;
- goto restart;
- }
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error truncating file: %s"),
- g_strerror (errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-static GFileInfo *
-g_local_file_output_stream_get_file_info (GFileOutputStream *stream,
- char *attributes,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *file;
-
- file = G_LOCAL_FILE_OUTPUT_STREAM (stream);
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- return _g_local_file_info_get_from_fd (file->priv->fd,
- attributes,
- error);
-}
-
-GFileOutputStream *
-g_local_file_output_stream_create (const char *filename,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *stream;
- int fd;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- fd = g_open (filename,
- O_CREAT | O_EXCL | O_WRONLY,
- 0666);
- if (fd == -1)
- {
- int errsv = errno;
-
- if (errsv == EINVAL)
- /* This must be an invalid filename, on e.g. FAT */
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename"));
- else
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error opening file '%s': %s"),
- filename, g_strerror (errsv));
- return NULL;
- }
-
- stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL);
- stream->priv->fd = fd;
- return G_FILE_OUTPUT_STREAM (stream);
-}
-
-GFileOutputStream *
-g_local_file_output_stream_append (const char *filename,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *stream;
- int fd;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- fd = g_open (filename,
- O_CREAT | O_APPEND | O_WRONLY,
- 0666);
- if (fd == -1)
- {
- int errsv = errno;
-
- if (errsv == EINVAL)
- /* This must be an invalid filename, on e.g. FAT */
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename"));
- else
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error opening file '%s': %s"),
- filename, g_strerror (errsv));
- return NULL;
- }
-
- stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL);
- stream->priv->fd = fd;
-
- return G_FILE_OUTPUT_STREAM (stream);
-}
-
-static char *
-create_backup_filename (const char *filename)
-{
- return g_strconcat (filename, BACKUP_EXTENSION, NULL);
-}
-
-#define BUFSIZE 8192 /* size of normal write buffer */
-
-static gboolean
-copy_file_data (gint sfd,
- gint dfd,
- GError **error)
-{
- gboolean ret = TRUE;
- gpointer buffer;
- const gchar *write_buffer;
- ssize_t bytes_read;
- ssize_t bytes_to_write;
- ssize_t bytes_written;
-
- buffer = g_malloc (BUFSIZE);
-
- do
- {
- bytes_read = read (sfd, buffer, BUFSIZE);
- if (bytes_read == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error reading from file': %s"),
- g_strerror (errno));
- ret = FALSE;
- break;
- }
-
- bytes_to_write = bytes_read;
- write_buffer = buffer;
-
- do
- {
- bytes_written = write (dfd, write_buffer, bytes_to_write);
- if (bytes_written == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error writing to file: %s"),
- g_strerror (errno));
- ret = FALSE;
- break;
- }
-
- bytes_to_write -= bytes_written;
- write_buffer += bytes_written;
- }
- while (bytes_to_write > 0);
-
- } while ((bytes_read != 0) && (ret == TRUE));
-
- g_free (buffer);
-
- return ret;
-}
-
-static int
-handle_overwrite_open (const char *filename,
- const char *etag,
- gboolean create_backup,
- char **temp_filename,
- GCancellable *cancellable,
- GError **error)
-{
- int fd = -1;
- struct stat original_stat;
- char *current_etag;
- gboolean is_symlink;
- int open_flags;
-
- /* We only need read access to the original file if we are creating a backup.
- * We also add O_CREATE to avoid a race if the file was just removed */
- if (create_backup)
- open_flags = O_RDWR | O_CREAT;
- else
- open_flags = O_WRONLY | O_CREAT;
-
- /* Some systems have O_NOFOLLOW, which lets us avoid some races
- * when finding out if the file we opened was a symlink */
-#ifdef O_NOFOLLOW
- is_symlink = FALSE;
- fd = g_open (filename, open_flags | O_NOFOLLOW, 0666);
- if (fd == -1 && errno == ELOOP)
- {
- /* Could be a symlink, or it could be a regular ELOOP error,
- * but then the next open will fail too. */
- is_symlink = TRUE;
- fd = g_open (filename, open_flags, 0666);
- }
-#else
- fd = g_open (filename, open_flags, 0666);
- /* This is racy, but we do it as soon as possible to minimize the race */
- is_symlink = g_file_test (filename, G_FILE_TEST_IS_SYMLINK);
-#endif
-
- if (fd == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error opening file '%s': %s"),
- filename, g_strerror (errno));
- return -1;
- }
-
- if (fstat (fd, &original_stat) != 0)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error stating file '%s': %s"),
- filename, g_strerror (errno));
- goto err_out;
- }
-
- /* not a regular file */
- if (!S_ISREG (original_stat.st_mode))
- {
- if (S_ISDIR (original_stat.st_mode))
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_IS_DIRECTORY,
- _("Target file is a directory"));
- else
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_NOT_REGULAR_FILE,
- _("Target file is not a regular file"));
- goto err_out;
- }
-
- if (etag != NULL)
- {
- current_etag = _g_local_file_info_create_etag (&original_stat);
- if (strcmp (etag, current_etag) != 0)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_WRONG_ETAG,
- _("The file was externally modified"));
- g_free (current_etag);
- goto err_out;
- }
- g_free (current_etag);
- }
-
- /* We use two backup strategies.
- * The first one (which is faster) consist in saving to a
- * tmp file then rename the original file to the backup and the
- * tmp file to the original name. This is fast but doesn't work
- * when the file is a link (hard or symbolic) or when we can't
- * write to the current dir or can't set the permissions on the
- * new file.
- * The second strategy consist simply in copying the old file
- * to a backup file and rewrite the contents of the file.
- */
-
- if (!(original_stat.st_nlink > 1) && !is_symlink)
- {
- char *dirname, *tmp_filename;
- int tmpfd;
-
- dirname = g_path_get_dirname (filename);
- tmp_filename = g_build_filename (dirname, ".goutputstream-XXXXXX", NULL);
- g_free (dirname);
-
- tmpfd = g_mkstemp (tmp_filename);
- if (tmpfd == -1)
- {
- g_free (tmp_filename);
- goto fallback_strategy;
- }
-
- /* try to keep permissions */
-
- if (
-#ifdef F_CHOWN
- fchown (tmpfd, original_stat.st_uid, original_stat.st_gid) == -1 ||
-#endif
-#ifdef F_CHMOD
- fchmod (tmpfd, original_stat.st_mode) == -1 ||
-#endif
- 0
- )
- {
- struct stat tmp_statbuf;
-
- /* Check that we really needed to change something */
- if (fstat (tmpfd, &tmp_statbuf) != 0 ||
- original_stat.st_uid != tmp_statbuf.st_uid ||
- original_stat.st_gid != tmp_statbuf.st_gid ||
- original_stat.st_mode != tmp_statbuf.st_mode)
- {
- close (tmpfd);
- unlink (tmp_filename);
- g_free (tmp_filename);
- goto fallback_strategy;
- }
- }
-
- close (fd);
- *temp_filename = tmp_filename;
- return tmpfd;
- }
-
- fallback_strategy:
-
- if (create_backup)
- {
- struct stat tmp_statbuf;
- char *backup_filename;
- int bfd;
-
- backup_filename = create_backup_filename (filename);
-
- if (unlink (backup_filename) == -1 && errno != ENOENT)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Backup file creation failed"));
- g_free (backup_filename);
- goto err_out;
- }
-
- bfd = g_open (backup_filename,
- O_WRONLY | O_CREAT | O_EXCL,
- original_stat.st_mode & 0777);
-
- if (bfd == -1)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Backup file creation failed"));
- g_free (backup_filename);
- goto err_out;
- }
-
- /* If needed, Try to set the group of the backup same as the
- * original file. If this fails, set the protection
- * bits for the group same as the protection bits for
- * others. */
-#ifdef HAVE_FCHOWN
- if (fstat (bfd, &tmp_statbuf) != 0)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Backup file creation failed"));
- unlink (backup_filename);
- g_free (backup_filename);
- goto err_out;
- }
-
- if ((original_stat.st_gid != tmp_statbuf.st_gid) &&
- fchown (bfd, (uid_t) -1, original_stat.st_gid) != 0)
- {
- if (fchmod (bfd,
- (original_stat.st_mode & 0707) |
- ((original_stat.st_mode & 07) << 3)) != 0)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Backup file creation failed"));
- unlink (backup_filename);
- close (bfd);
- g_free (backup_filename);
- goto err_out;
- }
- }
-#endif
-
- if (!copy_file_data (fd, bfd, NULL))
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_CANT_CREATE_BACKUP,
- _("Backup file creation failed"));
- unlink (backup_filename);
- close (bfd);
- g_free (backup_filename);
-
- goto err_out;
- }
-
- close (bfd);
- g_free (backup_filename);
-
- /* Seek back to the start of the file after the backup copy */
- if (lseek (fd, 0, SEEK_SET) == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error seeking in file: %s"),
- g_strerror (errno));
- goto err_out;
- }
- }
-
- /* Truncate the file at the start */
- if (ftruncate (fd, 0) == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error truncating file: %s"),
- g_strerror (errno));
- goto err_out;
- }
-
- return fd;
-
- err_out:
- close (fd);
- return -1;
-}
-
-GFileOutputStream *
-g_local_file_output_stream_replace (const char *filename,
- const char *etag,
- gboolean create_backup,
- GCancellable *cancellable,
- GError **error)
-{
- GLocalFileOutputStream *stream;
- int fd;
- char *temp_file;
-
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return NULL;
-
- temp_file = NULL;
- /* If the file doesn't exist, create it */
- fd = g_open (filename,
- O_CREAT | O_EXCL | O_WRONLY,
- 0666);
-
- if (fd == -1 && errno == EEXIST)
- {
- /* The file already exists */
- fd = handle_overwrite_open (filename, etag, create_backup, &temp_file,
- cancellable, error);
- if (fd == -1)
- return NULL;
- }
- else if (fd == -1)
- {
- int errsv = errno;
-
- if (errsv == EINVAL)
- /* This must be an invalid filename, on e.g. FAT */
- g_set_error (error, G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("Invalid filename"));
- else
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errsv),
- _("Error opening file '%s': %s"),
- filename, g_strerror (errsv));
- return NULL;
- }
-
-
- stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL);
- stream->priv->fd = fd;
- stream->priv->tmp_filename = temp_file;
- if (create_backup)
- stream->priv->backup_filename = create_backup_filename (filename);
- stream->priv->original_filename = g_strdup (filename);
-
- return G_FILE_OUTPUT_STREAM (stream);
-}
diff --git a/gio/glocalfileoutputstream.h b/gio/glocalfileoutputstream.h
deleted file mode 100644
index e45a1684..00000000
--- a/gio/glocalfileoutputstream.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __G_LOCAL_FILE_OUTPUT_STREAM_H__
-#define __G_LOCAL_FILE_OUTPUT_STREAM_H__
-
-#include <gio/gfileoutputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOCAL_FILE_OUTPUT_STREAM (g_local_file_output_stream_get_type ())
-#define G_LOCAL_FILE_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_LOCAL_FILE_OUTPUT_STREAM, GLocalFileOutputStream))
-#define G_LOCAL_FILE_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_LOCAL_FILE_OUTPUT_STREAM, GLocalFileOutputStreamClass))
-#define G_IS_LOCAL_FILE_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_LOCAL_FILE_OUTPUT_STREAM))
-#define G_IS_LOCAL_FILE_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_LOCAL_FILE_OUTPUT_STREAM))
-#define G_LOCAL_FILE_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_LOCAL_FILE_OUTPUT_STREAM, GLocalFileOutputStreamClass))
-
-typedef struct _GLocalFileOutputStream GLocalFileOutputStream;
-typedef struct _GLocalFileOutputStreamClass GLocalFileOutputStreamClass;
-typedef struct _GLocalFileOutputStreamPrivate GLocalFileOutputStreamPrivate;
-
-struct _GLocalFileOutputStream
-{
- GFileOutputStream parent;
-
- /*< private >*/
- GLocalFileOutputStreamPrivate *priv;
-};
-
-struct _GLocalFileOutputStreamClass
-{
- GFileOutputStreamClass parent_class;
-};
-
-GType g_local_file_output_stream_get_type (void) G_GNUC_CONST;
-GFileOutputStream *g_local_file_output_stream_create (const char *filename,
- GCancellable *cancellable,
- GError **error);
-GFileOutputStream *g_local_file_output_stream_append (const char *filename,
- GCancellable *cancellable,
- GError **error);
-GFileOutputStream *g_local_file_output_stream_replace (const char *filename,
- const char *etag,
- gboolean make_backup,
- GCancellable *cancellable,
- GError **error);
-
-
-G_END_DECLS
-
-#endif /* __G_LOCAL_FILE_OUTPUT_STREAM_H__ */
diff --git a/gio/glocalvfs.c b/gio/glocalvfs.c
deleted file mode 100644
index ab4b6417..00000000
--- a/gio/glocalvfs.c
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <config.h>
-#include "glocalvfs.h"
-#include "glocalfile.h"
-#include <gio/gdummyfile.h>
-
-struct _GLocalVfs
-{
- GVfs parent;
-};
-
-struct _GLocalVfsClass
-{
- GVfsClass parent_class;
-
-};
-
-G_DEFINE_TYPE (GLocalVfs, g_local_vfs, G_TYPE_VFS)
-
-static void
-g_local_vfs_finalize (GObject *object)
-{
- /* must chain up */
- G_OBJECT_CLASS (g_local_vfs_parent_class)->finalize (object);
-}
-
-static void
-g_local_vfs_init (GLocalVfs *vfs)
-{
-}
-
-GVfs *
-g_local_vfs_new (void)
-{
- return g_object_new (G_TYPE_LOCAL_VFS, NULL);
-}
-
-static GFile *
-g_local_vfs_get_file_for_path (GVfs *vfs,
- const char *path)
-{
- return g_local_file_new (path);
-}
-
-static GFile *
-g_local_vfs_get_file_for_uri (GVfs *vfs,
- const char *uri)
-{
- char *path;
- GFile *file;
-
- path = g_filename_from_uri (uri, NULL, NULL);
-
- if (path != NULL)
- file = g_local_file_new (path);
- else
- file = g_dummy_file_new (uri);
-
- g_free (path);
-
- return file;
-}
-
-static GFile *
-g_local_vfs_parse_name (GVfs *vfs,
- const char *parse_name)
-{
- GFile *file;
- char *filename;
-
- g_return_val_if_fail (G_IS_VFS (vfs), NULL);
- g_return_val_if_fail (parse_name != NULL, NULL);
-
- if (g_ascii_strncasecmp ("file:", parse_name, 5))
- filename = g_filename_from_uri (parse_name, NULL, NULL);
- else
- filename = g_filename_from_utf8 (parse_name, -1, NULL, NULL, NULL);
-
- file = g_local_file_new (filename);
- g_free (filename);
-
- return file;
-}
-
-static const char *
-g_local_vfs_get_name (GVfs *vfs)
-{
- return "local";
-}
-
-static int
-g_local_vfs_get_priority (GVfs *vfs)
-{
- return 0;
-}
-
-static void
-g_local_vfs_class_init (GLocalVfsClass *class)
-{
- GObjectClass *object_class;
- GVfsClass *vfs_class;
-
- object_class = (GObjectClass *) class;
-
- object_class->finalize = g_local_vfs_finalize;
-
- vfs_class = G_VFS_CLASS (class);
-
- vfs_class->get_name = g_local_vfs_get_name;
- vfs_class->get_priority = g_local_vfs_get_priority;
- vfs_class->get_file_for_path = g_local_vfs_get_file_for_path;
- vfs_class->get_file_for_uri = g_local_vfs_get_file_for_uri;
- vfs_class->parse_name = g_local_vfs_parse_name;
-}
diff --git a/gio/glocalvfs.h b/gio/glocalvfs.h
deleted file mode 100644
index 31c4cef6..00000000
--- a/gio/glocalvfs.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __G_LOCAL_VFS_H__
-#define __G_LOCAL_VFS_H__
-
-#include <gio/gvfs.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_LOCAL_VFS (g_local_vfs_get_type ())
-#define G_LOCAL_VFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_LOCAL_VFS, GLocalVfs))
-#define G_LOCAL_VFS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_LOCAL_VFS, GLocalVfsClass))
-#define G_IS_LOCAL_VFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_LOCAL_VFS))
-#define G_IS_LOCAL_VFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_LOCAL_VFS))
-#define G_LOCAL_VFS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_LOCAL_VFS, GLocalVfsClass))
-
-typedef struct _GLocalVfs GLocalVfs;
-typedef struct _GLocalVfsClass GLocalVfsClass;
-
-GType g_local_vfs_get_type (void) G_GNUC_CONST;
-
-GVfs *g_local_vfs_new (void);
-
-
-G_END_DECLS
-
-#endif /* __G_LOCAL_VFS_H__ */
diff --git a/gio/gmemoryinputstream.c b/gio/gmemoryinputstream.c
deleted file mode 100644
index a6f0ede4..00000000
--- a/gio/gmemoryinputstream.c
+++ /dev/null
@@ -1,369 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-
-#include "gmemoryinputstream.h"
-#include "ginputstream.h"
-#include "gseekable.h"
-#include "string.h"
-#include "gsimpleasyncresult.h"
-
-struct _GMemoryInputStreamPrivate {
-
- const guint8 *buffer;
- gsize pos;
- gsize len;
-
-};
-
-static gssize g_memory_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gssize g_memory_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_memory_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static void g_memory_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-static gssize g_memory_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_memory_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer datae);
-static gssize g_memory_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_memory_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_memory_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-static void g_memory_input_stream_seekable_iface_init (GSeekableIface *iface);
-static goffset g_memory_input_stream_tell (GSeekable *seekable);
-static gboolean g_memory_input_stream_can_seek (GSeekable *seekable);
-static gboolean g_memory_input_stream_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_memory_input_stream_can_truncate (GSeekable *seekable);
-static gboolean g_memory_input_stream_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error);
-
-G_DEFINE_TYPE_WITH_CODE (GMemoryInputStream, g_memory_input_stream, G_TYPE_INPUT_STREAM,
- G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
- g_memory_input_stream_seekable_iface_init))
-
-
-static void
-g_memory_input_stream_class_init (GMemoryInputStreamClass *klass)
-{
- GInputStreamClass *istream_class;
-
- g_type_class_add_private (klass, sizeof (GMemoryInputStreamPrivate));
-
- istream_class = G_INPUT_STREAM_CLASS (klass);
- istream_class->read = g_memory_input_stream_read;
- istream_class->skip = g_memory_input_stream_skip;
- istream_class->close = g_memory_input_stream_close;
-
- istream_class->read_async = g_memory_input_stream_read_async;
- istream_class->read_finish = g_memory_input_stream_read_finish;
- istream_class->skip_async = g_memory_input_stream_skip_async;
- istream_class->skip_finish = g_memory_input_stream_skip_finish;
- istream_class->close_async = g_memory_input_stream_close_async;
- istream_class->close_finish = g_memory_input_stream_close_finish;
-}
-
-static void
-g_memory_input_stream_seekable_iface_init (GSeekableIface *iface)
-{
- iface->tell = g_memory_input_stream_tell;
- iface->can_seek = g_memory_input_stream_can_seek;
- iface->seek = g_memory_input_stream_seek;
- iface->can_truncate = g_memory_input_stream_can_truncate;
- iface->truncate = g_memory_input_stream_truncate;
-}
-
-
-static void
-g_memory_input_stream_init (GMemoryInputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_MEMORY_INPUT_STREAM,
- GMemoryInputStreamPrivate);
-}
-
-GInputStream *
-g_memory_input_stream_from_data (const void *data, gsize len)
-{
- GInputStream *stream;
- GMemoryInputStream *memory_stream;
-
- g_return_val_if_fail (data != NULL, NULL);
-
- stream = g_object_new (G_TYPE_MEMORY_INPUT_STREAM, NULL);
- memory_stream = G_MEMORY_INPUT_STREAM (stream);
-
- memory_stream->priv->buffer = data;
- memory_stream->priv->len = len;
-
- return stream;
-
-}
-
-static gssize
-g_memory_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GMemoryInputStream *memory_stream;
- GMemoryInputStreamPrivate * priv;
-
- memory_stream = G_MEMORY_INPUT_STREAM (stream);
- priv = memory_stream->priv;
-
- count = MIN (count, priv->len - priv->pos);
- memcpy (buffer, priv->buffer + priv->pos, count);
- priv->pos += count;
-
- return count;
-}
-static gssize
-g_memory_input_stream_skip (GInputStream *stream,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GMemoryInputStream *memory_stream;
- GMemoryInputStreamPrivate *priv;
-
- memory_stream = G_MEMORY_INPUT_STREAM (stream);
- priv = memory_stream->priv;
-
- count = MIN (count, priv->len - priv->pos);
- priv->pos += count;
-
- return count;
-
-
-}
-
-static gboolean
-g_memory_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- return TRUE;
-}
-
-static void
-g_memory_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- gssize nread;
-
- nread = g_memory_input_stream_read (stream, buffer, count, cancellable, NULL);
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_memory_input_stream_read_async);
- g_simple_async_result_set_op_res_gssize (simple, nread);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
-}
-
-static gssize
-g_memory_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gssize nread;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- g_assert (g_simple_async_result_get_source_tag (simple) == g_memory_input_stream_read_async);
-
- nread = g_simple_async_result_get_op_res_gssize (simple);
- return nread;
-}
-
-static void
-g_memory_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- gssize nskipped;
-
- nskipped = g_memory_input_stream_skip (stream, count, cancellable, NULL);
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_memory_input_stream_skip_async);
- g_simple_async_result_set_op_res_gssize (simple, nskipped);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
-}
-
-static gssize
-g_memory_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gssize nskipped;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- g_assert (g_simple_async_result_get_source_tag (simple) == g_memory_input_stream_skip_async);
-
- nskipped = g_simple_async_result_get_op_res_gssize (simple);
- return nskipped;
-}
-
-static void
-g_memory_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_memory_input_stream_close_async);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
-}
-
-static gboolean
-g_memory_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- return TRUE;
-}
-
-static goffset
-g_memory_input_stream_tell (GSeekable *seekable)
-{
- GMemoryInputStream *memory_stream;
- GMemoryInputStreamPrivate * priv;
-
- memory_stream = G_MEMORY_INPUT_STREAM (seekable);
- priv = memory_stream->priv;
-
- return priv->pos;
-}
-
-static
-gboolean g_memory_input_stream_can_seek (GSeekable *seekable)
-{
- return TRUE;
-}
-
-static gboolean
-g_memory_input_stream_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- GMemoryInputStream *memory_stream;
- GMemoryInputStreamPrivate * priv;
- goffset absolute;
-
- memory_stream = G_MEMORY_INPUT_STREAM (seekable);
- priv = memory_stream->priv;
-
- switch (type) {
-
- case G_SEEK_CUR:
- absolute = priv->pos + offset;
- break;
-
- case G_SEEK_SET:
- absolute = offset;
- break;
-
- case G_SEEK_END:
- absolute = priv->len + offset;
- break;
-
- default:
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT,
- "Invalid GSeekType supplied");
-
- return FALSE;
- }
-
- if (absolute < 0 || absolute > priv->len)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT,
- "Invalid seek request");
- return FALSE;
- }
-
- priv->pos = absolute;
-
- return TRUE;
-}
-
-static gboolean
-g_memory_input_stream_can_truncate (GSeekable *seekable)
-{
- return FALSE;
-}
-
-static gboolean
-g_memory_input_stream_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error)
-{
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- "Cannot seek on GMemoryInputStream");
- return FALSE;
-}
-
-// vim: ts=2 sw=2 et
-
diff --git a/gio/gmemoryinputstream.h b/gio/gmemoryinputstream.h
deleted file mode 100644
index ca90f5d7..00000000
--- a/gio/gmemoryinputstream.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __G_MEMORY_INPUT_STREAM_H__
-#define __G_MEMORY_INPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/ginputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_MEMORY_INPUT_STREAM (g_memory_input_stream_get_type ())
-#define G_MEMORY_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MEMORY_INPUT_STREAM, GMemoryInputStream))
-#define G_MEMORY_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MEMORY_INPUT_STREAM, GMemoryInputStreamClass))
-#define G_IS_MEMORY_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MEMORY_INPUT_STREAM))
-#define G_IS_MEMORY_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MEMORY_INPUT_STREAM))
-#define G_MEMORY_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MEMORY_INPUT_STREAM, GMemoryInputStreamClass))
-
-typedef struct _GMemoryInputStream GMemoryInputStream;
-typedef struct _GMemoryInputStreamClass GMemoryInputStreamClass;
-typedef struct _GMemoryInputStreamPrivate GMemoryInputStreamPrivate;
-
-struct _GMemoryInputStream
-{
- GInputStream parent;
-
- /*< private >*/
- GMemoryInputStreamPrivate *priv;
-};
-
-struct _GMemoryInputStreamClass
-{
- GInputStreamClass parent_class;
-};
-
-
-GType g_memory_input_stream_get_type (void) G_GNUC_CONST;
-GInputStream * g_memory_input_stream_from_data (const void *data, gsize len);
-
-
-G_END_DECLS
-
-#endif /* __G_MEMORY_INPUT_STREAM_H__ */
diff --git a/gio/gmemoryoutputstream.c b/gio/gmemoryoutputstream.c
deleted file mode 100644
index d27a28a0..00000000
--- a/gio/gmemoryoutputstream.c
+++ /dev/null
@@ -1,608 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-
-#include "gmemoryoutputstream.h"
-#include "goutputstream.h"
-#include "gseekable.h"
-#include "gsimpleasyncresult.h"
-#include "string.h"
-
-/* TODO: Real P_() */
-#define P_(_x) (_x)
-
-struct _GMemoryOutputStreamPrivate {
-
- GByteArray *data;
- goffset pos;
-
- guint max_size;
- guint free_on_close : 1;
-};
-
-enum {
- PROP_0,
- PROP_DATA,
- PROP_FREE_ARRAY,
- PROP_SIZE_LIMIT
-};
-
-static void g_memory_output_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void g_memory_output_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gssize g_memory_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-
-static gboolean g_memory_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-
-static void g_memory_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_memory_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_memory_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_memory_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-static void g_memory_output_stream_seekable_iface_init (GSeekableIface *iface);
-static goffset g_memory_output_stream_tell (GSeekable *seekable);
-static gboolean g_memory_output_stream_can_seek (GSeekable *seekable);
-static gboolean g_memory_output_stream_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_memory_output_stream_can_truncate (GSeekable *seekable);
-static gboolean g_memory_output_stream_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error);
-
-G_DEFINE_TYPE_WITH_CODE (GMemoryOutputStream, g_memory_output_stream, G_TYPE_OUTPUT_STREAM,
- G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
- g_memory_output_stream_seekable_iface_init))
-
-
-static void
-g_memory_output_stream_class_init (GMemoryOutputStreamClass *klass)
-{
- GOutputStreamClass *ostream_class;
- GObjectClass *gobject_class;
-
- g_type_class_add_private (klass, sizeof (GMemoryOutputStreamPrivate));
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->get_property = g_memory_output_stream_get_property;
- gobject_class->set_property = g_memory_output_stream_set_property;
-
- ostream_class = G_OUTPUT_STREAM_CLASS (klass);
-
- ostream_class->write = g_memory_output_stream_write;
- ostream_class->close = g_memory_output_stream_close;
- ostream_class->write_async = g_memory_output_stream_write_async;
- ostream_class->write_finish = g_memory_output_stream_write_finish;
- ostream_class->close_async = g_memory_output_stream_close_async;
- ostream_class->close_finish = g_memory_output_stream_close_finish;
-
- g_object_class_install_property (gobject_class,
- PROP_DATA,
- g_param_spec_pointer ("data",
- P_("Data byte array"),
- P_("The byte array used as internal storage."),
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
-
- g_object_class_install_property (gobject_class,
- PROP_FREE_ARRAY,
- g_param_spec_boolean ("free-array",
- P_("Free array data"),
- P_("Wether or not the interal array should be free on close."),
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
- g_object_class_install_property (gobject_class,
- PROP_SIZE_LIMIT,
- g_param_spec_uint ("size-limit",
- P_("Limit"),
- P_("Maximum amount of bytes that can be written to the stream."),
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
-
-
-}
-
-static void
-g_memory_output_stream_seekable_iface_init (GSeekableIface *iface)
-{
- iface->tell = g_memory_output_stream_tell;
- iface->can_seek = g_memory_output_stream_can_seek;
- iface->seek = g_memory_output_stream_seek;
- iface->can_truncate = g_memory_output_stream_can_truncate;
- iface->truncate = g_memory_output_stream_truncate;
-}
-
-
-static void
-g_memory_output_stream_init (GMemoryOutputStream *stream)
-{
- GMemoryOutputStreamPrivate *priv;
-
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_MEMORY_OUTPUT_STREAM,
- GMemoryOutputStreamPrivate);
-
- priv = stream->priv;
- priv->data = NULL;
-}
-
-/**
- * g_memory_output_stream_new:
- * @data: a #GByteArray.
- *
- * Creates a new #GMemoryOutputStream. If @data is non-%NULL it will use
- * that for its internal storage otherwise it will create a new #GByteArray.
- * In both cases the internal #GByteArray can later be accessed through the
- * "data" property.
- *
- * Note: The new stream will not take ownership of the supplied
- * @data so you have to free it yourself after use or explicitly
- * ask for it be freed on close by setting the "free-array"
- * property to $TRUE.
- *
- * Return value: A newly created #GMemoryOutputStream object.
- **/
-GOutputStream *
-g_memory_output_stream_new (GByteArray *data)
-{
- GOutputStream *stream;
-
- if (data == NULL) {
- stream = g_object_new (G_TYPE_MEMORY_OUTPUT_STREAM, NULL);
- } else {
- stream = g_object_new (G_TYPE_MEMORY_OUTPUT_STREAM,
- "data", data,
- NULL);
- }
-
- return stream;
-}
-
-
-void
-g_memory_output_stream_set_max_size (GMemoryOutputStream *ostream,
- guint max_size)
-{
- GMemoryOutputStreamPrivate *priv;
- priv = ostream->priv;
-
- priv->max_size = max_size;
-
- if (priv->max_size > 0 &&
- priv->max_size < priv->data->len) {
-
- g_byte_array_set_size (priv->data, priv->max_size);
-
- if (priv->pos > priv->max_size) {
- priv->pos = priv->max_size;
- }
- }
-
- g_object_notify (G_OBJECT (ostream), "size-limit");
-}
-
-static void
-g_memory_output_stream_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GMemoryOutputStream *ostream;
- GMemoryOutputStreamPrivate *priv;
- GByteArray *data;
- guint max_size;
-
- ostream = G_MEMORY_OUTPUT_STREAM (object);
- priv = ostream->priv;
-
- switch (prop_id)
- {
- case PROP_DATA:
-
- if (priv->data && priv->free_on_close) {
- g_byte_array_free (priv->data, TRUE);
- }
-
- data = g_value_get_pointer (value);
-
- if (data == NULL) {
- data = g_byte_array_new ();
- priv->free_on_close = FALSE;
- } else {
- priv->free_on_close = TRUE;
- }
-
- priv->data = data;
- priv->pos = 0;
- g_object_notify (G_OBJECT (ostream), "data");
- break;
-
- case PROP_FREE_ARRAY:
- priv->free_on_close = g_value_get_boolean (value);
- break;
-
- case PROP_SIZE_LIMIT:
- max_size = g_value_get_uint (value);
- g_memory_output_stream_set_max_size (ostream, max_size);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-g_memory_output_stream_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GMemoryOutputStream *ostream;
- GMemoryOutputStreamPrivate *priv;
-
- ostream = G_MEMORY_OUTPUT_STREAM (object);
- priv = ostream->priv;
-
- switch (prop_id)
- {
- case PROP_DATA:
- g_value_set_pointer (value, priv->data);
- break;
-
- case PROP_FREE_ARRAY:
- g_value_set_boolean (value, priv->free_on_close);
- break;
-
- case PROP_SIZE_LIMIT:
- g_value_set_uint (value, priv->max_size);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-array_check_boundary (GMemoryOutputStream *stream,
- goffset size,
- GError **error)
-{
- GMemoryOutputStreamPrivate *priv;
-
- priv = stream->priv;
-
- if (! priv->max_size) {
- return TRUE;
- }
-
- if (priv->max_size < size || size > G_MAXUINT) {
-
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "Reached maximum data array limit");
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gssize
-array_resize (GMemoryOutputStream *stream,
- goffset size,
- GError **error)
-{
- GMemoryOutputStreamPrivate *priv;
- guint old_len;
-
- priv = stream->priv;
-
- if (! array_check_boundary (stream, size, error))
- return -1;
-
-
- if (priv->data->len == size)
- return priv->data->len - priv->pos;
-
-
- old_len = priv->data->len;
- g_byte_array_set_size (priv->data, size);
-
- if (size > old_len && priv->pos > old_len)
- memset (priv->data->data + priv->pos, 0, size - old_len);
-
-
- return priv->data->len - priv->pos;
-}
-
-static gssize
-g_memory_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GMemoryOutputStream *ostream;
- GMemoryOutputStreamPrivate *priv;
- gsize new_size;
- gssize n;
- guint8 *dest;
-
- ostream = G_MEMORY_OUTPUT_STREAM (stream);
- priv = ostream->priv;
-
- /* count < 0 is ensured by GOutputStream */
-
- n = MIN (count, priv->data->len - priv->pos);
-
- if (n < 1)
- {
- new_size = priv->pos + count;
-
- if (priv->max_size > 0)
- {
- new_size = MIN (new_size, priv->max_size);
- }
-
- n = array_resize (ostream, new_size, error);
-
- if (n == 0)
- {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "Reached maximum data array limit");
- return -1;
- }
- else if (n < 0)
- {
- return -1;
- }
- }
-
- dest = priv->data->data + priv->pos;
- memcpy (dest, buffer, n);
- priv->pos += n;
-
- return n;
-}
-
-static gboolean
-g_memory_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GMemoryOutputStream *ostream;
- GMemoryOutputStreamPrivate *priv;
-
- ostream = G_MEMORY_OUTPUT_STREAM (stream);
- priv = ostream->priv;
-
- if (priv->free_on_close) {
- g_byte_array_free (priv->data, TRUE);
- }
-
- return TRUE;
-}
-
-static void
-g_memory_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GSimpleAsyncResult *simple;
- gssize nwritten;
-
- nwritten = g_memory_output_stream_write (stream,
- buffer,
- count,
- cancellable,
- NULL);
-
-
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- data,
- g_memory_output_stream_write_async);
-
- g_simple_async_result_set_op_res_gssize (simple, nwritten);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
-
-}
-
-static gssize
-g_memory_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gssize nwritten;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_assert (g_simple_async_result_get_source_tag (simple) ==
- g_memory_output_stream_write_async);
-
- nwritten = g_simple_async_result_get_op_res_gssize (simple);
- return nwritten;
-}
-
-static void
-g_memory_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- data,
- g_memory_output_stream_close_async);
-
-
- /* will always return TRUE */
- g_memory_output_stream_close (stream, cancellable, NULL);
-
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
-
-}
-
-static gboolean
-g_memory_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
-
- g_assert (g_simple_async_result_get_source_tag (simple) ==
- g_memory_output_stream_close_async);
-
-
- return TRUE;
-}
-
-static goffset
-g_memory_output_stream_tell (GSeekable *seekable)
-{
- GMemoryOutputStream *stream;
- GMemoryOutputStreamPrivate *priv;
-
- stream = G_MEMORY_OUTPUT_STREAM (seekable);
- priv = stream->priv;
-
- return priv->pos;
-}
-
-static gboolean
-g_memory_output_stream_can_seek (GSeekable *seekable)
-{
- return TRUE;
-}
-
-static gboolean
-g_memory_output_stream_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- GMemoryOutputStream *stream;
- GMemoryOutputStreamPrivate *priv;
- goffset absolute;
-
- stream = G_MEMORY_OUTPUT_STREAM (seekable);
- priv = stream->priv;
-
- switch (type) {
-
- case G_SEEK_CUR:
- absolute = priv->pos + offset;
- break;
-
- case G_SEEK_SET:
- absolute = offset;
- break;
-
- case G_SEEK_END:
- absolute = priv->data->len + offset;
- break;
-
- default:
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT,
- "Invalid GSeekType supplied");
-
- return FALSE;
- }
-
- if (absolute < 0) {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT,
- "Invalid seek request");
- return FALSE;
- }
-
- if (! array_check_boundary (stream, absolute, error))
- return FALSE;
-
- priv->pos = absolute;
-
- return TRUE;
-}
-
-static gboolean
-g_memory_output_stream_can_truncate (GSeekable *seekable)
-{
- return TRUE;
-}
-
-static gboolean
-g_memory_output_stream_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error)
-{
- GMemoryOutputStream *ostream;
- GMemoryOutputStreamPrivate *priv;
-
- ostream = G_MEMORY_OUTPUT_STREAM (seekable);
- priv = ostream->priv;
-
- if (array_resize (ostream, offset, error) < 0)
- return FALSE;
-
- return TRUE;
-}
-
-
-/* vim: ts=2 sw=2 et */
-
diff --git a/gio/gmemoryoutputstream.h b/gio/gmemoryoutputstream.h
deleted file mode 100644
index 736bf85a..00000000
--- a/gio/gmemoryoutputstream.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef __G_MEMORY_OUTPUT_STREAM_H__
-#define __G_MEMORY_OUTPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/goutputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_MEMORY_OUTPUT_STREAM (g_memory_output_stream_get_type ())
-#define G_MEMORY_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStream))
-#define G_MEMORY_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStreamClass))
-#define G_IS_MEMORY_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MEMORY_OUTPUT_STREAM))
-#define G_IS_MEMORY_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MEMORY_OUTPUT_STREAM))
-#define G_MEMORY_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStreamClass))
-
-typedef struct _GMemoryOutputStream GMemoryOutputStream;
-typedef struct _GMemoryOutputStreamClass GMemoryOutputStreamClass;
-typedef struct _GMemoryOutputStreamPrivate GMemoryOutputStreamPrivate;
-
-struct _GMemoryOutputStream
-{
- GOutputStream parent;
-
- /*< private >*/
- GMemoryOutputStreamPrivate *priv;
-};
-
-struct _GMemoryOutputStreamClass
-{
- GOutputStreamClass parent_class;
-};
-
-
-GType g_memory_output_stream_get_type (void) G_GNUC_CONST;
-GOutputStream * g_memory_output_stream_new (GByteArray *data);
-void g_memory_output_stream_set_max_size (GMemoryOutputStream *ostream,
- guint max_size);
-
-G_END_DECLS
-
-#endif /* __G_MEMORY_OUTPUT_STREAM_H__ */
diff --git a/gio/gmountoperation.c b/gio/gmountoperation.c
deleted file mode 100644
index 711f463d..00000000
--- a/gio/gmountoperation.c
+++ /dev/null
@@ -1,224 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include "gmountoperation.h"
-#include "gvfs-marshal.h"
-#include <glib/gi18n-lib.h>
-
-G_DEFINE_TYPE (GMountOperation, g_mount_operation, G_TYPE_OBJECT);
-
-enum {
- ASK_PASSWORD,
- ASK_QUESTION,
- REPLY,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-struct _GMountOperationPrivate {
- char *password;
- char *user;
- char *domain;
- gboolean anonymous;
- GPasswordSave password_save;
- int choice;
-};
-
-static void
-g_mount_operation_finalize (GObject *object)
-{
- GMountOperation *operation;
- GMountOperationPrivate *priv;
-
- operation = G_MOUNT_OPERATION (object);
-
- priv = operation->priv;
-
- g_free (priv->password);
- g_free (priv->user);
- g_free (priv->domain);
-
- if (G_OBJECT_CLASS (g_mount_operation_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_mount_operation_parent_class)->finalize) (object);
-}
-
-static gboolean
-boolean_handled_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
-{
- gboolean continue_emission;
- gboolean signal_handled;
-
- signal_handled = g_value_get_boolean (handler_return);
- g_value_set_boolean (return_accu, signal_handled);
- continue_emission = !signal_handled;
-
- return continue_emission;
-}
-
-static gboolean
-ask_password (GMountOperation *op,
- const char *message,
- const char *default_user,
- const char *default_domain,
- GPasswordFlags flags)
-{
- return FALSE;
-}
-
-static gboolean
-ask_question (GMountOperation *op,
- const char *message,
- const char *choices[])
-{
- return FALSE;
-}
-
-static void
-g_mount_operation_class_init (GMountOperationClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GMountOperationPrivate));
-
- gobject_class->finalize = g_mount_operation_finalize;
-
- klass->ask_password = ask_password;
- klass->ask_question = ask_question;
-
- signals[ASK_PASSWORD] =
- g_signal_new (I_("ask_password"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GMountOperationClass, ask_password),
- boolean_handled_accumulator, NULL,
- _gvfs_marshal_BOOLEAN__STRING_STRING_STRING_INT,
- G_TYPE_BOOLEAN, 4,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);
-
- signals[ASK_QUESTION] =
- g_signal_new (I_("ask_question"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GMountOperationClass, ask_question),
- boolean_handled_accumulator, NULL,
- _gvfs_marshal_BOOLEAN__STRING_POINTER,
- G_TYPE_BOOLEAN, 2,
- G_TYPE_STRING, G_TYPE_POINTER);
-
- signals[REPLY] =
- g_signal_new (I_("reply"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GMountOperationClass, reply),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-}
-
-static void
-g_mount_operation_init (GMountOperation *operation)
-{
- operation->priv = G_TYPE_INSTANCE_GET_PRIVATE (operation,
- G_TYPE_MOUNT_OPERATION,
- GMountOperationPrivate);
-}
-
-GMountOperation *
-g_mount_operation_new (void)
-{
- return g_object_new (G_TYPE_MOUNT_OPERATION, NULL);
-}
-
-const char *
-g_mount_operation_get_username (GMountOperation *op)
-{
- return op->priv->user;
-}
-
-void
-g_mount_operation_set_username (GMountOperation *op,
- const char *username)
-{
- g_free (op->priv->user);
- op->priv->user = g_strdup (username);
-}
-
-const char *
-g_mount_operation_get_password (GMountOperation *op)
-{
- return op->priv->password;
-}
-
-void
-g_mount_operation_set_password (GMountOperation *op,
- const char *password)
-{
- g_free (op->priv->password);
- op->priv->password = g_strdup (password);
-}
-
-gboolean
-g_mount_operation_get_anonymous (GMountOperation *op)
-{
- return op->priv->anonymous;
-}
-
-void
-g_mount_operation_set_anonymous (GMountOperation *op,
- gboolean anonymous)
-{
- op->priv->anonymous = anonymous;
-}
-
-const char *
-g_mount_operation_get_domain (GMountOperation *op)
-{
- return op->priv->domain;
-}
-
-void
-g_mount_operation_set_domain (GMountOperation *op,
- const char *domain)
-{
- g_free (op->priv->domain);
- op->priv->domain = g_strdup (domain);
-}
-
-GPasswordSave
-g_mount_operation_get_password_save (GMountOperation *op)
-{
- return op->priv->password_save;
-}
-
-void
-g_mount_operation_set_password_save (GMountOperation *op,
- GPasswordSave save)
-{
- op->priv->password_save = save;
-}
-
-int
-g_mount_operation_get_choice (GMountOperation *op)
-{
- return op->priv->choice;
-}
-
-void
-g_mount_operation_set_choice (GMountOperation *op,
- int choice)
-{
- op->priv->choice = choice;
-}
-
-void
-g_mount_operation_reply (GMountOperation *op,
- gboolean abort)
-{
- g_signal_emit (op, signals[REPLY], 0, abort);
-}
diff --git a/gio/gmountoperation.h b/gio/gmountoperation.h
deleted file mode 100644
index 27d6b5ea..00000000
--- a/gio/gmountoperation.h
+++ /dev/null
@@ -1,92 +0,0 @@
-#ifndef __G_MOUNT_OPERATION_H__
-#define __G_MOUNT_OPERATION_H__
-
-#include <sys/stat.h>
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_MOUNT_OPERATION (g_mount_operation_get_type ())
-#define G_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MOUNT_OPERATION, GMountOperation))
-#define G_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MOUNT_OPERATION, GMountOperationClass))
-#define G_IS_MOUNT_OPERATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MOUNT_OPERATION))
-#define G_IS_MOUNT_OPERATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MOUNT_OPERATION))
-#define G_MOUNT_OPERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MOUNT_OPERATION, GMountOperationClass))
-
-typedef struct _GMountOperation GMountOperation;
-typedef struct _GMountOperationClass GMountOperationClass;
-typedef struct _GMountOperationPrivate GMountOperationPrivate;
-
-struct _GMountOperation
-{
- GObject parent_instance;
-
- GMountOperationPrivate *priv;
-};
-
-typedef enum {
- G_PASSWORD_FLAGS_NEED_PASSWORD = 1<<0,
- G_PASSWORD_FLAGS_NEED_USERNAME = 1<<1,
- G_PASSWORD_FLAGS_NEED_DOMAIN = 1<<2,
- G_PASSWORD_FLAGS_SAVING_SUPPORTED = 1<<4,
- G_PASSWORD_FLAGS_ANON_SUPPORTED = 1<<5
-} GPasswordFlags;
-
-typedef enum {
- G_PASSWORD_SAVE_NEVER,
- G_PASSWORD_SAVE_FOR_SESSION,
- G_PASSWORD_SAVE_PERMANENTLY
-} GPasswordSave;
-
-struct _GMountOperationClass
-{
- GObjectClass parent_class;
-
- /* signals: */
-
- gboolean (* ask_password) (GMountOperation *op,
- const char *message,
- const char *default_user,
- const char *default_domain,
- GPasswordFlags flags);
-
- gboolean (* ask_question) (GMountOperation *op,
- const char *message,
- const char *choices[]);
-
- void (* reply) (GMountOperation *op,
- gboolean abort);
-
-
-};
-
-GType g_mount_operation_get_type (void) G_GNUC_CONST;
-
-GMountOperation * g_mount_operation_new (void);
-
-const char * g_mount_operation_get_username (GMountOperation *op);
-void g_mount_operation_set_username (GMountOperation *op,
- const char *username);
-const char * g_mount_operation_get_password (GMountOperation *op);
-void g_mount_operation_set_password (GMountOperation *op,
- const char *password);
-gboolean g_mount_operation_get_anonymous (GMountOperation *op);
-void g_mount_operation_set_anonymous (GMountOperation *op,
- gboolean anonymous);
-const char * g_mount_operation_get_domain (GMountOperation *op);
-void g_mount_operation_set_domain (GMountOperation *op,
- const char *domain);
-GPasswordSave g_mount_operation_get_password_save (GMountOperation *op);
-void g_mount_operation_set_password_save (GMountOperation *op,
- GPasswordSave save);
-int g_mount_operation_get_choice (GMountOperation *op);
-void g_mount_operation_set_choice (GMountOperation *op,
- int choice);
-void g_mount_operation_reply (GMountOperation *op,
- gboolean abort);
-
-G_END_DECLS
-
-#endif /* __G_MOUNT_OPERATION_H__ */
diff --git a/gio/goutputstream.c b/gio/goutputstream.c
deleted file mode 100644
index fe4d9d99..00000000
--- a/gio/goutputstream.c
+++ /dev/null
@@ -1,883 +0,0 @@
-#include <config.h>
-#include <glib/gi18n-lib.h>
-
-#include "goutputstream.h"
-#include "gsimpleasyncresult.h"
-
-G_DEFINE_TYPE (GOutputStream, g_output_stream, G_TYPE_OBJECT);
-
-struct _GOutputStreamPrivate {
- guint closed : 1;
- guint pending : 1;
- guint cancelled : 1;
- GAsyncReadyCallback outstanding_callback;
-};
-
-static void g_output_stream_real_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_output_stream_real_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_output_stream_real_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_output_stream_real_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_output_stream_real_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_output_stream_real_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-static void
-g_output_stream_finalize (GObject *object)
-{
- GOutputStream *stream;
-
- stream = G_OUTPUT_STREAM (object);
-
- if (G_OBJECT_CLASS (g_output_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_output_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_output_stream_dispose (GObject *object)
-{
- GOutputStream *stream;
-
- stream = G_OUTPUT_STREAM (object);
-
- if (!stream->priv->closed)
- g_output_stream_close (stream, NULL, NULL);
-
- if (G_OBJECT_CLASS (g_output_stream_parent_class)->dispose)
- (*G_OBJECT_CLASS (g_output_stream_parent_class)->dispose) (object);
-}
-
-static void
-g_output_stream_class_init (GOutputStreamClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GOutputStreamPrivate));
-
- gobject_class->finalize = g_output_stream_finalize;
- gobject_class->dispose = g_output_stream_dispose;
-
- klass->write_async = g_output_stream_real_write_async;
- klass->write_finish = g_output_stream_real_write_finish;
- klass->flush_async = g_output_stream_real_flush_async;
- klass->flush_finish = g_output_stream_real_flush_finish;
- klass->close_async = g_output_stream_real_close_async;
- klass->close_finish = g_output_stream_real_close_finish;
-}
-
-static void
-g_output_stream_init (GOutputStream *stream)
-{
- stream->priv = G_TYPE_INSTANCE_GET_PRIVATE (stream,
- G_TYPE_OUTPUT_STREAM,
- GOutputStreamPrivate);
-}
-
-/**
- * g_output_stream_write:
- * @stream: a #GOutputStream.
- * @buffer: the buffer containing the data to write.
- * @count: the number of bytes to write
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Tries to write @count bytes from @buffer into the stream. Will block
- * during the operation.
- *
- * If count is zero returns zero and does nothing. A value of @count
- * larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
- *
- * On success, the number of bytes written to the stream is returned.
- * It is not an error if this is not the same as the requested size, as it
- * can happen e.g. on a partial i/o error, or if the there is not enough
- * storage in the stream. All writes either block until at least one byte
- * is written, so zero is never returned (unless @count is zero).
- *
- * 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. If an
- * operation was partially finished when the operation was cancelled the
- * partial result will be returned, without an error.
- *
- * On error -1 is returned and @error is set accordingly.
- *
- * Return value: Number of bytes written, or -1 on error
- **/
-gssize
-g_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GOutputStreamClass *class;
- gssize res;
-
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), -1);
- g_return_val_if_fail (stream != NULL, -1);
- g_return_val_if_fail (buffer != NULL, 0);
-
- if (count == 0)
- return 0;
-
- if (((gssize) count) < 0)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Too large count value passed to g_output_stream_write"));
- return -1;
- }
-
- if (stream->priv->closed)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return -1;
- }
-
- if (stream->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return -1;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
-
- if (class->write == NULL)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Output stream doesn't implement write"));
- return -1;
- }
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- stream->priv->pending = TRUE;
- res = class->write (stream, buffer, count, cancellable, error);
- stream->priv->pending = FALSE;
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- return res;
-}
-
-/**
- * g_output_stream_write_all:
- * @stream: a #GOutputStream.
- * @buffer: the buffer containing the data to write.
- * @count: the number of bytes to write
- * @bytes_written: location to store the number of bytes that was written to the stream
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Tries to write @count bytes from @buffer into the stream. Will block
- * during the operation.
- *
- * This function is similar to g_output_stream_write(), except it tries to
- * read as many bytes as requested, only stopping on an error.
- *
- * On a successful write of @count bytes, TRUE is returned, and @bytes_written
- * is set to @count.
- *
- * If there is an error during the operation FALSE is returned and @error
- * is set to indicate the error status, @bytes_written is updated to contain
- * the number of bytes written into the stream before the error occured.
- *
- * Return value: TRUE on success, FALSE if there was an error
- **/
-gboolean
-g_output_stream_write_all (GOutputStream *stream,
- const void *buffer,
- gsize count,
- gsize *bytes_written,
- GCancellable *cancellable,
- GError **error)
-{
- gsize _bytes_written;
- gssize res;
-
- _bytes_written = 0;
- while (_bytes_written < count)
- {
- res = g_output_stream_write (stream, (char *)buffer + _bytes_written, count - _bytes_written,
- cancellable, error);
- if (res == -1)
- {
- *bytes_written = _bytes_written;
- return FALSE;
- }
-
- if (res == 0)
- g_warning ("Write returned zero without error");
-
- _bytes_written += res;
- }
-
- *bytes_written = _bytes_written;
- return TRUE;
-}
-
-/**
- * g_output_stream_flush:
- * @stream: a #GOutputStream.
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Flushed any outstanding buffers in the stream. Will block during the operation.
- * Closing the stream will implicitly cause a flush.
- *
- * This function is optional for inherited classes.
- *
- * 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.
- *
- * Return value: TRUE on success, FALSE on error
- **/
-gboolean
-g_output_stream_flush (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GOutputStreamClass *class;
- gboolean res;
-
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE);
- g_return_val_if_fail (stream != NULL, FALSE);
-
- if (stream->priv->closed)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return FALSE;
- }
-
- if (stream->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return FALSE;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
-
- res = TRUE;
- if (class->flush)
- {
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- stream->priv->pending = TRUE;
- res = class->flush (stream, cancellable, error);
- stream->priv->pending = FALSE;
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
- }
-
- return res;
-}
-
-/**
- * g_output_stream_close:
- * @stream: A #GOutputStream.
- * @cancellable: optional cancellable object
- * @error: location to store the error occuring, or %NULL to ignore
- *
- * Closes the stream, releasing resources related to it.
- *
- * Once the stream is closed, all other operations will return %G_IO_ERROR_CLOSED.
- * Closing a stream multiple times will not return an error.
- *
- * Closing a stream will automatically flush any outstanding buffers in the
- * stream.
- *
- * Streams will be automatically closed when the last reference
- * is dropped, but you might want to call make sure resources
- * are released as early as possible.
- *
- * Some streams might keep the backing store of the stream (e.g. a file descriptor)
- * open after the stream is closed. See the documentation for the individual
- * stream for details.
- *
- * On failure the first error that happened will be reported, but the close
- * operation will finish as much as possible. A stream that failed to
- * close will still return %G_IO_ERROR_CLOSED all operations. Still, it
- * is important to check and report the error to the user, otherwise
- * there might be a loss of data as all data might not be written.
- *
- * 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.
- * Cancelling a close will still leave the stream closed, but there some streams
- * can use a faster close that doesn't block to e.g. check errors. On
- * cancellation (as with any error) there is no guarantee that all written
- * data will reach the target.
- *
- * Return value: %TRUE on success, %FALSE on failure
- **/
-gboolean
-g_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GOutputStreamClass *class;
- gboolean res;
-
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), -1);
- g_return_val_if_fail (stream != NULL, -1);
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
-
- if (stream->priv->closed)
- return TRUE;
-
- if (stream->priv->pending)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return FALSE;
- }
-
- res = g_output_stream_flush (stream, cancellable, error);
-
- stream->priv->pending = TRUE;
-
- if (cancellable)
- g_push_current_cancellable (cancellable);
-
- if (!res)
- {
- /* flushing caused the error that we want to return,
- * but we still want to close the underlying stream if possible
- */
- if (class->close)
- class->close (stream, cancellable, NULL);
- }
- else
- {
- res = TRUE;
- if (class->close)
- res = class->close (stream, cancellable, error);
- }
-
- if (cancellable)
- g_pop_current_cancellable (cancellable);
-
- stream->priv->closed = TRUE;
- stream->priv->pending = FALSE;
-
- return res;
-}
-
-static void
-async_ready_callback_wrapper (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GOutputStream *stream = G_OUTPUT_STREAM (source_object);
-
- stream->priv->pending = FALSE;
- (*stream->priv->outstanding_callback) (source_object, res, user_data);
- g_object_unref (stream);
-}
-
-static void
-async_ready_close_callback_wrapper (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GOutputStream *stream = G_OUTPUT_STREAM (source_object);
-
- stream->priv->pending = FALSE;
- stream->priv->closed = TRUE;
- (*stream->priv->outstanding_callback) (source_object, res, user_data);
- g_object_unref (stream);
-}
-
-/**
- * g_output_stream_write_async:
- * @stream: A #GOutputStream.
- * @buffer: the buffer containing the data to write.
- * @count: the number of bytes to write
- * @io_priority: the io priority of the request
- * @callback: callback to call when the request is satisfied
- * @user_data: the data to pass to callback function
- * @cancellable: optional cancellable object
- *
- * Request an asynchronous write of @count bytes from @buffer into the stream.
- * When the operation is finished @callback will be called, giving the results.
- *
- * During an async request no other sync and async calls are allowed, and will
- * result in %G_IO_ERROR_PENDING errors.
- *
- * A value of @count larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
- *
- * On success, the number of bytes written will be passed to the
- * callback. It is not an error if this is not the same as the requested size, as it
- * can happen e.g. on a partial i/o error, but generally we try to write
- * as many bytes as requested.
- *
- * Any outstanding i/o request with higher priority (lower numerical value) will
- * be executed before an outstanding request with lower priority. Default
- * priority is G_%PRIORITY_DEFAULT.
- *
- * The asyncronous methods have a default fallback that uses threads to implement
- * asynchronicity, so they are optional for inheriting classes. However, if you
- * override one you must override all.
- **/
-void
-g_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GOutputStreamClass *class;
- GSimpleAsyncResult *simple;
-
- g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
- g_return_if_fail (buffer != NULL);
-
- if (count == 0)
- {
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_output_stream_write_async);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- if (((gssize) count) < 0)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
- _("Too large count value passed to g_output_stream_write_async"));
- return;
- }
-
- if (stream->priv->closed)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return;
- }
-
- if (stream->priv->pending)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
-
- stream->priv->pending = TRUE;
- stream->priv->outstanding_callback = callback;
- g_object_ref (stream);
- class->write_async (stream, buffer, count, io_priority, cancellable,
- async_ready_callback_wrapper, user_data);
-}
-
-
-gssize
-g_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- GOutputStreamClass *class;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return -1;
-
- /* Special case writes of 0 bytes */
- if (g_simple_async_result_get_source_tag (simple) == g_output_stream_write_async)
- return 0;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
- return class->write_finish (stream, result, error);
-}
-
-void
-g_output_stream_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GOutputStreamClass *class;
- GSimpleAsyncResult *simple;
-
- g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
-
- if (stream->priv->closed)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_CLOSED,
- _("Stream is already closed"));
- return;
- }
-
- if (stream->priv->pending)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
-
- if (class->flush_async == NULL)
- {
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_output_stream_flush_async);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- stream->priv->pending = TRUE;
- stream->priv->outstanding_callback = callback;
- g_object_ref (stream);
- class->flush_async (stream, io_priority, cancellable,
- async_ready_callback_wrapper, user_data);
-}
-
-gboolean
-g_output_stream_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- GOutputStreamClass *class;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- /* Special case default implementation */
- if (g_simple_async_result_get_source_tag (simple) == g_output_stream_flush_async)
- return TRUE;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
- return class->flush_finish (stream, result, error);
-}
-
-
-/**
- * g_output_stream_close_async:
- * @stream: A #GOutputStream.
- * @callback: callback to call when the request is satisfied
- * @user_data: the data to pass to callback function
- * @cancellable: optional cancellable object
- *
- * Requests an asynchronous closes of the stream, releasing resources related to it.
- * When the operation is finished @callback will be called, giving the results.
- *
- * For behaviour details see g_output_stream_close().
- *
- * The asyncronous methods have a default fallback that uses threads to implement
- * asynchronicity, so they are optional for inheriting classes. However, if you
- * override one you must override all.
- **/
-void
-g_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GOutputStreamClass *class;
- GSimpleAsyncResult *simple;
-
- g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
-
- if (stream->priv->closed)
- {
- simple = g_simple_async_result_new (G_OBJECT (stream),
- callback,
- user_data,
- g_output_stream_close_async);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
- return;
- }
-
- if (stream->priv->pending)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (stream),
- callback,
- user_data,
- G_IO_ERROR, G_IO_ERROR_PENDING,
- _("Stream has outstanding operation"));
- return;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
- stream->priv->pending = TRUE;
- stream->priv->outstanding_callback = callback;
- g_object_ref (stream);
- class->close_async (stream, io_priority, cancellable,
- async_ready_close_callback_wrapper, user_data);
-}
-
-gboolean
-g_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- GOutputStreamClass *class;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
-
- /* Special case already closed */
- if (g_simple_async_result_get_source_tag (simple) == g_output_stream_close_async)
- return TRUE;
- }
-
- class = G_OUTPUT_STREAM_GET_CLASS (stream);
- return class->close_finish (stream, result, error);
-}
-
-gboolean
-g_output_stream_is_closed (GOutputStream *stream)
-{
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), TRUE);
- g_return_val_if_fail (stream != NULL, TRUE);
-
- return stream->priv->closed;
-}
-
-gboolean
-g_output_stream_has_pending (GOutputStream *stream)
-{
- g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), TRUE);
- g_return_val_if_fail (stream != NULL, TRUE);
-
- return stream->priv->pending;
-}
-
-void
-g_output_stream_set_pending (GOutputStream *stream,
- gboolean pending)
-{
- g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
- g_return_if_fail (stream != NULL);
-
- stream->priv->pending = pending;
-}
-
-
-/********************************************
- * Default implementation of async ops *
- ********************************************/
-
-typedef struct {
- const void *buffer;
- gsize count_requested;
- gssize count_written;
-} WriteData;
-
-static void
-write_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- WriteData *op;
- GOutputStreamClass *class;
- GError *error = NULL;
-
- class = G_OUTPUT_STREAM_GET_CLASS (object);
- op = g_simple_async_result_get_op_res_gpointer (res);
- op->count_written = class->write (G_OUTPUT_STREAM (object), op->buffer, op->count_requested,
- cancellable, &error);
- if (op->count_written == -1)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
-}
-
-static void
-g_output_stream_real_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
- WriteData *op;
-
- op = g_new0 (WriteData, 1);
- res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_output_stream_real_write_async);
- g_simple_async_result_set_op_res_gpointer (res, op, g_free);
- op->buffer = buffer;
- op->count_requested = count;
-
- g_simple_async_result_run_in_thread (res, write_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static gssize
-g_output_stream_real_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- WriteData *op;
-
- g_assert (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_write_async);
- op = g_simple_async_result_get_op_res_gpointer (simple);
- return op->count_written;
-}
-
-static void
-flush_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GOutputStreamClass *class;
- gboolean result;
- GError *error = NULL;
-
- class = G_OUTPUT_STREAM_GET_CLASS (object);
- result = TRUE;
- if (class->flush)
- result = class->flush (G_OUTPUT_STREAM (object), cancellable, &error);
-
- if (!result)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
-}
-
-static void
-g_output_stream_real_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_output_stream_real_write_async);
-
- g_simple_async_result_run_in_thread (res, flush_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static gboolean
-g_output_stream_real_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- return TRUE;
-}
-
-static void
-close_async_thread (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable)
-{
- GOutputStreamClass *class;
- GError *error = NULL;
- gboolean result;
-
- /* Auto handling of cancelation disabled, and ignore
- cancellation, since we want to close things anyway, although
- possibly in a quick-n-dirty way. At least we never want to leak
- open handles */
-
- class = G_OUTPUT_STREAM_GET_CLASS (object);
- result = class->close (G_OUTPUT_STREAM (object), cancellable, &error);
- if (!result)
- {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- }
-}
-
-static void
-g_output_stream_real_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *res;
-
- res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_output_stream_real_close_async);
-
- g_simple_async_result_set_handle_cancellation (res, FALSE);
-
- g_simple_async_result_run_in_thread (res, close_async_thread, io_priority, cancellable);
- g_object_unref (res);
-}
-
-static gboolean
-g_output_stream_real_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- g_assert (g_simple_async_result_get_source_tag (simple) == g_output_stream_real_close_async);
- return TRUE;
-}
diff --git a/gio/goutputstream.h b/gio/goutputstream.h
deleted file mode 100644
index f23046cf..00000000
--- a/gio/goutputstream.h
+++ /dev/null
@@ -1,139 +0,0 @@
-#ifndef __G_OUTPUT_STREAM_H__
-#define __G_OUTPUT_STREAM_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gioerror.h>
-#include <gio/gasyncresult.h>
-#include <gio/gcancellable.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_OUTPUT_STREAM (g_output_stream_get_type ())
-#define G_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OUTPUT_STREAM, GOutputStream))
-#define G_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
-#define G_IS_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OUTPUT_STREAM))
-#define G_IS_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OUTPUT_STREAM))
-#define G_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
-
-typedef struct _GOutputStream GOutputStream;
-typedef struct _GOutputStreamClass GOutputStreamClass;
-typedef struct _GOutputStreamPrivate GOutputStreamPrivate;
-
-struct _GOutputStream
-{
- GObject parent;
-
- /*< private >*/
- GOutputStreamPrivate *priv;
-};
-
-
-struct _GOutputStreamClass
-{
- GObjectClass parent_class;
-
- /* Sync ops: */
-
- gssize (* write) (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
- gboolean (* flush) (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
- gboolean (* close) (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-
- /* Async ops: (optional in derived classes) */
-
- void (* write_async) (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gssize (* write_finish) (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
- void (* flush_async) (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (* flush_finish) (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
- void (* close_async) (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (* close_finish) (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-
- /* Padding for future expansion */
- void (*_g_reserved1) (void);
- void (*_g_reserved2) (void);
- void (*_g_reserved3) (void);
- void (*_g_reserved4) (void);
- void (*_g_reserved5) (void);
-};
-
-GType g_output_stream_get_type (void) G_GNUC_CONST;
-
-gssize g_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-gboolean g_output_stream_write_all (GOutputStream *stream,
- const void *buffer,
- gsize count,
- gsize *bytes_written,
- GCancellable *cancellable,
- GError **error);
-gboolean g_output_stream_flush (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-gboolean g_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-void g_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gssize g_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-void g_output_stream_flush_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_output_stream_flush_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-void g_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-gboolean g_output_stream_is_closed (GOutputStream *stream);
-gboolean g_output_stream_has_pending (GOutputStream *stream);
-void g_output_stream_set_pending (GOutputStream *stream,
- gboolean pending);
-
-G_END_DECLS
-
-#endif /* __G_OUTPUT_STREAM_H__ */
diff --git a/gio/gpollfilemonitor.c b/gio/gpollfilemonitor.c
deleted file mode 100644
index eee499b3..00000000
--- a/gio/gpollfilemonitor.c
+++ /dev/null
@@ -1,198 +0,0 @@
-#include <config.h>
-#include <string.h>
-
-#include "gpollfilemonitor.h"
-#include "gfilemonitorpriv.h"
-
-static gboolean g_poll_file_monitor_cancel (GFileMonitor* monitor);
-static void schedule_poll_timeout (GPollFileMonitor* poll_monitor);
-
-struct _GPollFileMonitor
-{
- GFileMonitor parent_instance;
- GFile *file;
- GFileInfo *last_info;
- guint timeout;
-};
-
-#define POLL_TIME_SECS 5
-
-G_DEFINE_TYPE (GPollFileMonitor, g_poll_file_monitor, G_TYPE_FILE_MONITOR)
-
-static void
-g_poll_file_monitor_finalize (GObject* object)
-{
- GPollFileMonitor* poll_monitor;
-
- poll_monitor = G_POLL_FILE_MONITOR (object);
-
- g_object_unref (poll_monitor->file);
-
- if (G_OBJECT_CLASS (g_poll_file_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_poll_file_monitor_parent_class)->finalize) (object);
-}
-
-
-static void
-g_poll_file_monitor_class_init (GPollFileMonitorClass* klass)
-{
- GObjectClass* gobject_class = G_OBJECT_CLASS (klass);
- GFileMonitorClass *file_monitor_class = G_FILE_MONITOR_CLASS (klass);
-
- gobject_class->finalize = g_poll_file_monitor_finalize;
-
- file_monitor_class->cancel = g_poll_file_monitor_cancel;
-}
-
-static void
-g_poll_file_monitor_init (GPollFileMonitor* poll_monitor)
-{
-}
-
-static gboolean
-safe_strcmp (const char *a, const char *b)
-{
- if (a == NULL && b == NULL)
- return 0;
- if (a == NULL)
- return -1;
- if (b == NULL)
- return 1;
-
- return strcmp (a, b);
-}
-
-static int
-calc_event_type (GFileInfo *last,
- GFileInfo *new)
-{
- if (last == NULL && new == NULL)
- return -1;
-
- if (last == NULL && new != NULL)
- return G_FILE_MONITOR_EVENT_CREATED;
-
- if (last != NULL && new == NULL)
- return G_FILE_MONITOR_EVENT_DELETED;
-
- if (safe_strcmp (g_file_info_get_etag (last),
- g_file_info_get_etag (new)))
- return G_FILE_MONITOR_EVENT_CHANGED;
-
- if (g_file_info_get_size (last) !=
- g_file_info_get_size (new))
- return G_FILE_MONITOR_EVENT_CHANGED;
-
- return -1;
-}
-
-static void
-got_new_info (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GPollFileMonitor* poll_monitor = user_data;
- GFileInfo *info;
- int event;
-
- info = g_file_get_info_finish (poll_monitor->file, res, NULL);
-
- if (!g_file_monitor_is_cancelled (G_FILE_MONITOR (poll_monitor)))
- {
- event = calc_event_type (poll_monitor->last_info, info);
-
- if (event != -1)
- {
- g_file_monitor_emit_event (G_FILE_MONITOR (poll_monitor),
- poll_monitor->file,
- NULL, event);
- /* We're polling so slowly anyway, so always emit the done hint */
- if (event == G_FILE_MONITOR_EVENT_CHANGED)
- g_file_monitor_emit_event (G_FILE_MONITOR (poll_monitor),
- poll_monitor->file,
- NULL, G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT);
- }
-
- if (poll_monitor->last_info)
- {
- g_object_unref (poll_monitor->last_info);
- poll_monitor->last_info = NULL;
- }
-
- if (info)
- poll_monitor->last_info = g_object_ref (info);
-
- schedule_poll_timeout (poll_monitor);
- }
-
- if (info)
- g_object_unref (info);
-
- g_object_unref (poll_monitor);
-}
-
-static gboolean
-poll_file_timeout (gpointer data)
-{
- GPollFileMonitor* poll_monitor = data;
-
- poll_monitor->timeout = FALSE;
-
- g_file_get_info_async (poll_monitor->file, G_FILE_ATTRIBUTE_ETAG_VALUE "," G_FILE_ATTRIBUTE_STD_SIZE,
- 0, 0, NULL, got_new_info, g_object_ref (poll_monitor));
-
- return FALSE;
-}
-
-static void
-schedule_poll_timeout (GPollFileMonitor* poll_monitor)
-{
- poll_monitor->timeout = g_timeout_add_seconds (POLL_TIME_SECS, poll_file_timeout, poll_monitor);
- }
-
-static void
-got_initial_info (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GPollFileMonitor* poll_monitor = user_data;
- GFileInfo *info;
-
- info = g_file_get_info_finish (poll_monitor->file, res, NULL);
-
- poll_monitor->last_info = info;
-
- if (!g_file_monitor_is_cancelled (G_FILE_MONITOR (poll_monitor)))
- schedule_poll_timeout (poll_monitor);
-
- g_object_unref (poll_monitor);
-}
-
-GFileMonitor*
-g_poll_file_monitor_new (GFile *file)
-{
- GPollFileMonitor* poll_monitor;
-
- poll_monitor = g_object_new (G_TYPE_POLL_FILE_MONITOR, NULL);
-
- poll_monitor->file = g_object_ref (file);
-
- g_file_get_info_async (file, G_FILE_ATTRIBUTE_ETAG_VALUE "," G_FILE_ATTRIBUTE_STD_SIZE,
- 0, 0, NULL, got_initial_info, g_object_ref (poll_monitor));
-
- return G_FILE_MONITOR (poll_monitor);
-}
-
-static gboolean
-g_poll_file_monitor_cancel (GFileMonitor* monitor)
-{
- GPollFileMonitor *poll_monitor = G_POLL_FILE_MONITOR (monitor);
-
- if (poll_monitor->timeout)
- {
- g_source_remove (poll_monitor->timeout);
- poll_monitor->timeout = 0;
- }
-
- return TRUE;
-}
diff --git a/gio/gpollfilemonitor.h b/gio/gpollfilemonitor.h
deleted file mode 100644
index 297de2fa..00000000
--- a/gio/gpollfilemonitor.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __G_POLL_FILE_MONITOR_H__
-#define __G_POLL_FILE_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/gfilemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_POLL_FILE_MONITOR (g_poll_file_monitor_get_type ())
-#define G_POLL_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_POLL_FILE_MONITOR, GPollFileMonitor))
-#define G_POLL_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), G_TYPE_POLL_FILE_MONITOR, GPollFileMonitorClass))
-#define G_IS_POLL_FILE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_POLL_FILE_MONITOR))
-#define G_IS_POLL_FILE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_POLL_FILE_MONITOR))
-
-typedef struct _GPollFileMonitor GPollFileMonitor;
-typedef struct _GPollFileMonitorClass GPollFileMonitorClass;
-
-struct _GPollFileMonitorClass {
- GFileMonitorClass parent_class;
-};
-
-GType g_poll_file_monitor_get_type (void) G_GNUC_CONST;
-
-GFileMonitor* g_poll_file_monitor_new (GFile *file);
-
-G_END_DECLS
-
-#endif /* __G_POLL_FILE_MONITOR_H__ */
diff --git a/gio/gseekable.c b/gio/gseekable.c
deleted file mode 100644
index ed5f06e8..00000000
--- a/gio/gseekable.c
+++ /dev/null
@@ -1,100 +0,0 @@
-#include <config.h>
-#include "gseekable.h"
-#include <glib/gi18n-lib.h>
-
-static void g_seekable_base_init (gpointer g_class);
-
-
-GType
-g_seekable_get_type (void)
-{
- static GType seekable_type = 0;
-
- if (! seekable_type)
- {
- static const GTypeInfo seekable_info =
- {
- sizeof (GSeekableIface), /* class_size */
- g_seekable_base_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- seekable_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GSeekable"),
- &seekable_info, 0);
-
- g_type_interface_add_prerequisite (seekable_type, G_TYPE_OBJECT);
- }
-
- return seekable_type;
-}
-
-static void
-g_seekable_base_init (gpointer g_class)
-{
-}
-
-
-goffset
-g_seekable_tell (GSeekable *seekable)
-{
- GSeekableIface *iface;
-
- iface = G_SEEKABLE_GET_IFACE (seekable);
-
- return (* iface->tell) (seekable);
-}
-
-gboolean
-g_seekable_can_seek (GSeekable *seekable)
-{
- GSeekableIface *iface;
-
- iface = G_SEEKABLE_GET_IFACE (seekable);
-
- return (* iface->can_seek) (seekable);
-}
-
-gboolean
-g_seekable_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error)
-{
- GSeekableIface *iface;
-
- iface = G_SEEKABLE_GET_IFACE (seekable);
-
- return (* iface->seek) (seekable, offset, type, cancellable, error);
-}
-
-gboolean
-g_seekable_can_truncate (GSeekable *seekable)
-{
- GSeekableIface *iface;
-
- iface = G_SEEKABLE_GET_IFACE (seekable);
-
- return (* iface->can_truncate) (seekable);
-}
-
-gboolean
-g_seekable_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error)
-{
- GSeekableIface *iface;
-
- iface = G_SEEKABLE_GET_IFACE (seekable);
-
- return (* iface->truncate) (seekable, offset, cancellable, error);
-}
-
diff --git a/gio/gseekable.h b/gio/gseekable.h
deleted file mode 100644
index 353c7ade..00000000
--- a/gio/gseekable.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef __G_SEEKABLE_H__
-#define __G_SEEKABLE_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gcancellable.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_SEEKABLE (g_seekable_get_type ())
-#define G_SEEKABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SEEKABLE, GSeekable))
-#define G_IS_SEEKABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SEEKABLE))
-#define G_SEEKABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_SEEKABLE, GSeekableIface))
-
-typedef struct _GSeekable GSeekable;
-typedef struct _GSeekableIface GSeekableIface;
-
-struct _GSeekableIface
-{
- GTypeInterface g_iface;
-
- /* Virtual Table */
-
- goffset (* tell) (GSeekable *seekable);
-
- gboolean (* can_seek) (GSeekable *seekable);
- gboolean (* seek) (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **error);
-
- gboolean (* can_truncate) (GSeekable *seekable);
- gboolean (* truncate) (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error);
-
- /* TODO: Async seek/truncate */
-
-};
-
-GType g_seekable_get_type (void) G_GNUC_CONST;
-
-goffset g_seekable_tell (GSeekable *seekable);
-gboolean g_seekable_can_seek (GSeekable *seekable);
-gboolean g_seekable_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cancellable,
- GError **err);
-gboolean g_seekable_can_truncate (GSeekable *seekable);
-gboolean g_seekable_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **err);
-
-G_END_DECLS
-
-
-#endif /* __G_SEEKABLE_H__ */
diff --git a/gio/gsimpleasyncresult.c b/gio/gsimpleasyncresult.c
deleted file mode 100644
index 8f29a51b..00000000
--- a/gio/gsimpleasyncresult.c
+++ /dev/null
@@ -1,379 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "gsimpleasyncresult.h"
-#include "gioscheduler.h"
-#include <gio/gioerror.h>
-#include <glib/gi18n-lib.h>
-
-static void g_simple_async_result_async_result_iface_init (GAsyncResultIface *iface);
-
-struct _GSimpleAsyncResult
-{
- GObject parent_instance;
-
- GObject *source_object;
- GAsyncReadyCallback callback;
- gpointer user_data;
- GError *error;
- gboolean failed;
- gboolean handle_cancellation;
-
- gpointer source_tag;
-
- union {
- gpointer v_pointer;
- gboolean v_boolean;
- gssize v_ssize;
- } op_res;
-
- GDestroyNotify destroy_op_res;
-};
-
-G_DEFINE_TYPE_WITH_CODE (GSimpleAsyncResult, g_simple_async_result, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_RESULT,
- g_simple_async_result_async_result_iface_init))
-
-static void
-g_simple_async_result_finalize (GObject *object)
-{
- GSimpleAsyncResult *simple;
-
- simple = G_SIMPLE_ASYNC_RESULT (object);
-
- if (simple->source_object)
- g_object_unref (simple->source_object);
-
- if (simple->destroy_op_res)
- simple->destroy_op_res (simple->op_res.v_pointer);
-
- if (simple->error)
- g_error_free (simple->error);
-
- if (G_OBJECT_CLASS (g_simple_async_result_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_simple_async_result_parent_class)->finalize) (object);
-}
-
-static void
-g_simple_async_result_class_init (GSimpleAsyncResultClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_simple_async_result_finalize;
-}
-
-static void
-g_simple_async_result_init (GSimpleAsyncResult *simple)
-{
- simple->handle_cancellation = TRUE;
-}
-
-GSimpleAsyncResult *
-g_simple_async_result_new (GObject *source_object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- gpointer source_tag)
-{
- GSimpleAsyncResult *simple;
-
- simple = g_object_new (G_TYPE_SIMPLE_ASYNC_RESULT, NULL);
- simple->callback = callback;
- simple->source_object = g_object_ref (source_object);
- simple->user_data = user_data;
- simple->source_tag = source_tag;
-
- return simple;
-}
-
-GSimpleAsyncResult *
-g_simple_async_result_new_from_error (GObject *source_object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- GError *error)
-{
- GSimpleAsyncResult *simple;
-
- simple = g_simple_async_result_new (source_object,
- callback,
- user_data, NULL);
- g_simple_async_result_set_from_error (simple, error);
-
- return simple;
-}
-
-GSimpleAsyncResult *
-g_simple_async_result_new_error (GObject *source_object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- GQuark domain,
- gint code,
- const char *format,
- ...)
-{
- GSimpleAsyncResult *simple;
- va_list args;
-
- simple = g_simple_async_result_new (source_object,
- callback,
- user_data, NULL);
-
- va_start (args, format);
- g_simple_async_result_set_error_va (simple, domain, code, format, args);
- va_end (args);
-
- return simple;
-}
-
-
-static gpointer
-g_simple_async_result_get_user_data (GAsyncResult *res)
-{
- return G_SIMPLE_ASYNC_RESULT (res)->user_data;
-}
-
-static GObject *
-g_simple_async_result_get_source_object (GAsyncResult *res)
-{
- if (G_SIMPLE_ASYNC_RESULT (res)->source_object)
- return g_object_ref (G_SIMPLE_ASYNC_RESULT (res)->source_object);
- return NULL;
-}
-
-static void
-g_simple_async_result_async_result_iface_init (GAsyncResultIface *iface)
-{
- iface->get_user_data = g_simple_async_result_get_user_data;
- iface->get_source_object = g_simple_async_result_get_source_object;
-}
-
-
-void
-g_simple_async_result_set_handle_cancellation (GSimpleAsyncResult *simple,
- gboolean handle_cancellation)
-{
- simple->handle_cancellation = handle_cancellation;
-}
-
-gpointer
-g_simple_async_result_get_source_tag (GSimpleAsyncResult *simple)
-{
- return simple->source_tag;
-}
-
-gboolean
-g_simple_async_result_propagate_error (GSimpleAsyncResult *simple,
- GError **dest)
-{
- if (simple->failed)
- {
- g_propagate_error (dest, simple->error);
- simple->error = NULL;
- return TRUE;
- }
- return FALSE;
-}
-
-void
-g_simple_async_result_set_op_res_gpointer (GSimpleAsyncResult *simple,
- gpointer op_res,
- GDestroyNotify destroy_op_res)
-{
- simple->op_res.v_pointer = op_res;
- simple->destroy_op_res = destroy_op_res;
-}
-
-gpointer
-g_simple_async_result_get_op_res_gpointer (GSimpleAsyncResult *simple)
-{
- return simple->op_res.v_pointer;
-}
-
-void
-g_simple_async_result_set_op_res_gssize (GSimpleAsyncResult *simple,
- gssize op_res)
-{
- simple->op_res.v_ssize = op_res;
-}
-
-gssize
-g_simple_async_result_get_op_res_gssize (GSimpleAsyncResult *simple)
-{
- return simple->op_res.v_ssize;
-}
-
-void
-g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult *simple,
- gboolean op_res)
-{
- simple->op_res.v_boolean = op_res;
-}
-
-gboolean
-g_simple_async_result_get_op_res_gboolean (GSimpleAsyncResult *simple)
-{
- return simple->op_res.v_boolean;
-}
-
-void
-g_simple_async_result_set_from_error (GSimpleAsyncResult *simple,
- GError *error)
-{
- simple->error = g_error_copy (error);
- simple->failed = TRUE;
-}
-
-static GError*
-_g_error_new_valist (GQuark domain,
- gint code,
- const char *format,
- va_list args)
-{
- GError *error;
-
- error = g_new (GError, 1);
-
- error->domain = domain;
- error->code = code;
- error->message = g_strdup_vprintf (format, args);
-
- return error;
-}
-
-void
-g_simple_async_result_set_error_va (GSimpleAsyncResult *simple,
- GQuark domain,
- gint code,
- const char *format,
- va_list args)
-{
- simple->error = _g_error_new_valist (domain, code, format, args);
- simple->failed = TRUE;
-}
-
-
-void
-g_simple_async_result_set_error (GSimpleAsyncResult *simple,
- GQuark domain,
- gint code,
- const char *format,
- ...)
-{
- va_list args;
-
- va_start (args, format);
- g_simple_async_result_set_error_va (simple, domain, code, format, args);
- va_end (args);
-}
-
-
-void
-g_simple_async_result_complete (GSimpleAsyncResult *simple)
-{
- if (simple->callback)
- simple->callback (simple->source_object,
- G_ASYNC_RESULT (simple),
- simple->user_data);
-}
-
-static gboolean
-complete_in_idle_cb (gpointer data)
-{
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (data);
-
- g_simple_async_result_complete (simple);
-
- return FALSE;
-}
-
-void
-g_simple_async_result_complete_in_idle (GSimpleAsyncResult *simple)
-{
- GSource *source;
- guint id;
-
- g_object_ref (simple);
-
- source = g_idle_source_new ();
- g_source_set_priority (source, G_PRIORITY_DEFAULT);
- g_source_set_callback (source, complete_in_idle_cb, simple, g_object_unref);
-
- id = g_source_attach (source, NULL);
- g_source_unref (source);
-}
-
-typedef struct {
- GSimpleAsyncResult *simple;
- GSimpleAsyncThreadFunc func;
-} RunInThreadData;
-
-static void
-run_in_thread (GIOJob *job,
- GCancellable *c,
- gpointer _data)
-{
- RunInThreadData *data = _data;
- GSimpleAsyncResult *simple = data->simple;
-
- if (simple->handle_cancellation &&
- g_cancellable_is_cancelled (c))
- {
- g_simple_async_result_set_error (simple,
- G_IO_ERROR,
- G_IO_ERROR_CANCELLED,
- _("Operation was cancelled"));
- }
- else
- {
- data->func (simple,
- simple->source_object,
- c);
- }
-
- g_simple_async_result_complete_in_idle (data->simple);
- g_object_unref (data->simple);
- g_free (data);
-}
-
-void
-g_simple_async_result_run_in_thread (GSimpleAsyncResult *simple,
- GSimpleAsyncThreadFunc func,
- int io_priority,
- GCancellable *cancellable)
-{
- RunInThreadData *data;
-
- data = g_new (RunInThreadData, 1);
- data->func = func;
- data->simple = g_object_ref (simple);
- g_schedule_io_job (run_in_thread, data, NULL, io_priority, cancellable);
-}
-
-void
-g_simple_async_report_error_in_idle (GObject *object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- GQuark domain,
- gint code,
- const char *format,
- ...)
-{
- GSimpleAsyncResult *simple;
- va_list args;
-
- simple = g_simple_async_result_new (object,
- callback,
- user_data, NULL);
-
- va_start (args, format);
- g_simple_async_result_set_error_va (simple, domain, code, format, args);
- va_end (args);
- g_simple_async_result_complete_in_idle (simple);
- g_object_unref (simple);
-}
diff --git a/gio/gsimpleasyncresult.h b/gio/gsimpleasyncresult.h
deleted file mode 100644
index f6439ebf..00000000
--- a/gio/gsimpleasyncresult.h
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef __G_SIMPLE_ASYNC_RESULT_H__
-#define __G_SIMPLE_ASYNC_RESULT_H__
-
-#include <gio/gasyncresult.h>
-#include <gio/gcancellable.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_SIMPLE_ASYNC_RESULT (g_simple_async_result_get_type ())
-#define G_SIMPLE_ASYNC_RESULT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResult))
-#define G_SIMPLE_ASYNC_RESULT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass))
-#define G_IS_SIMPLE_ASYNC_RESULT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SIMPLE_ASYNC_RESULT))
-#define G_IS_SIMPLE_ASYNC_RESULT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SIMPLE_ASYNC_RESULT))
-#define G_SIMPLE_ASYNC_RESULT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SIMPLE_ASYNC_RESULT, GSimpleAsyncResultClass))
-
-typedef struct _GSimpleAsyncResult GSimpleAsyncResult;
-typedef struct _GSimpleAsyncResultClass GSimpleAsyncResultClass;
-
-struct _GSimpleAsyncResultClass
-{
- GObjectClass parent_class;
-};
-
-typedef void (*GSimpleAsyncThreadFunc) (GSimpleAsyncResult *res,
- GObject *object,
- GCancellable *cancellable);
-
-
-GType g_simple_async_result_get_type (void) G_GNUC_CONST;
-
-GSimpleAsyncResult *g_simple_async_result_new (GObject *source_object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- gpointer source_tag);
-GSimpleAsyncResult *g_simple_async_result_new_error (GObject *source_object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- GQuark domain,
- gint code,
- const char *format,
- ...) G_GNUC_PRINTF (6, 7);
-GSimpleAsyncResult *g_simple_async_result_new_from_error (GObject *source_object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- GError *error);
-
-void g_simple_async_result_set_op_res_gpointer (GSimpleAsyncResult *simple,
- gpointer op_res,
- GDestroyNotify destroy_op_res);
-gpointer g_simple_async_result_get_op_res_gpointer (GSimpleAsyncResult *simple);
-
-void g_simple_async_result_set_op_res_gssize (GSimpleAsyncResult *simple,
- gssize op_res);
-gssize g_simple_async_result_get_op_res_gssize (GSimpleAsyncResult *simple);
-
-void g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult *simple,
- gboolean op_res);
-gboolean g_simple_async_result_get_op_res_gboolean (GSimpleAsyncResult *simple);
-
-
-
-gpointer g_simple_async_result_get_source_tag (GSimpleAsyncResult *simple);
-void g_simple_async_result_set_handle_cancellation (GSimpleAsyncResult *simple,
- gboolean handle_cancellation);
-void g_simple_async_result_complete (GSimpleAsyncResult *simple);
-void g_simple_async_result_complete_in_idle (GSimpleAsyncResult *simple);
-void g_simple_async_result_run_in_thread (GSimpleAsyncResult *simple,
- GSimpleAsyncThreadFunc func,
- int io_priority,
- GCancellable *cancellable);
-void g_simple_async_result_set_from_error (GSimpleAsyncResult *simple,
- GError *error);
-gboolean g_simple_async_result_propagate_error (GSimpleAsyncResult *simple,
- GError **dest);
-void g_simple_async_result_set_error (GSimpleAsyncResult *simple,
- GQuark domain,
- gint code,
- const char *format,
- ...) G_GNUC_PRINTF (4, 5);
-void g_simple_async_result_set_error_va (GSimpleAsyncResult *simple,
- GQuark domain,
- gint code,
- const char *format,
- va_list args);
-
-void g_simple_async_report_error_in_idle (GObject *object,
- GAsyncReadyCallback callback,
- gpointer user_data,
- GQuark domain,
- gint code,
- const char *format,
- ...);
-
-G_END_DECLS
-
-
-
-#endif /* __G_SIMPLE_ASYNC_RESULT_H__ */
diff --git a/gio/gsocketinputstream.c b/gio/gsocketinputstream.c
deleted file mode 100644
index 5b738d3a..00000000
--- a/gio/gsocketinputstream.c
+++ /dev/null
@@ -1,435 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <poll.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n-lib.h>
-#include "gioerror.h"
-#include "gsimpleasyncresult.h"
-#include "gsocketinputstream.h"
-#include "gcancellable.h"
-#include "gasynchelper.h"
-
-G_DEFINE_TYPE (GSocketInputStream, g_socket_input_stream, G_TYPE_INPUT_STREAM);
-
-struct _GSocketInputStreamPrivate {
- int fd;
- gboolean close_fd_at_close;
-};
-
-static gssize g_socket_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_socket_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static void g_socket_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_socket_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_socket_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_socket_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_socket_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_socket_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-static void
-g_socket_input_stream_finalize (GObject *object)
-{
- GSocketInputStream *stream;
-
- stream = G_SOCKET_INPUT_STREAM (object);
-
- if (G_OBJECT_CLASS (g_socket_input_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_socket_input_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_socket_input_stream_class_init (GSocketInputStreamClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GInputStreamClass *stream_class = G_INPUT_STREAM_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GSocketInputStreamPrivate));
-
- gobject_class->finalize = g_socket_input_stream_finalize;
-
- stream_class->read = g_socket_input_stream_read;
- stream_class->close = g_socket_input_stream_close;
- stream_class->read_async = g_socket_input_stream_read_async;
- stream_class->read_finish = g_socket_input_stream_read_finish;
- if (0)
- {
- /* TODO: Implement instead of using fallbacks */
- stream_class->skip_async = g_socket_input_stream_skip_async;
- stream_class->skip_finish = g_socket_input_stream_skip_finish;
- }
- stream_class->close_async = g_socket_input_stream_close_async;
- stream_class->close_finish = g_socket_input_stream_close_finish;
-}
-
-static void
-g_socket_input_stream_init (GSocketInputStream *socket)
-{
- socket->priv = G_TYPE_INSTANCE_GET_PRIVATE (socket,
- G_TYPE_SOCKET_INPUT_STREAM,
- GSocketInputStreamPrivate);
-}
-
-GInputStream *
-g_socket_input_stream_new (int fd,
- gboolean close_fd_at_close)
-{
- GSocketInputStream *stream;
-
- stream = g_object_new (G_TYPE_SOCKET_INPUT_STREAM, NULL);
-
- stream->priv->fd = fd;
- stream->priv->close_fd_at_close = close_fd_at_close;
-
- return G_INPUT_STREAM (stream);
-}
-
-static gssize
-g_socket_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GSocketInputStream *socket_stream;
- gssize res;
- struct pollfd poll_fds[2];
- int poll_ret;
- int cancel_fd;
-
- socket_stream = G_SOCKET_INPUT_STREAM (stream);
-
- cancel_fd = g_cancellable_get_fd (cancellable);
- if (cancel_fd != -1)
- {
- do
- {
- poll_fds[0].events = POLLIN;
- poll_fds[0].fd = socket_stream->priv->fd;
- poll_fds[1].events = POLLIN;
- poll_fds[1].fd = cancel_fd;
- poll_ret = poll (poll_fds, 2, -1);
- }
- while (poll_ret == -1 && errno == EINTR);
-
- if (poll_ret == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error reading from socket: %s"),
- g_strerror (errno));
- return -1;
- }
- }
-
- while (1)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- break;
- res = read (socket_stream->priv->fd, buffer, count);
- if (res == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error reading from socket: %s"),
- g_strerror (errno));
- }
-
- break;
- }
-
- return res;
-}
-
-static gboolean
-g_socket_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GSocketInputStream *socket_stream;
- int res;
-
- socket_stream = G_SOCKET_INPUT_STREAM (stream);
-
- if (!socket_stream->priv->close_fd_at_close)
- return TRUE;
-
- while (1)
- {
- /* This might block during the close. Doesn't seem to be a way to avoid it though. */
- res = close (socket_stream->priv->fd);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing socket: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- return res != -1;
-}
-
-typedef struct {
- gsize count;
- void *buffer;
- GAsyncReadyCallback callback;
- gpointer user_data;
- GCancellable *cancellable;
- GSocketInputStream *stream;
-} ReadAsyncData;
-
-static gboolean
-read_async_cb (ReadAsyncData *data,
- GIOCondition condition,
- int fd)
-{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
- gssize count_read;
-
- /* We know that we can read from fd once without blocking */
- while (1)
- {
- if (g_cancellable_set_error_if_cancelled (data->cancellable, &error))
- {
- count_read = -1;
- break;
- }
- count_read = read (data->stream->priv->fd, data->buffer, data->count);
- if (count_read == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error reading from socket: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- simple = g_simple_async_result_new (G_OBJECT (data->stream),
- data->callback,
- data->user_data,
- g_socket_input_stream_read_async);
-
- g_simple_async_result_set_op_res_gssize (simple, count_read);
-
- if (count_read == -1)
- {
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
- }
-
- /* Complete immediately, not in idle, since we're already in a mainloop callout */
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-
- return FALSE;
-}
-
-static void
-g_socket_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSource *source;
- GSocketInputStream *socket_stream;
- ReadAsyncData *data;
-
- socket_stream = G_SOCKET_INPUT_STREAM (stream);
-
- data = g_new0 (ReadAsyncData, 1);
- data->count = count;
- data->buffer = buffer;
- data->callback = callback;
- data->user_data = user_data;
- data->cancellable = cancellable;
- data->stream = socket_stream;
-
- source = _g_fd_source_new (socket_stream->priv->fd,
- POLLIN,
- cancellable);
-
- g_source_set_callback (source, (GSourceFunc)read_async_cb, data, g_free);
- g_source_attach (source, NULL);
-
- g_source_unref (source);
-}
-
-static gssize
-g_socket_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gssize nread;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- g_assert (g_simple_async_result_get_source_tag (simple) == g_socket_input_stream_read_async);
-
- nread = g_simple_async_result_get_op_res_gssize (simple);
- return nread;
-}
-
-static void
-g_socket_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data)
-{
- g_assert_not_reached ();
- /* TODO: Not implemented */
-}
-
-static gssize
-g_socket_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- g_assert_not_reached ();
- /* TODO: Not implemented */
-}
-
-
-typedef struct {
- GInputStream *stream;
- GAsyncReadyCallback callback;
- gpointer user_data;
-} CloseAsyncData;
-
-static void
-close_async_data_free (gpointer _data)
-{
- CloseAsyncData *data = _data;
-
- g_free (data);
-}
-
-static gboolean
-close_async_cb (CloseAsyncData *data)
-{
- GSocketInputStream *socket_stream;
- GSimpleAsyncResult *simple;
- GError *error = NULL;
- gboolean result;
- int res;
-
- socket_stream = G_SOCKET_INPUT_STREAM (data->stream);
-
- if (!socket_stream->priv->close_fd_at_close)
- {
- result = TRUE;
- goto out;
- }
-
- while (1)
- {
- res = close (socket_stream->priv->fd);
- if (res == -1)
- {
- g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing socket: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- result = res != -1;
-
- out:
- simple = g_simple_async_result_new (G_OBJECT (data->stream),
- data->callback,
- data->user_data,
- g_socket_input_stream_close_async);
-
- if (!result)
- {
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
- }
-
- /* Complete immediately, not in idle, since we're already in a mainloop callout */
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-
- return FALSE;
-}
-
-static void
-g_socket_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSource *idle;
- CloseAsyncData *data;
-
- data = g_new0 (CloseAsyncData, 1);
-
- data->stream = stream;
- data->callback = callback;
- data->user_data = user_data;
-
- idle = g_idle_source_new ();
- g_source_set_callback (idle, (GSourceFunc)close_async_cb, data, close_async_data_free);
- g_source_attach (idle, NULL);
- g_source_unref (idle);
-}
-
-static gboolean
-g_socket_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- /* Failures handled in generic close_finish code */
- return TRUE;
-}
-
diff --git a/gio/gsocketinputstream.h b/gio/gsocketinputstream.h
deleted file mode 100644
index 32beff28..00000000
--- a/gio/gsocketinputstream.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __G_SOCKET_INPUT_STREAM_H__
-#define __G_SOCKET_INPUT_STREAM_H__
-
-#include <gio/ginputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_SOCKET_INPUT_STREAM (g_socket_input_stream_get_type ())
-#define G_SOCKET_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SOCKET_INPUT_STREAM, GSocketInputStream))
-#define G_SOCKET_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SOCKET_INPUT_STREAM, GSocketInputStreamClass))
-#define G_IS_SOCKET_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SOCKET_INPUT_STREAM))
-#define G_IS_SOCKET_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SOCKET_INPUT_STREAM))
-#define G_SOCKET_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SOCKET_INPUT_STREAM, GSocketInputStreamClass))
-
-typedef struct _GSocketInputStream GSocketInputStream;
-typedef struct _GSocketInputStreamClass GSocketInputStreamClass;
-typedef struct _GSocketInputStreamPrivate GSocketInputStreamPrivate;
-
-struct _GSocketInputStream
-{
- GInputStream parent;
-
- /*< private >*/
- GSocketInputStreamPrivate *priv;
-};
-
-struct _GSocketInputStreamClass
-{
- GInputStreamClass parent_class;
-};
-
-GType g_socket_input_stream_get_type (void) G_GNUC_CONST;
-
-GInputStream *g_socket_input_stream_new (int fd,
- gboolean close_fd_at_close);
-
-G_END_DECLS
-
-#endif /* __G_SOCKET_INPUT_STREAM_H__ */
diff --git a/gio/gsocketoutputstream.c b/gio/gsocketoutputstream.c
deleted file mode 100644
index c0394078..00000000
--- a/gio/gsocketoutputstream.c
+++ /dev/null
@@ -1,391 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <poll.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <glib/gi18n-lib.h>
-#include "gioerror.h"
-#include "gsocketoutputstream.h"
-#include "gcancellable.h"
-#include "gsimpleasyncresult.h"
-#include "gasynchelper.h"
-
-G_DEFINE_TYPE (GSocketOutputStream, g_socket_output_stream, G_TYPE_OUTPUT_STREAM);
-
-
-struct _GSocketOutputStreamPrivate {
- int fd;
- gboolean close_fd_at_close;
-};
-
-static gssize g_socket_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error);
-static gboolean g_socket_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error);
-static void g_socket_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gssize g_socket_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-static void g_socket_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer data);
-static gboolean g_socket_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error);
-
-
-static void
-g_socket_output_stream_finalize (GObject *object)
-{
- GSocketOutputStream *stream;
-
- stream = G_SOCKET_OUTPUT_STREAM (object);
-
- if (G_OBJECT_CLASS (g_socket_output_stream_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_socket_output_stream_parent_class)->finalize) (object);
-}
-
-static void
-g_socket_output_stream_class_init (GSocketOutputStreamClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GOutputStreamClass *stream_class = G_OUTPUT_STREAM_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GSocketOutputStreamPrivate));
-
- gobject_class->finalize = g_socket_output_stream_finalize;
-
- stream_class->write = g_socket_output_stream_write;
- stream_class->close = g_socket_output_stream_close;
- stream_class->write_async = g_socket_output_stream_write_async;
- stream_class->write_finish = g_socket_output_stream_write_finish;
- stream_class->close_async = g_socket_output_stream_close_async;
- stream_class->close_finish = g_socket_output_stream_close_finish;
-}
-
-static void
-g_socket_output_stream_init (GSocketOutputStream *socket)
-{
- socket->priv = G_TYPE_INSTANCE_GET_PRIVATE (socket,
- G_TYPE_SOCKET_OUTPUT_STREAM,
- GSocketOutputStreamPrivate);
-}
-
-GOutputStream *
-g_socket_output_stream_new (int fd,
- gboolean close_fd_at_close)
-{
- GSocketOutputStream *stream;
-
- stream = g_object_new (G_TYPE_SOCKET_OUTPUT_STREAM, NULL);
-
- stream->priv->fd = fd;
- stream->priv->close_fd_at_close = close_fd_at_close;
-
- return G_OUTPUT_STREAM (stream);
-}
-
-static gssize
-g_socket_output_stream_write (GOutputStream *stream,
- const void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
-{
- GSocketOutputStream *socket_stream;
- gssize res;
- struct pollfd poll_fds[2];
- int poll_ret;
- int cancel_fd;
-
- socket_stream = G_SOCKET_OUTPUT_STREAM (stream);
-
- cancel_fd = g_cancellable_get_fd (cancellable);
- if (cancel_fd != -1)
- {
- do
- {
- poll_fds[0].events = POLLOUT;
- poll_fds[0].fd = socket_stream->priv->fd;
- poll_fds[1].events = POLLIN;
- poll_fds[1].fd = cancel_fd;
- poll_ret = poll (poll_fds, 2, -1);
- }
- while (poll_ret == -1 && errno == EINTR);
-
- if (poll_ret == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error writing to socket: %s"),
- g_strerror (errno));
- return -1;
- }
- }
-
- while (1)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- break;
- res = write (socket_stream->priv->fd, buffer, count);
- if (res == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error writing to socket: %s"),
- g_strerror (errno));
- }
-
- break;
- }
-
- return res;
-}
-
-static gboolean
-g_socket_output_stream_close (GOutputStream *stream,
- GCancellable *cancellable,
- GError **error)
-{
- GSocketOutputStream *socket_stream;
- int res;
-
- socket_stream = G_SOCKET_OUTPUT_STREAM (stream);
-
- if (!socket_stream->priv->close_fd_at_close)
- return TRUE;
-
- while (1)
- {
- /* This might block during the close. Doesn't seem to be a way to avoid it though. */
- res = close (socket_stream->priv->fd);
- if (res == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing socket: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- return res != -1;
-}
-
-typedef struct {
- gsize count;
- const void *buffer;
- GAsyncReadyCallback callback;
- gpointer user_data;
- GCancellable *cancellable;
- GSocketOutputStream *stream;
-} WriteAsyncData;
-
-static gboolean
-write_async_cb (WriteAsyncData *data,
- GIOCondition condition,
- int fd)
-{
- GSimpleAsyncResult *simple;
- GError *error = NULL;
- gssize count_written;
-
- while (1)
- {
- if (g_cancellable_set_error_if_cancelled (data->cancellable, &error))
- {
- count_written = -1;
- break;
- }
-
- count_written = write (data->stream->priv->fd, data->buffer, data->count);
- if (count_written == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error reading from socket: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- simple = g_simple_async_result_new (G_OBJECT (data->stream),
- data->callback,
- data->user_data,
- g_socket_output_stream_write_async);
-
- g_simple_async_result_set_op_res_gssize (simple, count_written);
-
- if (count_written == -1)
- {
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
- }
-
- /* Complete immediately, not in idle, since we're already in a mainloop callout */
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-
- return FALSE;
-}
-
-static void
-g_socket_output_stream_write_async (GOutputStream *stream,
- const void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSource *source;
- GSocketOutputStream *socket_stream;
- WriteAsyncData *data;
-
- socket_stream = G_SOCKET_OUTPUT_STREAM (stream);
-
- data = g_new0 (WriteAsyncData, 1);
- data->count = count;
- data->buffer = buffer;
- data->callback = callback;
- data->user_data = user_data;
- data->cancellable = cancellable;
- data->stream = socket_stream;
-
- source = _g_fd_source_new (socket_stream->priv->fd,
- POLLOUT,
- cancellable);
-
- g_source_set_callback (source, (GSourceFunc)write_async_cb, data, g_free);
- g_source_attach (source, NULL);
-
- g_source_unref (source);
-}
-
-static gssize
-g_socket_output_stream_write_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gssize nwritten;
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- g_assert (g_simple_async_result_get_source_tag (simple) == g_socket_output_stream_write_async);
-
- nwritten = g_simple_async_result_get_op_res_gssize (simple);
- return nwritten;
-}
-
-typedef struct {
- GOutputStream *stream;
- GAsyncReadyCallback callback;
- gpointer user_data;
-} CloseAsyncData;
-
-static gboolean
-close_async_cb (CloseAsyncData *data)
-{
- GSocketOutputStream *socket_stream;
- GSimpleAsyncResult *simple;
- GError *error = NULL;
- gboolean result;
- int res;
-
- socket_stream = G_SOCKET_OUTPUT_STREAM (data->stream);
-
- if (!socket_stream->priv->close_fd_at_close)
- {
- result = TRUE;
- goto out;
- }
-
- while (1)
- {
- res = close (socket_stream->priv->fd);
- if (res == -1)
- {
- g_set_error (&error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error closing socket: %s"),
- g_strerror (errno));
- }
- break;
- }
-
- result = res != -1;
-
- out:
- simple = g_simple_async_result_new (G_OBJECT (data->stream),
- data->callback,
- data->user_data,
- g_socket_output_stream_close_async);
-
- if (!result)
- {
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
- }
-
- /* Complete immediately, not in idle, since we're already in a mainloop callout */
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-
- return FALSE;
-}
-
-static void
-g_socket_output_stream_close_async (GOutputStream *stream,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSource *idle;
- CloseAsyncData *data;
-
- data = g_new0 (CloseAsyncData, 1);
-
- data->stream = stream;
- data->callback = callback;
- data->user_data = user_data;
-
- idle = g_idle_source_new ();
- g_source_set_callback (idle, (GSourceFunc)close_async_cb, data, g_free);
- g_source_attach (idle, NULL);
- g_source_unref (idle);
-}
-
-static gboolean
-g_socket_output_stream_close_finish (GOutputStream *stream,
- GAsyncResult *result,
- GError **error)
-{
- /* Failures handled in generic close_finish code */
- return TRUE;
-}
diff --git a/gio/gsocketoutputstream.h b/gio/gsocketoutputstream.h
deleted file mode 100644
index 235c905f..00000000
--- a/gio/gsocketoutputstream.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __G_SOCKET_OUTPUT_STREAM_H__
-#define __G_SOCKET_OUTPUT_STREAM_H__
-
-#include <gio/goutputstream.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_SOCKET_OUTPUT_STREAM (g_socket_output_stream_get_type ())
-#define G_SOCKET_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_SOCKET_OUTPUT_STREAM, GSocketOutputStream))
-#define G_SOCKET_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_SOCKET_OUTPUT_STREAM, GSocketOutputStreamClass))
-#define G_IS_SOCKET_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_SOCKET_OUTPUT_STREAM))
-#define G_IS_SOCKET_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_SOCKET_OUTPUT_STREAM))
-#define G_SOCKET_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_SOCKET_OUTPUT_STREAM, GSocketOutputStreamClass))
-
-typedef struct _GSocketOutputStream GSocketOutputStream;
-typedef struct _GSocketOutputStreamClass GSocketOutputStreamClass;
-typedef struct _GSocketOutputStreamPrivate GSocketOutputStreamPrivate;
-
-struct _GSocketOutputStream
-{
- GOutputStream parent;
-
- /*< private >*/
- GSocketOutputStreamPrivate *priv;
-};
-
-struct _GSocketOutputStreamClass
-{
- GOutputStreamClass parent_class;
-};
-
-GType g_socket_output_stream_get_type (void) G_GNUC_CONST;
-
-GOutputStream *g_socket_output_stream_new (int fd,
- gboolean close_fd_at_close);
-
-G_END_DECLS
-
-#endif /* __G_SOCKET_OUTPUT_STREAM_H__ */
diff --git a/gio/gthemedicon.c b/gio/gthemedicon.c
deleted file mode 100644
index 82a1c14e..00000000
--- a/gio/gthemedicon.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include <config.h>
-
-#include "gthemedicon.h"
-
-static void g_themed_icon_icon_iface_init (GIconIface *iface);
-
-struct _GThemedIcon
-{
- GObject parent_instance;
-
- char **names;
-};
-
-G_DEFINE_TYPE_WITH_CODE (GThemedIcon, g_themed_icon, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
- g_themed_icon_icon_iface_init))
-
-static void
-g_themed_icon_finalize (GObject *object)
-{
- GThemedIcon *themed;
-
- themed = G_THEMED_ICON (object);
-
- g_strfreev (themed->names);
-
- if (G_OBJECT_CLASS (g_themed_icon_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_themed_icon_parent_class)->finalize) (object);
-}
-
-static void
-g_themed_icon_class_init (GThemedIconClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_themed_icon_finalize;
-}
-
-static void
-g_themed_icon_init (GThemedIcon *themed)
-{
-}
-
-GIcon *
-g_themed_icon_new (const char *iconname)
-{
- GThemedIcon *themed;
-
- themed = g_object_new (G_TYPE_THEMED_ICON, NULL);
- themed->names = g_new (char *, 2);
- themed->names[0] = g_strdup (iconname);
- themed->names[1] = NULL;
-
- return G_ICON (themed);
-}
-
-GIcon *
-g_themed_icon_new_from_names (char **iconnames, int len)
-{
- GThemedIcon *themed;
- int i;
-
- themed = g_object_new (G_TYPE_THEMED_ICON, NULL);
- if (len == -1)
- themed->names = g_strdupv (iconnames);
- else
- {
- themed->names = g_new (char *, len + 1);
- for (i = 0; i < len; i++)
- themed->names[i] = g_strdup (iconnames[i]);
- }
-
-
- return G_ICON (themed);
-}
-
-char **
-g_themed_icon_get_names (GThemedIcon *icon)
-{
- return icon->names;
-}
-
-static guint
-g_themed_icon_hash (GIcon *icon)
-{
- GThemedIcon *themed = G_THEMED_ICON (icon);
- guint hash;
- int i;
-
- hash = 0;
-
- for (i = 0; themed->names[i] != NULL; i++)
- hash ^= g_str_hash (themed->names[i]);
-
- return hash;
-}
-
-static gboolean
-g_themed_icon_equal (GIcon *icon1,
- GIcon *icon2)
-{
- GThemedIcon *themed1 = G_THEMED_ICON (icon1);
- GThemedIcon *themed2 = G_THEMED_ICON (icon2);
- int i;
-
- for (i = 0; themed1->names[i] != NULL && themed2->names[i] != NULL; i++)
- {
- if (!g_str_equal (themed1->names[i], themed2->names[i]))
- return FALSE;
- }
-
- return themed1->names[i] == NULL && themed2->names[i] == NULL;
-}
-
-
-static void
-g_themed_icon_icon_iface_init (GIconIface *iface)
-{
- iface->hash = g_themed_icon_hash;
- iface->equal = g_themed_icon_equal;
-}
diff --git a/gio/gthemedicon.h b/gio/gthemedicon.h
deleted file mode 100644
index 4f39c3b1..00000000
--- a/gio/gthemedicon.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __G_THEMED_ICON_H__
-#define __G_THEMED_ICON_H__
-
-#include <gio/gicon.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_THEMED_ICON (g_themed_icon_get_type ())
-#define G_THEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_THEMED_ICON, GThemedIcon))
-#define G_THEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_THEMED_ICON, GThemedIconClass))
-#define G_IS_THEMED_ICON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_THEMED_ICON))
-#define G_IS_THEMED_ICON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_THEMED_ICON))
-#define G_THEMED_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_THEMED_ICON, GThemedIconClass))
-
-typedef struct _GThemedIcon GThemedIcon;
-typedef struct _GThemedIconClass GThemedIconClass;
-
-struct _GThemedIconClass
-{
- GObjectClass parent_class;
-};
-
-GType g_themed_icon_get_type (void) G_GNUC_CONST;
-
-GIcon *g_themed_icon_new (const char *iconname);
-GIcon *g_themed_icon_new_from_names (char **iconnames, int len);
-
-char **g_themed_icon_get_names (GThemedIcon *icon);
-
-G_END_DECLS
-
-#endif /* __G_THEMED_ICON_H__ */
diff --git a/gio/guniondrive.c b/gio/guniondrive.c
deleted file mode 100644
index cc2f9f33..00000000
--- a/gio/guniondrive.c
+++ /dev/null
@@ -1,274 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include "guniondrive.h"
-#include "gunionvolumemonitor.h"
-#include "gdrivepriv.h"
-
-/* In general we don't expect collisions in drives
- * between HAL and unix-mounts. Either you use HAL to
- * enumerate removable devices, or user-mountable
- * entries in fstab. So, we don't merge drives, saving
- * considerable complexity, at the cost of having double
- * drives in weird cases (and these two drives would have
- * the same volume).
- */
-
-struct _GUnionDrive {
- GObject parent;
- GVolumeMonitor *union_monitor;
-
- GDrive *child_drive;
- GVolumeMonitor *child_monitor;
-};
-
-static void g_union_volume_drive_iface_init (GDriveIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GUnionDrive, g_union_drive, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_DRIVE,
- g_union_volume_drive_iface_init))
-
-static void
-g_union_drive_finalize (GObject *object)
-{
- GUnionDrive *drive;
-
- drive = G_UNION_DRIVE (object);
-
- if (drive->union_monitor)
- g_object_remove_weak_pointer (G_OBJECT (drive->union_monitor), (gpointer *)&drive->union_monitor);
-
- g_object_unref (drive->child_drive);
- g_object_unref (drive->child_monitor);
-
- if (G_OBJECT_CLASS (g_union_drive_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_union_drive_parent_class)->finalize) (object);
-}
-
-static void
-g_union_drive_class_init (GUnionDriveClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_union_drive_finalize;
-}
-
-static void
-g_union_drive_init (GUnionDrive *union_drive)
-{
-}
-
-
-static void
-child_changed (GDrive *child_drive, GDrive *union_drive)
-{
- g_signal_emit_by_name (union_drive, "changed");
-}
-
-GUnionDrive *
-g_union_drive_new (GVolumeMonitor *union_monitor,
- GDrive *child_drive,
- GVolumeMonitor *child_monitor)
-{
- GUnionDrive *drive;
-
- drive = g_object_new (G_TYPE_UNION_DRIVE, NULL);
-
- drive->union_monitor = union_monitor;
- g_object_add_weak_pointer (G_OBJECT (drive->union_monitor),
- (gpointer *)&drive->union_monitor);
-
- drive->child_drive = g_object_ref (child_drive);
- drive->child_monitor = g_object_ref (child_monitor);
-
- g_signal_connect_object (drive->child_drive, "changed", (GCallback)child_changed, drive, 0);
-
- return drive;
-}
-
-gboolean
-g_union_drive_child_is_for_monitor (GUnionDrive *union_drive,
- GVolumeMonitor *child_monitor)
-{
- return (union_drive->child_monitor == child_monitor);
-}
-
-gboolean
-g_union_drive_is_for_child_drive (GUnionDrive *union_drive,
- GDrive *child_drive)
-{
- if (union_drive->child_drive == child_drive)
- return TRUE;
-
- return FALSE;
-}
-
-static char *
-g_union_drive_get_name (GDrive *drive)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
-
- return g_drive_get_name (union_drive->child_drive);
-}
-
-static GIcon *
-g_union_drive_get_icon (GDrive *drive)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
-
- return g_drive_get_icon (union_drive->child_drive);
-}
-
-static gboolean
-g_union_drive_is_automounted (GDrive *drive)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
-
- return g_drive_is_automounted (union_drive->child_drive);
-}
-
-static GList *
-g_union_drive_get_volumes (GDrive *drive)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
- GList *child_volumes, *union_volumes;
-
- if (union_drive->union_monitor == NULL)
- return NULL;
-
- child_volumes = g_drive_get_volumes (union_drive->child_drive);
-
- union_volumes =
- g_union_volume_monitor_convert_volumes (G_UNION_VOLUME_MONITOR (union_drive->union_monitor),
- child_volumes);
- g_list_foreach (child_volumes, (GFunc)g_object_unref, NULL);
- g_list_free (child_volumes);
- return union_volumes;
-}
-
-static gboolean
-g_union_drive_can_mount (GDrive *drive)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
-
- return g_drive_can_mount (union_drive->child_drive);
-}
-
-static gboolean
-g_union_drive_can_eject (GDrive *drive)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
-
- return g_drive_can_eject (union_drive->child_drive);
-}
-
-typedef struct {
- GDrive *union_drive;
- GDrive *child_drive;
- GAsyncReadyCallback callback;
- gpointer user_data;
-} MountOp;
-
-static void
-mount_op_free (gpointer _data)
-{
- MountOp *data = _data;
-
- g_object_unref (data->union_drive);
- g_object_unref (data->child_drive);
- g_free (data);
-}
-
-static void
-union_done (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- MountOp *data = user_data;
-
- g_object_set_data_full (G_OBJECT (res), "union", data, mount_op_free);
- data->callback (G_OBJECT (data->union_drive),
- res, data->user_data);
-}
-
-static void
-g_union_drive_mount (GDrive *drive,
- GMountOperation *mount_operation,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
- MountOp *data;
-
- data = g_new (MountOp, 1);
- data->union_drive = g_object_ref (union_drive);
- data->child_drive = g_object_ref (union_drive->child_drive);
- data->callback = callback;
- data->user_data = user_data;
-
- return g_drive_mount (data->child_drive,
- mount_operation,
- union_done, data);
-}
-
-static gboolean
-g_union_drive_mount_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error)
-{
- MountOp *data;
-
- data = g_object_get_data (G_OBJECT (result), "union");
-
- return g_drive_mount_finish (data->child_drive,
- result,
- error);
-}
-
-static void
-g_union_drive_eject (GDrive *drive,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GUnionDrive *union_drive = G_UNION_DRIVE (drive);
- MountOp *data;
-
- data = g_new (MountOp, 1);
- data->union_drive = g_object_ref (union_drive);
- data->child_drive = g_object_ref (union_drive->child_drive);
- data->callback = callback;
- data->user_data = user_data;
-
- return g_drive_eject (data->child_drive,
- union_done, data);
-}
-
-static gboolean
-g_union_drive_eject_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error)
-{
- MountOp *data;
-
- data = g_object_get_data (G_OBJECT (result), "union");
-
- return g_drive_eject_finish (data->child_drive,
- result,
- error);
-}
-
-static void
-g_union_volume_drive_iface_init (GDriveIface *iface)
-{
- iface->get_name = g_union_drive_get_name;
- iface->get_icon = g_union_drive_get_icon;
- iface->is_automounted = g_union_drive_is_automounted;
- iface->get_volumes = g_union_drive_get_volumes;
- iface->can_mount = g_union_drive_can_mount;
- iface->can_eject = g_union_drive_can_eject;
- iface->mount = g_union_drive_mount;
- iface->mount_finish = g_union_drive_mount_finish;
- iface->eject = g_union_drive_eject;
- iface->eject_finish = g_union_drive_eject_finish;
-}
diff --git a/gio/guniondrive.h b/gio/guniondrive.h
deleted file mode 100644
index b1c28b52..00000000
--- a/gio/guniondrive.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __G_UNION_DRIVE_H__
-#define __G_UNION_DRIVE_H__
-
-#include <glib-object.h>
-#include <gio/gdrive.h>
-#include <gio/gvolumemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_UNION_DRIVE (g_union_drive_get_type ())
-#define G_UNION_DRIVE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNION_DRIVE, GUnionDrive))
-#define G_UNION_DRIVE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNION_DRIVE, GUnionDriveClass))
-#define G_IS_UNION_DRIVE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNION_DRIVE))
-#define G_IS_UNION_DRIVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNION_DRIVE))
-
-typedef struct _GUnionDrive GUnionDrive;
-typedef struct _GUnionDriveClass GUnionDriveClass;
-
-struct _GUnionDriveClass {
- GObjectClass parent_class;
-};
-
-GType g_union_drive_get_type (void) G_GNUC_CONST;
-
-GUnionDrive *g_union_drive_new (GVolumeMonitor *union_monitor,
- GDrive *child_drive,
- GVolumeMonitor *child_monitor);
-gboolean g_union_drive_is_for_child_drive (GUnionDrive *union_drive,
- GDrive *child_drive);
-gboolean g_union_drive_child_is_for_monitor (GUnionDrive *union_drive,
- GVolumeMonitor *child_monitor);
-
-G_END_DECLS
-
-#endif /* __G_UNION_DRIVE_H__ */
diff --git a/gio/gunionvolume.c b/gio/gunionvolume.c
deleted file mode 100644
index eaefbf50..00000000
--- a/gio/gunionvolume.c
+++ /dev/null
@@ -1,431 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include "gunionvolume.h"
-#include "gunionvolumemonitor.h"
-#include "gvolumepriv.h"
-#include "gsimpleasyncresult.h"
-
-typedef struct {
- GVolume *volume;
- GVolumeMonitor *monitor;
- guint32 changed_tag;
-} ChildVolume;
-
-struct _GUnionVolume {
- GObject parent;
- GVolumeMonitor *union_monitor;
-
- GList *child_volumes;
-};
-
-static void g_union_volue_volume_iface_init (GVolumeIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GUnionVolume, g_union_volume, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_VOLUME,
- g_union_volue_volume_iface_init))
-
-
-static void
-g_union_volume_finalize (GObject *object)
-{
- GUnionVolume *volume;
- ChildVolume *child;
- GList *l;
-
- volume = G_UNION_VOLUME (object);
-
- if (volume->union_monitor)
- g_object_remove_weak_pointer (G_OBJECT (volume->union_monitor), (gpointer *)&volume->union_monitor);
-
- for (l = volume->child_volumes; l != NULL; l = l->next)
- {
- child = l->data;
-
- g_signal_handler_disconnect (child->volume, child->changed_tag);
- g_object_unref (child->volume);
- g_object_unref (child->monitor);
- g_free (child);
- }
- g_list_free (volume->child_volumes);
-
- if (G_OBJECT_CLASS (g_union_volume_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_union_volume_parent_class)->finalize) (object);
-}
-
-static void
-g_union_volume_class_init (GUnionVolumeClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_union_volume_finalize;
-}
-
-
-static void
-g_union_volume_init (GUnionVolume *union_volume)
-{
-}
-
-GUnionVolume *
-g_union_volume_new (GVolumeMonitor *union_monitor,
- GVolume *child_volume,
- GVolumeMonitor *child_monitor)
-{
- GUnionVolume *volume;
-
- volume = g_object_new (G_TYPE_UNION_VOLUME, NULL);
-
- volume->union_monitor = union_monitor;
- g_object_add_weak_pointer (G_OBJECT (volume->union_monitor),
- (gpointer *)&volume->union_monitor);
-
-
- g_union_volume_add_volume (volume, child_volume, child_monitor);
-
- return volume;
-}
-
-static void
-child_changed (GDrive *child_drive, GDrive *union_drive)
-{
- g_signal_emit_by_name (union_drive, "changed");
-}
-
-void
-g_union_volume_add_volume (GUnionVolume *union_volume,
- GVolume *child_volume,
- GVolumeMonitor *child_monitor)
-{
- ChildVolume *child;
-
- child = g_new (ChildVolume, 1);
- child->volume = g_object_ref (child_volume);
- child->monitor = g_object_ref (child_monitor);
- child->changed_tag = g_signal_connect (child->volume, "changed", (GCallback)child_changed, union_volume);
-
- union_volume->child_volumes = g_list_prepend (union_volume->child_volumes, child);
-
- g_signal_emit_by_name (union_volume, "changed");
-}
-
-gboolean
-g_union_volume_is_last_child (GUnionVolume *union_volume,
- GVolume *child_volume)
-{
- if (union_volume->child_volumes != NULL &&
- union_volume->child_volumes->next == NULL)
- {
- ChildVolume *child = union_volume->child_volumes->data;
- if (child->volume == child_volume)
- return TRUE;
- }
- return FALSE;
-}
-
-void
-g_union_volume_remove_volume (GUnionVolume *union_volume,
- GVolume *child_volume)
-{
- GList *l;
- ChildVolume *child;
-
-
- for (l = union_volume->child_volumes; l != NULL; l = l->next)
- {
- child = l->data;
-
- if (child->volume == child_volume)
- {
- union_volume->child_volumes = g_list_delete_link (union_volume->child_volumes, l);
- g_signal_handler_disconnect (child->volume, child->changed_tag);
- g_object_unref (child->volume);
- g_object_unref (child->monitor);
- g_free (child);
-
- g_signal_emit_by_name (union_volume, "changed");
-
- return;
- }
- }
-}
-
-GVolume *
-g_union_volume_get_child_for_monitor (GUnionVolume *union_volume,
- GVolumeMonitor *child_monitor)
-{
- GList *l;
- ChildVolume *child;
-
- for (l = union_volume->child_volumes; l != NULL; l = l->next)
- {
- child = l->data;
-
- if (child->monitor == child_monitor)
- return g_object_ref (child->volume);
- }
-
- return NULL;
-}
-
-gboolean
-g_union_volume_has_child_volume (GUnionVolume *union_volume,
- GVolume *child_volume)
-{
- GList *l;
- ChildVolume *child;
-
- for (l = union_volume->child_volumes; l != NULL; l = l->next)
- {
- child = l->data;
-
- if (child->volume == child_volume)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static char *
-g_union_volume_get_platform_id (GVolume *volume)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- return g_volume_get_platform_id (child->volume);
- }
- return NULL;
-}
-
-static char *
-g_union_volume_get_name (GVolume *volume)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- return g_volume_get_name (child->volume);
- }
- return g_strdup ("volume");
-}
-
-static GIcon *
-g_union_volume_get_icon (GVolume *volume)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- return g_volume_get_icon (child->volume);
- }
- return NULL;
-}
-
-static GFile *
-g_union_volume_get_root (GVolume *volume)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- return g_volume_get_root (child->volume);
- }
- return NULL;
-}
-
-static GDrive *
-g_union_volume_get_drive (GVolume *volume)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
- GDrive *child_drive, *union_drive;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- child_drive = g_volume_get_drive (child->volume);
- union_drive = NULL;
- if (child_drive)
- {
- union_drive = g_union_volume_monitor_convert_drive (G_UNION_VOLUME_MONITOR (union_volume->union_monitor),
- child_drive);
- g_object_unref (child_drive);
- }
- return union_drive;
- }
- return NULL;
-}
-
-static gboolean
-g_union_volume_can_unmount (GVolume *volume)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- return g_volume_can_unmount (child->volume);
- }
- return FALSE;
-}
-
-static gboolean
-g_union_volume_can_eject (GVolume *volume)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- return g_volume_can_eject (child->volume);
- }
- return FALSE;
-}
-
-typedef struct {
- GVolume *union_volume;
- GVolume *child_volume;
- GAsyncReadyCallback callback;
- gpointer user_data;
-} MountOp;
-
-static void
-mount_op_free (gpointer _data)
-{
- MountOp *data = _data;
-
- g_object_unref (data->union_volume);
- g_object_unref (data->child_volume);
- g_free (data);
-}
-
-static void
-union_done (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- MountOp *data = user_data;
-
- g_object_set_data_full (G_OBJECT (res), "union", data, mount_op_free);
- data->callback (G_OBJECT (data->union_volume),
- res, data->user_data);
-}
-
-static void
-g_union_volume_unmount (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
- MountOp *data;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
-
- data = g_new (MountOp, 1);
- data->union_volume = g_object_ref (volume);
- data->child_volume = g_object_ref (child->volume);
- data->callback = callback;
- data->user_data = user_data;
-
- return g_volume_unmount (data->child_volume,
- union_done, data);
- }
- else
- {
- g_simple_async_report_error_in_idle (G_OBJECT (volume),
- callback, user_data,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
-
- }
-}
-
-static gboolean
-g_union_volume_unmount_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error)
-{
- MountOp *data;
-
- data = g_object_get_data (G_OBJECT (result), "union");
-
- return g_volume_unmount_finish (data->child_volume,
- result, error);
-}
-
-static void
-g_union_volume_eject (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GUnionVolume *union_volume = G_UNION_VOLUME (volume);
- ChildVolume *child;
- MountOp *data;
-
- if (union_volume->child_volumes)
- {
- child = union_volume->child_volumes->data;
- data = g_new (MountOp, 1);
- data->union_volume = g_object_ref (volume);
- data->child_volume = g_object_ref (child->volume);
- data->callback = callback;
- data->user_data = user_data;
-
- return g_volume_eject (data->child_volume,
- union_done, data);
- }
- else
- {
- g_simple_async_report_error_in_idle (G_OBJECT (volume),
- callback, user_data,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
-
- }
-}
-
-
-static gboolean
-g_union_volume_eject_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error)
-{
- MountOp *data;
-
- data = g_object_get_data (G_OBJECT (result), "union");
-
- return g_volume_eject_finish (data->child_volume,
- result, error);
-}
-
-
-static void
-g_union_volue_volume_iface_init (GVolumeIface *iface)
-{
- iface->get_platform_id = g_union_volume_get_platform_id;
- iface->get_name = g_union_volume_get_name;
- iface->get_icon = g_union_volume_get_icon;
- iface->get_root = g_union_volume_get_root;
- iface->get_drive = g_union_volume_get_drive;
- iface->can_unmount = g_union_volume_can_unmount;
- iface->can_eject = g_union_volume_can_eject;
- iface->unmount = g_union_volume_unmount;
- iface->unmount_finish = g_union_volume_unmount_finish;
- iface->eject = g_union_volume_eject;
- iface->eject_finish = g_union_volume_eject_finish;
-}
diff --git a/gio/gunionvolume.h b/gio/gunionvolume.h
deleted file mode 100644
index 28d0d5f9..00000000
--- a/gio/gunionvolume.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __G_UNION_VOLUME_H__
-#define __G_UNION_VOLUME_H__
-
-#include <glib-object.h>
-#include <gio/gvolume.h>
-#include <gio/gvolumemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_UNION_VOLUME (g_union_volume_get_type ())
-#define G_UNION_VOLUME(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNION_VOLUME, GUnionVolume))
-#define G_UNION_VOLUME_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNION_VOLUME, GUnionVolumeClass))
-#define G_IS_UNION_VOLUME(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNION_VOLUME))
-#define G_IS_UNION_VOLUME_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNION_VOLUME))
-
-typedef struct _GUnionVolume GUnionVolume;
-typedef struct _GUnionVolumeClass GUnionVolumeClass;
-
-struct _GUnionVolumeClass {
- GObjectClass parent_class;
-};
-
-GType g_union_volume_get_type (void) G_GNUC_CONST;
-
-GUnionVolume *g_union_volume_new (GVolumeMonitor *union_monitor,
- GVolume *volume,
- GVolumeMonitor *monitor);
-void g_union_volume_add_volume (GUnionVolume *union_volume,
- GVolume *volume,
- GVolumeMonitor *monitor);
-void g_union_volume_remove_volume (GUnionVolume *union_volume,
- GVolume *volume);
-gboolean g_union_volume_is_last_child (GUnionVolume *union_volume,
- GVolume *child_volume);
-gboolean g_union_volume_has_child_volume (GUnionVolume *union_volume,
- GVolume *child_volume);
-GVolume * g_union_volume_get_child_for_monitor (GUnionVolume *union_volume,
- GVolumeMonitor *child_monitor);
-
-G_END_DECLS
-
-#endif /* __G_UNION_VOLUME_H__ */
diff --git a/gio/gunionvolumemonitor.c b/gio/gunionvolumemonitor.c
deleted file mode 100644
index c868763b..00000000
--- a/gio/gunionvolumemonitor.c
+++ /dev/null
@@ -1,468 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include "gunionvolumemonitor.h"
-#include "gunionvolume.h"
-#include "guniondrive.h"
-#include "gvolumepriv.h"
-#include "giomodule.h"
-#ifdef G_OS_UNIX
-#include "gunixvolumemonitor.h"
-#endif
-
-struct _GUnionVolumeMonitor {
- GVolumeMonitor parent;
-
- GList *monitors;
- GList *volumes;
- GList *drives;
-};
-
-static void g_union_volume_monitor_remove_monitor (GUnionVolumeMonitor *union_monitor,
- GVolumeMonitor *child_monitor);
-
-
-G_DEFINE_TYPE (GUnionVolumeMonitor, g_union_volume_monitor, G_TYPE_VOLUME_MONITOR);
-
-G_LOCK_DEFINE_STATIC(the_volume_monitor);
-static GUnionVolumeMonitor *the_volume_monitor = NULL;
-
-static void
-g_union_volume_monitor_finalize (GObject *object)
-{
- GUnionVolumeMonitor *monitor;
-
- monitor = G_UNION_VOLUME_MONITOR (object);
-
- while (monitor->monitors != NULL)
- g_union_volume_monitor_remove_monitor (monitor,
- monitor->monitors->data);
-
- if (G_OBJECT_CLASS (g_union_volume_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_union_volume_monitor_parent_class)->finalize) (object);
-}
-
-static void
-g_union_volume_monitor_dispose (GObject *object)
-{
- GUnionVolumeMonitor *monitor;
-
- monitor = G_UNION_VOLUME_MONITOR (object);
-
- G_LOCK (the_volume_monitor);
- the_volume_monitor = NULL;
- G_UNLOCK (the_volume_monitor);
-
- if (G_OBJECT_CLASS (g_union_volume_monitor_parent_class)->dispose)
- (*G_OBJECT_CLASS (g_union_volume_monitor_parent_class)->dispose) (object);
-}
-
-static GList *
-get_mounted_volumes (GVolumeMonitor *volume_monitor)
-{
- GUnionVolumeMonitor *monitor;
- GList *l;
-
- monitor = G_UNION_VOLUME_MONITOR (volume_monitor);
-
- l = g_list_copy (monitor->volumes);
- g_list_foreach (l, (GFunc)g_object_ref, NULL);
-
- return l;
-}
-
-static GList *
-get_connected_drives (GVolumeMonitor *volume_monitor)
-{
- GUnionVolumeMonitor *monitor;
- GList *l;
-
- monitor = G_UNION_VOLUME_MONITOR (volume_monitor);
-
- l = g_list_copy (monitor->drives);
- g_list_foreach (l, (GFunc)g_object_ref, NULL);
-
- return l;
-}
-
-static void
-g_union_volume_monitor_class_init (GUnionVolumeMonitorClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GVolumeMonitorClass *monitor_class = G_VOLUME_MONITOR_CLASS (klass);
-
- gobject_class->finalize = g_union_volume_monitor_finalize;
- gobject_class->dispose = g_union_volume_monitor_dispose;
-
- monitor_class->get_mounted_volumes = get_mounted_volumes;
- monitor_class->get_connected_drives = get_connected_drives;
-}
-
-static void
-add_child_volume (GUnionVolumeMonitor *union_monitor,
- GVolume *child_volume,
- GVolumeMonitor *child_monitor)
-{
- char *platform_id, *id;
- GList *l;
- GUnionVolume *union_volume;
-
- /* TODO: Add locking everywhere... */
- platform_id = g_volume_get_platform_id (child_volume);
-
- if (platform_id)
- {
- for (l = union_monitor->volumes; l != NULL; l = l->next)
- {
- GVolume *current_child = l->data;
- id = g_volume_get_platform_id (current_child);
-
- if (id && strcmp (id, platform_id) == 0)
- {
- g_union_volume_add_volume (G_UNION_VOLUME (current_child), child_volume, child_monitor);
- g_free (id);
- g_free (platform_id);
- return;
- }
- g_free (id);
- }
- g_free (platform_id);
- }
-
- union_volume = g_union_volume_new (G_VOLUME_MONITOR (union_monitor), child_volume, child_monitor);
- union_monitor->volumes = g_list_prepend (union_monitor->volumes,
- union_volume);
- g_signal_emit_by_name (union_monitor,
- "volume_mounted",
- union_volume);
-}
-
-static GUnionVolume *
-lookup_union_volume (GUnionVolumeMonitor *union_monitor,
- GVolume *child_volume)
-{
- GList *l;
- GUnionVolume *union_volume;
-
- for (l = union_monitor->volumes; l != NULL; l = l->next)
- {
- union_volume = l->data;
-
- if (g_union_volume_has_child_volume (union_volume, child_volume))
- return union_volume;
- }
- return NULL;
-}
-
-static void
-remove_child_volume (GUnionVolumeMonitor *union_monitor,
- GVolume *child_volume)
-{
- GUnionVolume *union_volume;
- gboolean last;
-
- union_volume = lookup_union_volume (union_monitor, child_volume);
- if (union_volume == NULL)
- return;
-
- last = g_union_volume_is_last_child (union_volume, child_volume);
-
- /* Emit volume_unmounted before we remove the child volume so that
- ops still work on the union volume */
- if (last)
- {
- union_monitor->volumes = g_list_remove (union_monitor->volumes,
- union_volume);
- g_signal_emit_by_name (union_monitor,
- "volume_unmounted",
- union_volume);
- }
-
- g_union_volume_remove_volume (union_volume, child_volume);
-
- if (last)
- g_object_unref (union_volume);
-}
-
-static GUnionDrive *
-lookup_union_drive (GUnionVolumeMonitor *union_monitor,
- GDrive *child_drive)
-{
- GList *l;
- GUnionDrive *union_drive;
-
- for (l = union_monitor->drives; l != NULL; l = l->next)
- {
- union_drive = l->data;
-
- if (g_union_drive_is_for_child_drive (union_drive, child_drive))
- return union_drive;
- }
- return NULL;
-}
-
-
-static void
-add_child_drive (GUnionVolumeMonitor *union_monitor,
- GDrive *child_drive,
- GVolumeMonitor *child_monitor)
-{
- GUnionDrive *union_drive;
-
- union_drive = g_union_drive_new (G_VOLUME_MONITOR (union_monitor), child_drive, child_monitor);
- union_monitor->drives = g_list_prepend (union_monitor->drives,
- union_drive);
- g_signal_emit_by_name (union_monitor,
- "drive_connected",
- child_drive);
-}
-
-
-static void
-remove_union_drive (GUnionVolumeMonitor *union_monitor,
- GUnionDrive *union_drive)
-{
- union_monitor->drives = g_list_remove (union_monitor->drives,
- union_drive);
- g_signal_emit_by_name (union_monitor,
- "drive_disconnected",
- union_drive);
- g_object_unref (union_drive);
-}
-
-static void
-remove_child_drive (GUnionVolumeMonitor *union_monitor,
- GDrive *child_drive)
-{
- GUnionDrive *union_drive;
-
- union_drive = lookup_union_drive (union_monitor, child_drive);
- if (union_drive)
- remove_union_drive (union_monitor, union_drive);
-}
-
-static void
-child_volume_mounted (GVolumeMonitor *child_monitor,
- GVolume *child_volume,
- GUnionVolumeMonitor *union_monitor)
-{
- add_child_volume (union_monitor,
- child_volume,
- child_monitor);
-}
-
-static void
-child_volume_pre_unmount (GVolumeMonitor *child_monitor,
- GVolume *child_volume,
- GUnionVolumeMonitor *union_monitor)
-{
- GUnionVolume *union_volume;
-
- union_volume = lookup_union_volume (union_monitor, child_volume);
- if (union_volume)
- g_signal_emit_by_name (union_monitor,
- "volume_pre_unmount",
- union_volume);
-}
-
-static void
-child_volume_unmounted (GVolumeMonitor *child_monitor,
- GVolume *volume,
- GUnionVolumeMonitor *union_monitor)
-{
- remove_child_volume (union_monitor, volume);
-}
-
-static void
-child_drive_connected (GVolumeMonitor *child_monitor,
- GDrive *drive,
- GUnionVolumeMonitor *union_monitor)
-{
- add_child_drive (union_monitor, drive, child_monitor);
-}
-
-static void
-child_drive_disconnected (GVolumeMonitor *child_monitor,
- GDrive *drive,
- GUnionVolumeMonitor *union_monitor)
-{
- remove_child_drive (union_monitor, drive);
-}
-
-static void
-g_union_volume_monitor_add_monitor (GUnionVolumeMonitor *union_monitor,
- GVolumeMonitor *volume_monitor)
-{
- GList *volumes, *drives, *l;
- GVolume *volume;
- GDrive *drive;
-
- if (g_list_find (union_monitor->monitors, volume_monitor))
- return;
-
- union_monitor->monitors = g_list_prepend (union_monitor->monitors,
- g_object_ref (volume_monitor));
-
- g_signal_connect (volume_monitor, "volume_mounted", (GCallback)child_volume_mounted, union_monitor);
- g_signal_connect (volume_monitor, "volume_pre_unmount", (GCallback)child_volume_pre_unmount, union_monitor);
- g_signal_connect (volume_monitor, "volume_unmounted", (GCallback)child_volume_unmounted, union_monitor);
- g_signal_connect (volume_monitor, "drive_connected", (GCallback)child_drive_connected, union_monitor);
- g_signal_connect (volume_monitor, "drive_disconnected", (GCallback)child_drive_disconnected, union_monitor);
-
- volumes = g_volume_monitor_get_mounted_volumes (volume_monitor);
- for (l = volumes; l != NULL; l = l->next)
- {
- volume = l->data;
- add_child_volume (union_monitor, volume, volume_monitor);
- g_object_unref (volume);
- }
- g_list_free (volumes);
-
- drives = g_volume_monitor_get_connected_drives (volume_monitor);
- for (l = drives; l != NULL; l = l->next)
- {
- drive = l->data;
- add_child_drive (union_monitor, drive, volume_monitor);
- g_object_unref (drive);
- }
- g_list_free (drives);
-}
-
-static void
-g_union_volume_monitor_remove_monitor (GUnionVolumeMonitor *union_monitor,
- GVolumeMonitor *child_monitor)
-{
- GList *l;
- GUnionVolume *union_volume;
- GUnionDrive *union_drive;
- GVolume *volume;
-
- if (!g_list_find (union_monitor->monitors, child_monitor))
- return;
-
- for (l = union_monitor->volumes; l != NULL; l = l->next)
- {
- union_volume = l->data;
-
- volume = g_union_volume_get_child_for_monitor (union_volume, child_monitor);
- if (volume)
- {
- remove_child_volume (union_monitor, volume);
- g_object_unref (volume);
- }
- }
-
- for (l = union_monitor->drives; l != NULL; l = l->next)
- {
- union_drive = l->data;
-
- if (g_union_drive_child_is_for_monitor (union_drive, child_monitor))
- remove_union_drive (union_monitor, union_drive);
- }
-
-}
-
-GList *
-g_union_volume_monitor_convert_volumes (GUnionVolumeMonitor *monitor,
- GList *child_volumes)
-{
- GList *union_volumes, *l;
-
- union_volumes = 0;
- for (l = child_volumes; l != NULL; l = l->next)
- {
- GVolume *child_volume = l->data;
- GUnionVolume *union_volume = lookup_union_volume (monitor, child_volume);
- if (union_volume)
- {
- union_volumes = g_list_prepend (union_volumes,
- g_object_ref (union_volume));
- break;
- }
- }
-
- return union_volumes;
-}
-
-GDrive *
-g_union_volume_monitor_convert_drive (GUnionVolumeMonitor *monitor,
- GDrive *child_drive)
-{
- GUnionDrive *union_drive;
-
- union_drive = lookup_union_drive (monitor, child_drive);
- if (union_drive)
- return g_object_ref (union_drive);
-
- return NULL;
-}
-
-static void
-g_union_volume_monitor_init (GUnionVolumeMonitor *union_monitor)
-{
- GVolumeMonitor *monitor;
- GType *monitors;
- guint n_monitors;
- int i;
-
-#ifdef G_OS_UNIX
- /* Ensure GUnixVolumeMonitor type is availible */
- {
- GType (*casted_get_type)(void);
- /* cast is required to avoid any G_GNUC_CONST optimizations */
- casted_get_type = g_unix_volume_monitor_get_type;
- casted_get_type ();
- }
-#endif
-
- /* Ensure vfs in modules loaded */
- g_io_modules_ensure_loaded (GIO_MODULE_DIR);
-
-
- monitors = g_type_children (G_TYPE_VOLUME_MONITOR, &n_monitors);
-
- for (i = 0; i < n_monitors; i++)
- {
- if (monitors[i] == G_TYPE_UNION_VOLUME_MONITOR)
- continue;
-
- monitor = g_object_new (monitors[i], NULL);
- g_union_volume_monitor_add_monitor (union_monitor, monitor);
- g_object_unref (monitor);
- }
-
- g_free (monitors);
-}
-
-static GUnionVolumeMonitor *
-g_union_volume_monitor_new (void)
-{
- GUnionVolumeMonitor *monitor;
-
- monitor = g_object_new (G_TYPE_UNION_VOLUME_MONITOR, NULL);
-
- return monitor;
-}
-
-GVolumeMonitor *
-g_get_volume_monitor (void)
-{
- GVolumeMonitor *vm;
-
- G_LOCK (the_volume_monitor);
-
- if (the_volume_monitor )
- vm = G_VOLUME_MONITOR (g_object_ref (the_volume_monitor));
- else
- {
- the_volume_monitor = g_union_volume_monitor_new ();
- vm = G_VOLUME_MONITOR (the_volume_monitor);
- }
-
- G_UNLOCK (the_volume_monitor);
-
- return vm;
-}
diff --git a/gio/gunionvolumemonitor.h b/gio/gunionvolumemonitor.h
deleted file mode 100644
index 0d55f2b0..00000000
--- a/gio/gunionvolumemonitor.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __G_UNION_VOLUME_MONITOR_H__
-#define __G_UNION_VOLUME_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/gvolumemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_UNION_VOLUME_MONITOR (g_union_volume_monitor_get_type ())
-#define G_UNION_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNION_VOLUME_MONITOR, GUnionVolumeMonitor))
-#define G_UNION_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNION_VOLUME_MONITOR, GUnionVolumeMonitorClass))
-#define G_IS_UNION_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNION_VOLUME_MONITOR))
-#define G_IS_UNION_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNION_VOLUME_MONITOR))
-
-typedef struct _GUnionVolumeMonitor GUnionVolumeMonitor;
-typedef struct _GUnionVolumeMonitorClass GUnionVolumeMonitorClass;
-
-struct _GUnionVolumeMonitorClass {
- GVolumeMonitorClass parent_class;
-
-};
-
-GType g_union_volume_monitor_get_type (void) G_GNUC_CONST;
-
-GList * g_union_volume_monitor_convert_volumes (GUnionVolumeMonitor *monitor,
- GList *child_volumes);
-GDrive *g_union_volume_monitor_convert_drive (GUnionVolumeMonitor *monitor,
- GDrive *child_drive);
-
-G_END_DECLS
-
-#endif /* __G_UNION_VOLUME_MONITOR_H__ */
diff --git a/gio/gunixdrive.c b/gio/gunixdrive.c
deleted file mode 100644
index c023c723..00000000
--- a/gio/gunixdrive.c
+++ /dev/null
@@ -1,264 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include "gunixdrive.h"
-#include "gunixvolume.h"
-#include "gdrivepriv.h"
-#include "gthemedicon.h"
-#include "gvolumemonitor.h"
-
-struct _GUnixDrive {
- GObject parent;
-
- GUnixVolume *volume; /* owned by volume monitor */
- char *name;
- char *icon;
- char *mountpoint;
- GUnixMountType guessed_type;
-};
-
-static void g_unix_volume_drive_iface_init (GDriveIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GUnixDrive, g_unix_drive, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_DRIVE,
- g_unix_volume_drive_iface_init))
-
-static void
-g_unix_drive_finalize (GObject *object)
-{
- GUnixDrive *drive;
-
- drive = G_UNIX_DRIVE (object);
-
- if (drive->volume)
- g_unix_volume_unset_drive (drive->volume, drive);
-
- g_free (drive->name);
- g_free (drive->icon);
- g_free (drive->mountpoint);
-
- if (G_OBJECT_CLASS (g_unix_drive_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_unix_drive_parent_class)->finalize) (object);
-}
-
-static void
-g_unix_drive_class_init (GUnixDriveClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_unix_drive_finalize;
-}
-
-static void
-g_unix_drive_init (GUnixDrive *unix_drive)
-{
-}
-
-static char *
-type_to_icon (GUnixMountType type)
-{
- const char *icon_name = NULL;
-
- switch (type)
- {
- case G_UNIX_MOUNT_TYPE_HD:
- icon_name = "drive-harddisk";
- break;
- case G_UNIX_MOUNT_TYPE_FLOPPY:
- case G_UNIX_MOUNT_TYPE_ZIP:
- case G_UNIX_MOUNT_TYPE_JAZ:
- case G_UNIX_MOUNT_TYPE_MEMSTICK:
- icon_name = "drive-removable-media";
- break;
- case G_UNIX_MOUNT_TYPE_CDROM:
- icon_name = "drive-optical";
- break;
- case G_UNIX_MOUNT_TYPE_NFS:
- /* TODO: Would like a better icon here... */
- icon_name = "drive-removable-media";
- break;
- case G_UNIX_MOUNT_TYPE_CAMERA:
- icon_name = "camera-photo";
- break;
- case G_UNIX_MOUNT_TYPE_IPOD:
- icon_name = "multimedia-player";
- break;
- case G_UNIX_MOUNT_TYPE_UNKNOWN:
- default:
- icon_name = "drive-removable-media";
- break;
- }
- return g_strdup (icon_name);
-}
-
-GUnixDrive *
-g_unix_drive_new (GVolumeMonitor *volume_monitor,
- GUnixMountPoint *mountpoint)
-{
- GUnixDrive *drive;
-
- if (!(mountpoint->is_user_mountable ||
- g_str_has_prefix (mountpoint->device_path, "/vol/")) ||
- mountpoint->is_loopback)
- return NULL;
-
- drive = g_object_new (G_TYPE_UNIX_DRIVE, NULL);
-
- drive->guessed_type = _g_guess_type_for_mount (mountpoint->mount_path,
- mountpoint->device_path,
- mountpoint->filesystem_type);
-
- /* TODO: */
- drive->mountpoint = g_strdup (mountpoint->mount_path);
- drive->icon = type_to_icon (drive->guessed_type);
- drive->name = g_strdup (_("Unknown drive"));
-
- return drive;
-}
-
-void
-g_unix_drive_disconnected (GUnixDrive *drive)
-{
- if (drive->volume)
- {
- g_unix_volume_unset_drive (drive->volume, drive);
- drive->volume = NULL;
- }
-}
-
-void
-g_unix_drive_set_volume (GUnixDrive *drive,
- GUnixVolume *volume)
-{
- if (drive->volume == volume)
- return;
-
- if (drive->volume)
- g_unix_volume_unset_drive (drive->volume, drive);
-
- drive->volume = volume;
-
- /* TODO: Emit changed in idle to avoid locking issues */
- g_signal_emit_by_name (drive, "changed");
-}
-
-void
-g_unix_drive_unset_volume (GUnixDrive *drive,
- GUnixVolume *volume)
-{
- if (drive->volume == volume)
- {
- drive->volume = NULL;
- /* TODO: Emit changed in idle to avoid locking issues */
- g_signal_emit_by_name (drive, "changed");
- }
-}
-
-static GIcon *
-g_unix_drive_get_icon (GDrive *drive)
-{
- GUnixDrive *unix_drive = G_UNIX_DRIVE (drive);
-
- return g_themed_icon_new (unix_drive->icon);
-}
-
-static char *
-g_unix_drive_get_name (GDrive *drive)
-{
- GUnixDrive *unix_drive = G_UNIX_DRIVE (drive);
-
- return g_strdup (unix_drive->name);
-}
-
-static gboolean
-g_unix_drive_is_automounted (GDrive *drive)
-{
- /* TODO */
- return FALSE;
-}
-
-static gboolean
-g_unix_drive_can_mount (GDrive *drive)
-{
- /* TODO */
- return TRUE;
-}
-
-static gboolean
-g_unix_drive_can_eject (GDrive *drive)
-{
- /* TODO */
- return FALSE;
-}
-
-static GList *
-g_unix_drive_get_volumes (GDrive *drive)
-{
- GList *l;
- GUnixDrive *unix_drive = G_UNIX_DRIVE (drive);
-
- l = NULL;
- if (unix_drive->volume)
- l = g_list_prepend (l, g_object_ref (unix_drive->volume));
-
- return l;
-}
-
-gboolean
-g_unix_drive_has_mountpoint (GUnixDrive *drive,
- const char *mountpoint)
-{
- return strcmp (drive->mountpoint, mountpoint) == 0;
-}
-
-static void
-g_unix_drive_mount (GDrive *drive,
- GMountOperation *mount_operation,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- /* TODO */
-}
-
-
-static gboolean
-g_unix_drive_mount_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error)
-{
- return TRUE;
-}
-
-static void
-g_unix_drive_eject (GDrive *drive,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- /* TODO */
-}
-
-static gboolean
-g_unix_drive_eject_finish (GDrive *drive,
- GAsyncResult *result,
- GError **error)
-{
- return TRUE;
-}
-
-static void
-g_unix_volume_drive_iface_init (GDriveIface *iface)
-{
- iface->get_name = g_unix_drive_get_name;
- iface->get_icon = g_unix_drive_get_icon;
- iface->get_volumes = g_unix_drive_get_volumes;
- iface->is_automounted = g_unix_drive_is_automounted;
- iface->can_mount = g_unix_drive_can_mount;
- iface->can_eject = g_unix_drive_can_eject;
- iface->mount = g_unix_drive_mount;
- iface->mount_finish = g_unix_drive_mount_finish;
- iface->eject = g_unix_drive_eject;
- iface->eject_finish = g_unix_drive_eject_finish;
-}
diff --git a/gio/gunixdrive.h b/gio/gunixdrive.h
deleted file mode 100644
index ae778724..00000000
--- a/gio/gunixdrive.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __G_UNIX_DRIVE_H__
-#define __G_UNIX_DRIVE_H__
-
-#include <glib-object.h>
-#include <gio/gdrive.h>
-#include <gio/gunixmounts.h>
-#include <gio/gunixvolumemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_UNIX_DRIVE (g_unix_drive_get_type ())
-#define G_UNIX_DRIVE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_DRIVE, GUnixDrive))
-#define G_UNIX_DRIVE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNIX_DRIVE, GUnixDriveClass))
-#define G_IS_UNIX_DRIVE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_DRIVE))
-#define G_IS_UNIX_DRIVE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNIX_DRIVE))
-
-typedef struct _GUnixDriveClass GUnixDriveClass;
-
-struct _GUnixDriveClass {
- GObjectClass parent_class;
-};
-
-GType g_unix_drive_get_type (void) G_GNUC_CONST;
-
-GUnixDrive *g_unix_drive_new (GVolumeMonitor *volume_monitor,
- GUnixMountPoint *mountpoint);
-gboolean g_unix_drive_has_mountpoint (GUnixDrive *drive,
- const char *mountpoint);
-void g_unix_drive_set_volume (GUnixDrive *drive,
- GUnixVolume *volume);
-void g_unix_drive_unset_volume (GUnixDrive *drive,
- GUnixVolume *volume);
-void g_unix_drive_disconnected (GUnixDrive *drive);
-
-G_END_DECLS
-
-#endif /* __G_UNIX_DRIVE_H__ */
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
deleted file mode 100644
index 76e31a24..00000000
--- a/gio/gunixmounts.c
+++ /dev/null
@@ -1,1035 +0,0 @@
-#include <config.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#ifndef HAVE_SYSCTLBYNAME
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
-#endif
-#endif
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-
-#include "gunixmounts.h"
-#include "gfile.h"
-#include "gfilemonitor.h"
-
-#define MOUNT_POLL_INTERVAL 4000
-
-#ifdef HAVE_SYS_MNTTAB_H
-#define MNTOPT_RO "ro"
-#endif
-
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#elif defined (HAVE_SYS_MNTTAB_H)
-#include <sys/mnttab.h>
-#endif
-
-#ifdef HAVE_SYS_VFSTAB_H
-#include <sys/vfstab.h>
-#endif
-
-#if defined(HAVE_SYS_MNTCTL_H) && defined(HAVE_SYS_VMOUNT_H) && defined(HAVE_SYS_VFS_H)
-#include <sys/mntctl.h>
-#include <sys/vfs.h>
-#include <sys/vmount.h>
-#include <fshelp.h>
-#endif
-
-#if defined(HAVE_GETMNTINFO) && defined(HAVE_FSTAB_H) && defined(HAVE_SYS_MOUNT_H)
-#include <sys/param.h>
-#include <sys/ucred.h>
-#include <sys/mount.h>
-#include <fstab.h>
-#ifdef HAVE_SYS_SYSCTL_H
-#include <sys/sysctl.h>
-#endif
-#endif
-
-#ifndef HAVE_SETMNTENT
-#define setmntent(f,m) fopen(f,m)
-#endif
-#ifndef HAVE_ENDMNTENT
-#define endmntent(f) fclose(f)
-#endif
-
-#ifdef HAVE_MNTENT_H
-
-static char *
-get_mtab_read_file (void)
-{
-#ifdef _PATH_MOUNTED
-# ifdef __linux__
- return "/proc/mounts";
-# else
- return _PATH_MOUNTED;
-# endif
-#else
- return "/etc/mtab";
-#endif
-}
-
-static char *
-get_mtab_monitor_file (void)
-{
-#ifdef _PATH_MOUNTED
- return _PATH_MOUNTED;
-#else
- return "/etc/mtab";
-#endif
-}
-
-GList *
-_g_get_unix_mounts ()
-{
- struct mntent *mntent;
- FILE *file;
- char *read_file;
- GUnixMount *mount_entry;
- GHashTable *mounts_hash;
- GList *return_list;
-
- read_file = get_mtab_read_file ();
-
- file = setmntent (read_file, "r");
- if (file == NULL)
- return NULL;
-
- return_list = NULL;
-
- mounts_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- while ((mntent = getmntent (file)) != NULL)
- {
- /* ignore any mnt_fsname that is repeated and begins with a '/'
- *
- * We do this to avoid being fooled by --bind mounts, since
- * these have the same device as the location they bind to.
- * Its not an ideal solution to the problem, but its likely that
- * the most important mountpoint is first and the --bind ones after
- * that aren't as important. So it should work.
- *
- * The '/' is to handle procfs, tmpfs and other no device mounts.
- */
- if (mntent->mnt_fsname != NULL &&
- mntent->mnt_fsname[0] == '/' &&
- g_hash_table_lookup (mounts_hash, mntent->mnt_fsname))
- continue;
-
- mount_entry = g_new0 (GUnixMount, 1);
- mount_entry->mount_path = g_strdup (mntent->mnt_dir);
- mount_entry->device_path = g_strdup (mntent->mnt_fsname);
- mount_entry->filesystem_type = g_strdup (mntent->mnt_type);
-
-#if defined (HAVE_HASMNTOPT)
- if (hasmntopt (mntent, MNTOPT_RO) != NULL)
- mount_entry->is_read_only = TRUE;
-#endif
-
- g_hash_table_insert (mounts_hash,
- mount_entry->device_path,
- mount_entry->device_path);
-
- return_list = g_list_prepend (return_list, mount_entry);
- }
- g_hash_table_destroy (mounts_hash);
-
- endmntent (file);
-
- return g_list_reverse (return_list);
-}
-
-#elif defined (HAVE_SYS_MNTTAB_H)
-
-static char *
-get_mtab_read_file (void)
-{
-#ifdef _PATH_MOUNTED
- return _PATH_MOUNTED;
-#else
- return "/etc/mnttab";
-#endif
-}
-
-static char *
-get_mtab_monitor_file (void)
-{
- return get_mtab_read_file ();
-}
-
-GList *
-_g_get_unix_mounts (void)
-{
- struct mnttab mntent;
- FILE *file;
- char *read_file;
- GUnixMount *mount_entry;
- GList *return_list;
-
- read_file = get_mtab_read_file ();
-
- file = setmntent (read_file, "r");
- if (file == NULL)
- return NULL;
-
- return_list = NULL;
-
- while (! getmntent (file, &mntent))
- {
- mount_entry = g_new0 (GUnixMount, 1);
-
- mount_entry->mount_path = g_strdup (mntent.mnt_mountp);
- mount_entry->device_path = g_strdup (mntent.mnt_special);
- mount_entry->filesystem_type = g_strdup (mntent.mnt_fstype);
-
-#if defined (HAVE_HASMNTOPT)
- if (hasmntopt (&mntent, MNTOPT_RO) != NULL)
- mount_entry->is_read_only = TRUE;
-#endif
-
- return_list = g_list_prepend (return_list, mount_entry);
- }
-
- endmntent (file);
-
- return g_list_reverse (return_list);
-}
-
-#elif defined(HAVE_SYS_MNTCTL_H) && defined(HAVE_SYS_VMOUNT_H) && defined(HAVE_SYS_VFS_H)
-
-static char *
-get_mtab_monitor_file (void)
-{
- return NULL;
-}
-
-GList *
-_g_get_unix_mounts (void)
-{
- struct vfs_ent *fs_info;
- struct vmount *vmount_info;
- int vmount_number;
- unsigned int vmount_size;
- int current;
- GList *return_list;
-
- if (mntctl (MCTL_QUERY, sizeof (vmount_size), &vmount_size) != 0)
- {
- g_warning ("Unable to know the number of mounted volumes\n");
-
- return NULL;
- }
-
- vmount_info = (struct vmount*)g_malloc (vmount_size);
-
- vmount_number = mntctl (MCTL_QUERY, vmount_size, vmount_info);
-
- if (vmount_info->vmt_revision != VMT_REVISION)
- g_warning ("Bad vmount structure revision number, want %d, got %d\n", VMT_REVISION, vmount_info->vmt_revision);
-
- if (vmount_number < 0)
- {
- g_warning ("Unable to recover mounted volumes information\n");
-
- g_free (vmount_info);
- return NULL;
- }
-
- return_list = NULL;
- while (vmount_number > 0)
- {
- mount_entry = g_new0 (GUnixMount, 1);
-
- mount_entry->device_path = g_strdup (vmt2dataptr (vmount_info, VMT_OBJECT));
- mount_entry->mount_path = g_strdup (vmt2dataptr (vmount_info, VMT_STUB));
- /* is_removable = (vmount_info->vmt_flags & MNT_REMOVABLE) ? 1 : 0; */
- mount_entry->is_read_only = (vmount_info->vmt_flags & MNT_READONLY) ? 1 : 0;
-
- fs_info = getvfsbytype (vmount_info->vmt_gfstype);
-
- if (fs_info == NULL)
- mount_entry->filesystem_type = g_strdup ("unknown");
- else
- mount_entry->filesystem_type = g_strdup (fs_info->vfsent_name);
-
- return_list = g_list_prepend (return_list, mount_entry);
-
- vmount_info = (struct vmount *)( (char*)vmount_info
- + vmount_info->vmt_length);
- vmount_number--;
- }
-
-
- g_free (vmount_info);
-
- return g_list_reverse (return_list);
-}
-
-#elif defined(HAVE_GETMNTINFO) && defined(HAVE_FSTAB_H) && defined(HAVE_SYS_MOUNT_H)
-
-static char *
-get_mtab_monitor_file (void)
-{
- return NULL;
-}
-
-GList *
-_g_get_unix_mounts (void)
-{
- struct statfs *mntent = NULL;
- int num_mounts, i;
- GUnixMount *mount_entry;
- GList *return_list;
-
- /* Pass MNT_NOWAIT to avoid blocking trying to update NFS mounts. */
- if ((num_mounts = getmntinfo (&mntent, MNT_NOWAIT)) == 0)
- return NULL;
-
- return_list = NULL;
-
- for (i = 0; i < num_mounts; i++)
- {
- mount_entry = g_new0 (GUnixMount, 1);
-
- mount_entry->mount_path = g_strdup (mntent[i].f_mntonname);
- mount_entry->device_path = g_strdup (mntent[i].f_mntfromname);
- mount_entry->filesystem_type = g_strdup (mntent[i].f_fstypename);
- if (mntent[i].f_flags & MNT_RDONLY)
- mount_entry->is_read_only = TRUE;
-
- return_list = g_list_prepend (return_list, mount_entry);
- }
-
- return g_list_reverse (return_list);
-}
-#else
-#error No _g_get_unix_mounts() implementation for system
-#endif
-
-
-/* _g_get_unix_mount_points():
- * read the fstab.
- * don't return swap and ignore mounts.
- */
-
-static char *
-get_fstab_file (void)
-{
-#if defined(HAVE_SYS_MNTCTL_H) && defined(HAVE_SYS_VMOUNT_H) && defined(HAVE_SYS_VFS_H)
- /* AIX */
- return "/etc/filesystems";
-#elif defined(_PATH_MNTTAB)
- return _PATH_MNTTAB;
-#elif defined(VFSTAB)
- return VFSTAB;
-#else
- return "/etc/fstab";
-#endif
-}
-
-#ifdef HAVE_MNTENT_H
-GList *
-_g_get_unix_mount_points (void)
-{
- struct mntent *mntent;
- FILE *file;
- char *read_file;
- char *opt, *opt_end;
- GUnixMountPoint *mount_entry;
- GList *return_list;
-
- read_file = get_fstab_file ();
-
- file = setmntent (read_file, "r");
- if (file == NULL)
- return NULL;
-
- return_list = NULL;
-
- while ((mntent = getmntent (file)) != NULL)
- {
- if ((strcmp (mntent->mnt_dir, "ignore") == 0) ||
- (strcmp (mntent->mnt_dir, "swap") == 0))
- continue;
-
- mount_entry = g_new0 (GUnixMountPoint, 1);
- mount_entry->mount_path = g_strdup (mntent->mnt_dir);
- mount_entry->device_path = g_strdup (mntent->mnt_fsname);
- mount_entry->filesystem_type = g_strdup (mntent->mnt_type);
-
-#ifdef HAVE_HASMNTOPT
- if (hasmntopt (mntent, MNTOPT_RO) != NULL)
- mount_entry->is_read_only = TRUE;
-
- if (hasmntopt (mntent, "loop") != NULL)
- mount_entry->is_loopback = TRUE;
-
- if ((opt = hasmntopt (mntent, "dev=")) != NULL)
- {
- opt = opt + strlen("dev=");
- opt_end = strchr (opt, ',');
- if (opt_end)
- mount_entry->dev_opt = g_strndup (opt, opt_end - opt);
- else
- mount_entry->dev_opt = g_strdup (opt);
- }
-#endif
-
- if ((mntent->mnt_type != NULL && strcmp ("supermount", mntent->mnt_type) == 0)
-#ifdef HAVE_HASMNTOPT
- || (hasmntopt (mntent, "user") != NULL
- && hasmntopt (mntent, "user") != hasmntopt (mntent, "user_xattr"))
- || hasmntopt (mntent, "pamconsole") != NULL
- || hasmntopt (mntent, "users") != NULL
- || hasmntopt (mntent, "owner") != NULL
-#endif
- )
- mount_entry->is_user_mountable = TRUE;
-
- return_list = g_list_prepend (return_list, mount_entry);
- }
-
- endmntent (file);
-
- return g_list_reverse (return_list);
-}
-
-#elif defined (HAVE_SYS_MNTTAB_H)
-
-GList *
-_g_get_unix_mount_points (void)
-{
- struct mnttab mntent;
- FILE *file;
- char *read_file;
- GUnixMountPoint *mount_entry;
- GList *return_list;
-
- read_file = get_fstab_file ();
-
- file = setmntent (read_file, "r");
- if (file == NULL)
- return NULL;
-
- return_list = NULL;
-
- while (! getmntent (file, &mntent))
- {
- if ((strcmp (mntent.mnt_mountp, "ignore") == 0) ||
- (strcmp (mntent.mnt_mountp, "swap") == 0))
- continue;
-
- mount_entry = g_new0 (GUnixMountPoint, 1);
-
- mount_entry->mount_path = g_strdup (mntent.mnt_mountp);
- mount_entry->device_path = g_strdup (mntent.mnt_special);
- mount_entry->filesystem_type = g_strdup (mntent.mnt_fstype);
-
-#ifdef HAVE_HASMNTOPT
- if (hasmntopt (&mntent, MNTOPT_RO) != NULL)
- mount_entry->is_read_only = TRUE;
-
- if (hasmntopt (&mntent, "lofs") != NULL)
- mount_entry->is_loopback = TRUE;
-#endif
-
- if ((mntent.mnt_fstype != NULL)
-#ifdef HAVE_HASMNTOPT
- || (hasmntopt (&mntent, "user") != NULL
- && hasmntopt (&mntent, "user") != hasmntopt (&mntent, "user_xattr"))
- || hasmntopt (&mntent, "pamconsole") != NULL
- || hasmntopt (&mntent, "users") != NULL
- || hasmntopt (&mntent, "owner") != NULL
-#endif
- )
- mount_entry->is_user_mountable = TRUE;
-
-
- return_list = g_list_prepend (return_list, mount_entry);
- }
-
- endmntent (file);
-
- return g_list_reverse (return_list);
-}
-#elif defined(HAVE_SYS_MNTCTL_H) && defined(HAVE_SYS_VMOUNT_H) && defined(HAVE_SYS_VFS_H)
-
-/* functions to parse /etc/filesystems on aix */
-
-/* read character, ignoring comments (begin with '*', end with '\n' */
-static int
-aix_fs_getc (FILE *fd)
-{
- int c;
-
- while ((c = getc (fd)) == '*')
- {
- while (((c = getc (fd)) != '\n') && (c != EOF))
- ;
- }
-}
-
-/* eat all continuous spaces in a file */
-static int
-aix_fs_ignorespace (FILE *fd)
-{
- int c;
-
- while ((c = aix_fs_getc (fd)) != EOF)
- {
- if (!g_ascii_isspace (c))
- {
- ungetc (c,fd);
- return c;
- }
- }
-
- return EOF;
-}
-
-/* read one word from file */
-static int
-aix_fs_getword (FILE *fd, char *word)
-{
- int c;
-
- aix_fs_ignorespace (fd);
-
- while (((c = aix_fs_getc (fd)) != EOF) && !g_ascii_isspace (c))
- {
- if (c == '"')
- {
- while (((c = aix_fs_getc (fd)) != EOF) && (c != '"'))
- *word++ = c;
- else
- *word++ = c;
- }
- }
- *word = 0;
-
- return c;
-}
-
-typedef struct {
- char mnt_mount[PATH_MAX];
- char mnt_special[PATH_MAX];
- char mnt_fstype[16];
- char mnt_options[128];
-} AixMountTableEntry;
-
-/* read mount points properties */
-static int
-aix_fs_get (FILE *fd, AixMountTableEntry *prop)
-{
- static char word[PATH_MAX] = { 0 };
- char value[PATH_MAX];
-
- /* read stanza */
- if (word[0] == 0)
- {
- if (aix_fs_getword (fd, word) == EOF)
- return EOF;
- }
-
- word[strlen(word) - 1] = 0;
- strcpy (prop->mnt_mount, word);
-
- /* read attributes and value */
-
- while (aix_fs_getword (fd, word) != EOF)
- {
- /* test if is attribute or new stanza */
- if (word[strlen(word) - 1] == ':')
- return 0;
-
- /* read "=" */
- aix_fs_getword (fd, value);
-
- /* read value */
- aix_fs_getword (fd, value);
-
- if (strcmp (word, "dev") == 0)
- strcpy (prop->mnt_special, value);
- else if (strcmp (word, "vfs") == 0)
- strcpy (prop->mnt_fstype, value);
- else if (strcmp (word, "options") == 0)
- strcpy(prop->mnt_options, value);
- }
-
- return 0;
-}
-
-GList *
-_g_get_unix_mount_points (void)
-{
- struct mntent *mntent;
- FILE *file;
- char *read_file;
- GUnixMountPoint *mount_entry;
- AixMountTableEntry mntent;
- GList *return_list;
-
- read_file = get_fstab_file ();
-
- file = setmntent (read_file, "r");
- if (file == NULL)
- return NULL;
-
- return_list = NULL;
-
- while (!aix_fs_get (file, &mntent))
- {
- if (strcmp ("cdrfs", mntent.mnt_fstype) == 0)
- {
- mount_entry = g_new0 (GUnixMountPoint, 1);
-
-
- mount_entry->mount_path = g_strdup (mntent.mnt_mount);
- mount_entry->device_path = g_strdup (mntent.mnt_special);
- mount_entry->filesystem_type = g_strdup (mntent.mnt_fstype);
- mount_entry->is_read_only = TRUE;
- mount_entry->is_user_mountable = TRUE;
-
- return_list = g_list_prepend (return_list, mount_entry);
- }
- }
-
- endmntent (file);
-
- return g_list_reverse (return_list);
-}
-
-#elif defined(HAVE_GETMNTINFO) && defined(HAVE_FSTAB_H) && defined(HAVE_SYS_MOUNT_H)
-
-GList *
-_g_get_unix_mount_points (void)
-{
- struct fstab *fstab = NULL;
- GUnixMountPoint *mount_entry;
- GList *return_list;
-#ifdef HAVE_SYS_SYSCTL_H
- int usermnt = 0;
- size_t len = sizeof(usermnt);
- struct stat sb;
-#endif
-
- stat_file = get_fstab_file ();
-
- if (!setfsent ())
- return NULL;
-
- return_list = NULL;
-
-#ifdef HAVE_SYS_SYSCTL_H
-#if defined(HAVE_SYSCTLBYNAME)
- sysctlbyname ("vfs.usermount", &usermnt, &len, NULL, 0);
-#elif defined(CTL_VFS) && defined(VFS_USERMOUNT)
- {
- int mib[2];
-
- mib[0] = CTL_VFS;
- mib[1] = VFS_USERMOUNT;
- sysctl (mib, 2, &usermnt, &len, NULL, 0);
- }
-#elif defined(CTL_KERN) && defined(KERN_USERMOUNT)
- {
- int mib[2];
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_USERMOUNT;
- sysctl (mib, 2, &usermnt, &len, NULL, 0);
- }
-#endif
-#endif
-
- while ((fstab = getfsent ()) != NULL)
- {
- if (strcmp (fstab->fs_vfstype, "swap") == 0)
- continue;
-
- mount_entry = g_new0 (GUnixMountPoint, 1);
-
- mount_entry->mount_path = g_strdup (fstab->fs_file);
- mount_entry->device_path = g_strdup (fstab->fs_spec);
- mount_entry->filesystem_type = g_strdup (fstab->fs_vfstype);
-
- if (strcmp (fstab->fs_type, "ro") == 0)
- mount_entry->is_read_only = TRUE;
-
-#ifdef HAVE_SYS_SYSCTL_H
- if (usermnt != 0)
- {
- uid_t uid = getuid ();
- if (stat (fstab->fs_file, &sb) == 0)
- {
- if (uid == 0 || sb.st_uid == uid)
- mount_entry->is_user_mountable = TRUE;
- }
- }
-#endif
-
- return_list = g_list_prepend (return_list, mount_entry);
- }
-
- endfsent ();
-
- return g_list_reverse (return_list);
-}
-#else
-#error No _g_get_mount_table() implementation for system
-#endif
-
-GUnixMount *
-_g_get_unix_mount_at (const char *mount_path)
-{
- GList *mounts, *l;
- GUnixMount *mount_entry, *found;
-
- mounts = _g_get_unix_mounts ();
-
- found = NULL;
- for (l = mounts; l != NULL; l = l->next)
- {
- mount_entry = l->data;
-
- if (strcmp (mount_path, mount_entry->mount_path) == 0)
- found = mount_entry;
- else
- _g_unix_mount_free (mount_entry);
-
- }
- g_list_free (mounts);
-
- return found;
-}
-
-typedef struct {
- GUnixMountCallback mountpoints_changed;
- GUnixMountCallback mounts_changed;
- gpointer user_data;
-} MountMonitor;
-
-static GFileMonitor *fstab_monitor;
-static GFileMonitor *mtab_monitor;
-static GList *mount_monitors = NULL;
-
-static void
-fstab_file_changed (GFileMonitor* monitor,
- GFile* file,
- GFile* other_file,
- GFileMonitorEvent event_type,
- gpointer user_data)
-{
- GList *l;
-
- if (event_type != G_FILE_MONITOR_EVENT_CHANGED &&
- event_type != G_FILE_MONITOR_EVENT_CREATED &&
- event_type != G_FILE_MONITOR_EVENT_DELETED)
- return;
-
- for (l = mount_monitors; l != NULL; l = l->next)
- {
- MountMonitor *mount_monitor = l->data;
-
- if (mount_monitor->mountpoints_changed)
- mount_monitor->mountpoints_changed (mount_monitor->user_data);
- }
-}
-
-static void
-mtab_file_changed (GFileMonitor* monitor,
- GFile* file,
- GFile* other_file,
- GFileMonitorEvent event_type,
- gpointer user_data)
-{
- GList *l;
-
- if (event_type != G_FILE_MONITOR_EVENT_CHANGED &&
- event_type != G_FILE_MONITOR_EVENT_CREATED &&
- event_type != G_FILE_MONITOR_EVENT_DELETED)
- return;
-
- for (l = mount_monitors; l != NULL; l = l->next)
- {
- MountMonitor *mount_monitor = l->data;
-
- if (mount_monitor->mounts_changed)
- mount_monitor->mounts_changed (mount_monitor->user_data);
- }
-}
-
-gpointer
-_g_monitor_unix_mounts (GUnixMountCallback mountpoints_changed,
- GUnixMountCallback mounts_changed,
- gpointer user_data)
-{
- GFile *file;
- MountMonitor *mount_monitor;
-
- mount_monitor = g_new0 (MountMonitor, 1);
- mount_monitor->mountpoints_changed = mountpoints_changed;
- mount_monitor->mounts_changed = mounts_changed;
- mount_monitor->user_data = user_data;
-
- if (mount_monitors == NULL)
- {
- if (get_fstab_file () != NULL)
- {
- file = g_file_new_for_path (get_fstab_file ());
- fstab_monitor = g_file_monitor_file (file, 0);
- g_object_unref (file);
-
- g_signal_connect (fstab_monitor, "changed", (GCallback)fstab_file_changed, NULL);
- }
-
- if (get_mtab_monitor_file () != NULL)
- {
- file = g_file_new_for_path (get_mtab_monitor_file ());
- mtab_monitor = g_file_monitor_file (file, 0);
- g_object_unref (file);
-
- g_signal_connect (mtab_monitor, "changed", (GCallback)mtab_file_changed, NULL);
- }
- }
-
- mount_monitors = g_list_prepend (mount_monitors, mount_monitor);
- return mount_monitor;
-}
-
-void
-_g_stop_monitoring_unix_mounts (gpointer tag)
-{
- MountMonitor *mount_monitor = tag;
-
- if (g_list_find (mount_monitors, mount_monitor) == NULL)
- {
- g_warning ("Could not stop mount monitor %p", tag);
- return;
- }
-
- mount_monitors = g_list_remove (mount_monitors, mount_monitor);
- g_free (mount_monitor);
-
- if (mount_monitors == NULL)
- {
- if (fstab_monitor != NULL)
- {
- g_file_monitor_cancel (fstab_monitor);
- g_object_unref (fstab_monitor);
- fstab_monitor = NULL;
- }
- if (mtab_monitor != NULL)
- {
- g_file_monitor_cancel (mtab_monitor);
- g_object_unref (mtab_monitor);
- mtab_monitor = NULL;
- }
- }
-}
-
-void
-_g_unix_mount_free (GUnixMount *mount_entry)
-{
- g_free (mount_entry->mount_path);
- g_free (mount_entry->device_path);
- g_free (mount_entry->filesystem_type);
- g_free (mount_entry);
-}
-
-void
-_g_unix_mount_point_free (GUnixMountPoint *mount_point)
-{
- g_free (mount_point->mount_path);
- g_free (mount_point->device_path);
- g_free (mount_point->filesystem_type);
- g_free (mount_point->dev_opt);
- g_free (mount_point);
-}
-
-static int
-strcmp_null (const char *str1,
- const char *str2)
-{
- if (str1 == str2)
- return 0;
- if (str1 == NULL && str2 != NULL)
- return -1;
- if (str1 != NULL && str2 == NULL)
- return 1;
- return strcmp (str1, str2);
-}
-
-gint
-_g_unix_mount_compare (GUnixMount *mount1,
- GUnixMount *mount2)
-{
- int res;
-
- res = strcmp_null (mount1->mount_path, mount2->mount_path);
- if (res != 0)
- return res;
-
- res = strcmp_null (mount1->device_path, mount2->device_path);
- if (res != 0)
- return res;
-
- res = strcmp_null (mount1->filesystem_type, mount2->filesystem_type);
- if (res != 0)
- return res;
-
- res = mount1->is_read_only - mount2->is_read_only;
- if (res != 0)
- return res;
-
- return 0;
-}
-
-gint
-_g_unix_mount_point_compare (GUnixMountPoint *mount1,
- GUnixMountPoint *mount2)
-{
- int res;
-
- res = strcmp_null (mount1->mount_path, mount2->mount_path);
- if (res != 0)
- return res;
-
- res = strcmp_null (mount1->device_path, mount2->device_path);
- if (res != 0)
- return res;
-
- res = strcmp_null (mount1->filesystem_type, mount2->filesystem_type);
- if (res != 0)
- return res;
-
- res = strcmp_null (mount1->dev_opt, mount2->dev_opt);
- if (res != 0)
- return res;
-
- res = mount1->is_read_only - mount2->is_read_only;
- if (res != 0)
- return res;
-
- res = mount1->is_user_mountable - mount2->is_user_mountable;
- if (res != 0)
- return res;
-
- res = mount1->is_loopback - mount2->is_loopback;
- if (res != 0)
- return res;
-
- return 0;
-}
-
-
-GUnixMountType
-_g_guess_type_for_mount (const char *mount_path,
- const char *device_path,
- const char *filesystem_type)
-{
- GUnixMountType type;
- char *basename;
-
- type = G_UNIX_MOUNT_TYPE_UNKNOWN;
-
- if ((strcmp (filesystem_type, "udf") == 0) ||
- (strcmp (filesystem_type, "iso9660") == 0) ||
- (strcmp (filesystem_type, "cd9660") == 0))
- type = G_UNIX_MOUNT_TYPE_CDROM;
- else if (strcmp (filesystem_type, "nfs") == 0)
- type = G_UNIX_MOUNT_TYPE_NFS;
- else if (g_str_has_prefix (device_path, "/vol/dev/diskette/") ||
- g_str_has_prefix (device_path, "/dev/fd") ||
- g_str_has_prefix (device_path, "/dev/floppy"))
- type = G_UNIX_MOUNT_TYPE_FLOPPY;
- else if (g_str_has_prefix (device_path, "/dev/cdrom") ||
- g_str_has_prefix (device_path, "/dev/acd") ||
- g_str_has_prefix (device_path, "/dev/cd"))
- type = G_UNIX_MOUNT_TYPE_CDROM;
- else if (g_str_has_prefix (device_path, "/vol/"))
- {
- const char *name = mount_path + strlen ("/");
-
- if (g_str_has_prefix (name, "cdrom"))
- type = G_UNIX_MOUNT_TYPE_CDROM;
- else if (g_str_has_prefix (name, "floppy") ||
- g_str_has_prefix (device_path, "/vol/dev/diskette/"))
- type = G_UNIX_MOUNT_TYPE_FLOPPY;
- else if (g_str_has_prefix (name, "rmdisk"))
- type = G_UNIX_MOUNT_TYPE_ZIP;
- else if (g_str_has_prefix (name, "jaz"))
- type = G_UNIX_MOUNT_TYPE_JAZ;
- else if (g_str_has_prefix (name, "memstick"))
- type = G_UNIX_MOUNT_TYPE_MEMSTICK;
- }
- else
- {
- basename = g_path_get_basename (mount_path);
-
- if (g_str_has_prefix (basename, "cdrom") ||
- g_str_has_prefix (basename, "cdwriter") ||
- g_str_has_prefix (basename, "burn") ||
- g_str_has_prefix (basename, "cdr") ||
- g_str_has_prefix (basename, "cdrw") ||
- g_str_has_prefix (basename, "dvdrom") ||
- g_str_has_prefix (basename, "dvdram") ||
- g_str_has_prefix (basename, "dvdr") ||
- g_str_has_prefix (basename, "dvdrw") ||
- g_str_has_prefix (basename, "cdrom_dvdrom") ||
- g_str_has_prefix (basename, "cdrom_dvdram") ||
- g_str_has_prefix (basename, "cdrom_dvdr") ||
- g_str_has_prefix (basename, "cdrom_dvdrw") ||
- g_str_has_prefix (basename, "cdr_dvdrom") ||
- g_str_has_prefix (basename, "cdr_dvdram") ||
- g_str_has_prefix (basename, "cdr_dvdr") ||
- g_str_has_prefix (basename, "cdr_dvdrw") ||
- g_str_has_prefix (basename, "cdrw_dvdrom") ||
- g_str_has_prefix (basename, "cdrw_dvdram") ||
- g_str_has_prefix (basename, "cdrw_dvdr") ||
- g_str_has_prefix (basename, "cdrw_dvdrw"))
- type = G_UNIX_MOUNT_TYPE_CDROM;
- else if (g_str_has_prefix (basename, "floppy"))
- type = G_UNIX_MOUNT_TYPE_FLOPPY;
- else if (g_str_has_prefix (basename, "zip"))
- type = G_UNIX_MOUNT_TYPE_ZIP;
- else if (g_str_has_prefix (basename, "jaz"))
- type = G_UNIX_MOUNT_TYPE_JAZ;
- else if (g_str_has_prefix (basename, "camera"))
- type = G_UNIX_MOUNT_TYPE_CAMERA;
- else if (g_str_has_prefix (basename, "memstick") ||
- g_str_has_prefix (basename, "memory_stick") ||
- g_str_has_prefix (basename, "ram"))
- type = G_UNIX_MOUNT_TYPE_MEMSTICK;
- else if (g_str_has_prefix (basename, "compact_flash"))
- type = G_UNIX_MOUNT_TYPE_CF;
- else if (g_str_has_prefix (basename, "smart_media"))
- type = G_UNIX_MOUNT_TYPE_SM;
- else if (g_str_has_prefix (basename, "sd_mmc"))
- type = G_UNIX_MOUNT_TYPE_SDMMC;
- else if (g_str_has_prefix (basename, "ipod"))
- type = G_UNIX_MOUNT_TYPE_IPOD;
-
- g_free (basename);
- }
-
- if (type == G_UNIX_MOUNT_TYPE_UNKNOWN)
- type = G_UNIX_MOUNT_TYPE_HD;
-
- return type;
-}
diff --git a/gio/gunixmounts.h b/gio/gunixmounts.h
deleted file mode 100644
index e12ae98b..00000000
--- a/gio/gunixmounts.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef __G_UNIX_MOUNTS_H__
-#define __G_UNIX_MOUNTS_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef struct {
- char *mount_path;
- char *device_path;
- char *filesystem_type;
- gboolean is_read_only;
-} GUnixMount;
-
-typedef struct {
- char *mount_path;
- char *device_path;
- char *filesystem_type;
- char *dev_opt;
- gboolean is_read_only;
- gboolean is_user_mountable;
- gboolean is_loopback;
-} GUnixMountPoint;
-
-
-typedef enum {
- G_UNIX_MOUNT_TYPE_UNKNOWN,
- G_UNIX_MOUNT_TYPE_FLOPPY,
- G_UNIX_MOUNT_TYPE_CDROM,
- G_UNIX_MOUNT_TYPE_NFS,
- G_UNIX_MOUNT_TYPE_ZIP,
- G_UNIX_MOUNT_TYPE_JAZ,
- G_UNIX_MOUNT_TYPE_MEMSTICK,
- G_UNIX_MOUNT_TYPE_CF,
- G_UNIX_MOUNT_TYPE_SM,
- G_UNIX_MOUNT_TYPE_SDMMC,
- G_UNIX_MOUNT_TYPE_IPOD,
- G_UNIX_MOUNT_TYPE_CAMERA,
- G_UNIX_MOUNT_TYPE_HD,
-} GUnixMountType;
-
-typedef void (* GUnixMountCallback) (gpointer user_data);
-
-void _g_unix_mount_free (GUnixMount *mount_entry);
-void _g_unix_mount_point_free (GUnixMountPoint *mount_point);
-gint _g_unix_mount_compare (GUnixMount *mount_entry1,
- GUnixMount *mount_entry2);
-gint _g_unix_mount_point_compare (GUnixMountPoint *mount_point1,
- GUnixMountPoint *mount_point2);
-GList * _g_get_unix_mount_points (void);
-GList * _g_get_unix_mounts (void);
-GUnixMount *_g_get_unix_mount_at (const char *mount_path);
-gpointer _g_monitor_unix_mounts (GUnixMountCallback mountpoints_changed,
- GUnixMountCallback mounts_changed,
- gpointer user_data);
-void _g_stop_monitoring_unix_mounts (gpointer tag);
-
-GUnixMountType _g_guess_type_for_mount (const char *mount_path,
- const char *device_path,
- const char *filesystem_type);
-
-
-G_END_DECLS
-
-#endif /* __G_UNIX_MOUNTS_H__ */
diff --git a/gio/gunixvolume.c b/gio/gunixvolume.c
deleted file mode 100644
index 328e083c..00000000
--- a/gio/gunixvolume.c
+++ /dev/null
@@ -1,374 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include "gunixvolumemonitor.h"
-#include "gunixvolume.h"
-#include "gunixdrive.h"
-#include "gvolumepriv.h"
-#include "gvolumemonitor.h"
-#include "gthemedicon.h"
-
-struct _GUnixVolume {
- GObject parent;
-
- GUnixDrive *drive; /* owned by volume monitor */
- char *name;
- char *icon;
- char *mountpoint;
-};
-
-static void g_unix_volume_volume_iface_init (GVolumeIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GUnixVolume, g_unix_volume, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_VOLUME,
- g_unix_volume_volume_iface_init))
-
-
-static void
-g_unix_volume_finalize (GObject *object)
-{
- GUnixVolume *volume;
-
- volume = G_UNIX_VOLUME (object);
-
- if (volume->drive)
- g_unix_drive_unset_volume (volume->drive, volume);
-
- g_assert (volume->drive == NULL);
- g_free (volume->name);
- g_free (volume->icon);
- g_free (volume->mountpoint);
-
- if (G_OBJECT_CLASS (g_unix_volume_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_unix_volume_parent_class)->finalize) (object);
-}
-
-static void
-g_unix_volume_class_init (GUnixVolumeClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_unix_volume_finalize;
-}
-
-static void
-g_unix_volume_init (GUnixVolume *unix_volume)
-{
-}
-
-static gboolean
-is_in (const char *value, const char *set[])
-{
- int i;
- for (i = 0; set[i] != NULL; i++)
- {
- if (strcmp (set[i], value) == 0)
- return TRUE;
- }
- return FALSE;
-}
-
-static char *
-get_filesystem_volume_name (const char *fs_type)
-{
- /* TODO: add translation table from gnome-vfs */
- return g_strdup_printf (_("%s volume"), fs_type);
-}
-
-static char *
-type_to_icon (GUnixMountType type)
-{
- const char *icon_name = NULL;
-
- switch (type)
- {
- case G_UNIX_MOUNT_TYPE_HD:
- icon_name = "drive-harddisk";
- break;
- case G_UNIX_MOUNT_TYPE_FLOPPY:
- case G_UNIX_MOUNT_TYPE_ZIP:
- case G_UNIX_MOUNT_TYPE_JAZ:
- icon_name = "media-floppy";
- break;
- case G_UNIX_MOUNT_TYPE_CDROM:
- icon_name = "media-optical";
- break;
- case G_UNIX_MOUNT_TYPE_NFS:
- /* TODO: Would like a better icon here... */
- icon_name = "drive-harddisk";
- break;
- case G_UNIX_MOUNT_TYPE_MEMSTICK:
- icon_name = "media-flash";
- break;
- case G_UNIX_MOUNT_TYPE_CAMERA:
- icon_name = "camera-photo";
- break;
- case G_UNIX_MOUNT_TYPE_IPOD:
- icon_name = "multimedia-player";
- break;
- case G_UNIX_MOUNT_TYPE_UNKNOWN:
- default:
- icon_name = "drive-harddisk";
- break;
- }
- return g_strdup (icon_name);
-}
-
-GUnixVolume *
-g_unix_volume_new (GVolumeMonitor *volume_monitor,
- GUnixMount *mount)
-{
- GUnixVolume *volume;
- GUnixDrive *drive;
- GUnixMountType type;
- char *volume_name;
- const char *ignore_fs[] = {
- "auto",
- "autofs",
- "devfs",
- "devpts",
- "kernfs",
- "linprocfs",
- "proc",
- "procfs",
- "ptyfs",
- "rootfs",
- "selinuxfs",
- "sysfs",
- "tmpfs",
- "usbfs",
- "nfsd",
- NULL
- };
- const char *ignore_devices[] = {
- "none",
- "sunrpc",
- "devpts",
- "nfsd",
- "/dev/loop",
- "/dev/vn",
- NULL
- };
- const char *ignore_mountpoints[] = {
- /* Includes all FHS 2.3 toplevel dirs */
- "/",
- "/bin",
- "/boot",
- "/dev",
- "/etc",
- "/home",
- "/lib",
- "/lib64",
- "/media",
- "/mnt",
- "/opt",
- "/root",
- "/sbin",
- "/srv",
- "/tmp",
- "/usr",
- "/var",
- "/proc",
- "/sbin",
- NULL
- };
-
- drive = g_unix_volume_monitor_lookup_drive_for_mountpoint (G_UNIX_VOLUME_MONITOR (volume_monitor),
- mount->mount_path);
-
- if (drive == NULL)
- {
- /* No drive for volume. Ignore most internal things */
-
- if (is_in (mount->filesystem_type, ignore_fs))
- return NULL;
-
- if (is_in (mount->device_path, ignore_devices))
- return NULL;
-
- if (is_in (mount->mount_path, ignore_mountpoints))
- return NULL;
-
- if (g_str_has_prefix (mount->mount_path, "/dev") ||
- g_str_has_prefix (mount->mount_path, "/proc") ||
- g_str_has_prefix (mount->mount_path, "/sys"))
- return NULL;
- }
-
- volume = g_object_new (G_TYPE_UNIX_VOLUME, NULL);
- volume->drive = drive;
- if (drive)
- g_unix_drive_set_volume (drive, volume);
- volume->mountpoint = g_strdup (mount->mount_path);
-
- type = _g_guess_type_for_mount (mount->mount_path,
- mount->device_path,
- mount->filesystem_type);
-
- volume->icon = type_to_icon (type);
-
-
- volume_name = NULL;
- if (type == G_UNIX_MOUNT_TYPE_CDROM)
- {
- /* Get CD type (audio/data) and volume name */
-
- }
-
- if (volume_name == NULL)
- {
- const char *name = strrchr (mount->mount_path, '/');
- if (name == NULL)
- if (mount->filesystem_type != NULL)
- volume_name = g_strdup (get_filesystem_volume_name (mount->filesystem_type));
- }
-
- if (volume_name == NULL)
- {
- /* TODO: Use volume size as name? */
- volume_name = g_strdup (_("Unknown volume"));
- }
-
- volume->name = volume_name;
-
- return volume;
-}
-
-
-void
-g_unix_volume_unmounted (GUnixVolume *volume)
-{
- if (volume->drive)
- {
- g_unix_drive_unset_volume (volume->drive, volume);
- volume->drive = NULL;
- g_signal_emit_by_name (volume, "changed");
- }
-}
-
-void
-g_unix_volume_unset_drive (GUnixVolume *volume,
- GUnixDrive *drive)
-{
- if (volume->drive == drive)
- {
- volume->drive = NULL;
- /* TODO: Emit changed in idle to avoid locking issues */
- g_signal_emit_by_name (volume, "changed");
- }
-}
-
-static char *
-g_unix_volume_get_platform_id (GVolume *volume)
-{
- GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
-
- return g_strdup (unix_volume->mountpoint);
-}
-
-static GFile *
-g_unix_volume_get_root (GVolume *volume)
-{
- GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
-
- return g_file_new_for_path (unix_volume->mountpoint);
-}
-
-static GIcon *
-g_unix_volume_get_icon (GVolume *volume)
-{
- GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
-
- return g_themed_icon_new (unix_volume->icon);
-}
-
-static char *
-g_unix_volume_get_name (GVolume *volume)
-{
- GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
-
- return g_strdup (unix_volume->name);
-}
-
-gboolean
-g_unix_volume_has_mountpoint (GUnixVolume *volume,
- const char *mountpoint)
-{
- return strcmp (volume->mountpoint, mountpoint) == 0;
-}
-
-static GDrive *
-g_unix_volume_get_drive (GVolume *volume)
-{
- GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
-
- if (unix_volume->drive)
- return G_DRIVE (g_object_ref (unix_volume->drive));
-
- return NULL;
-}
-
-static gboolean
-g_unix_volume_can_unmount (GVolume *volume)
-{
- /* TODO */
- return FALSE;
-}
-
-static gboolean
-g_unix_volume_can_eject (GVolume *volume)
-{
- /* TODO */
- return FALSE;
-}
-
-static void
-g_unix_volume_unmount (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- /* TODO */
-}
-
-static gboolean
-g_unix_volume_unmount_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error)
-{
- return TRUE;
-}
-
-static void
-g_unix_volume_eject (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- /* TODO */
-}
-
-static gboolean
-g_unix_volume_eject_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error)
-{
- return TRUE;
-}
-
-static void
-g_unix_volume_volume_iface_init (GVolumeIface *iface)
-{
- iface->get_root = g_unix_volume_get_root;
- iface->get_name = g_unix_volume_get_name;
- iface->get_icon = g_unix_volume_get_icon;
- iface->get_drive = g_unix_volume_get_drive;
- iface->can_unmount = g_unix_volume_can_unmount;
- iface->can_eject = g_unix_volume_can_eject;
- iface->unmount = g_unix_volume_unmount;
- iface->unmount_finish = g_unix_volume_unmount_finish;
- iface->eject = g_unix_volume_eject;
- iface->eject_finish = g_unix_volume_eject_finish;
- iface->get_platform_id = g_unix_volume_get_platform_id;
-}
diff --git a/gio/gunixvolume.h b/gio/gunixvolume.h
deleted file mode 100644
index 890ba99d..00000000
--- a/gio/gunixvolume.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __G_UNIX_VOLUME_H__
-#define __G_UNIX_VOLUME_H__
-
-#include <glib-object.h>
-#include <gio/gvolume.h>
-#include <gio/gunixmounts.h>
-#include <gio/gunixvolumemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_UNIX_VOLUME (g_unix_volume_get_type ())
-#define G_UNIX_VOLUME(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_VOLUME, GUnixVolume))
-#define G_UNIX_VOLUME_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNIX_VOLUME, GUnixVolumeClass))
-#define G_IS_UNIX_VOLUME(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_VOLUME))
-#define G_IS_UNIX_VOLUME_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNIX_VOLUME))
-
-typedef struct _GUnixVolumeClass GUnixVolumeClass;
-
-struct _GUnixVolumeClass {
- GObjectClass parent_class;
-};
-
-GType g_unix_volume_get_type (void) G_GNUC_CONST;
-
-GUnixVolume *g_unix_volume_new (GVolumeMonitor *volume_monitor,
- GUnixMount *mount);
-gboolean g_unix_volume_has_mountpoint (GUnixVolume *volume,
- const char *mountpoint);
-void g_unix_volume_unset_drive (GUnixVolume *volume,
- GUnixDrive *drive);
-void g_unix_volume_unmounted (GUnixVolume *volume);
-
-G_END_DECLS
-
-#endif /* __G_UNIX_VOLUME_H__ */
diff --git a/gio/gunixvolumemonitor.c b/gio/gunixvolumemonitor.c
deleted file mode 100644
index c2cb90ce..00000000
--- a/gio/gunixvolumemonitor.c
+++ /dev/null
@@ -1,307 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include "gunixvolumemonitor.h"
-#include "gunixmounts.h"
-#include "gunixvolume.h"
-#include "gunixdrive.h"
-#include "gvolumepriv.h"
-
-struct _GUnixVolumeMonitor {
- GVolumeMonitor parent;
-
- gpointer mount_monitor;
-
- GList *last_mountpoints;
- GList *last_mounts;
-
- GList *drives;
- GList *volumes;
-};
-
-static void update_drives (GUnixVolumeMonitor *monitor);
-static void update_volumes (GUnixVolumeMonitor *monitor);
-
-G_DEFINE_TYPE (GUnixVolumeMonitor, g_unix_volume_monitor, G_TYPE_VOLUME_MONITOR);
-
-static void
-g_unix_volume_monitor_finalize (GObject *object)
-{
- GUnixVolumeMonitor *monitor;
-
- monitor = G_UNIX_VOLUME_MONITOR (object);
-
- if (monitor->mount_monitor)
- _g_stop_monitoring_unix_mounts (monitor->mount_monitor);
-
- g_list_foreach (monitor->last_mounts, (GFunc)_g_unix_mount_free, NULL);
- g_list_free (monitor->last_mounts);
-
- g_list_foreach (monitor->volumes, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->volumes);
- g_list_foreach (monitor->drives, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->drives);
-
- if (G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize) (object);
-}
-
-static GList *
-get_mounted_volumes (GVolumeMonitor *volume_monitor)
-{
- GUnixVolumeMonitor *monitor;
- GList *l;
-
- monitor = G_UNIX_VOLUME_MONITOR (volume_monitor);
-
- l = g_list_copy (monitor->volumes);
- g_list_foreach (l, (GFunc)g_object_ref, NULL);
-
- return l;
-}
-
-static GList *
-get_connected_drives (GVolumeMonitor *volume_monitor)
-{
- GUnixVolumeMonitor *monitor;
- GList *l;
-
- monitor = G_UNIX_VOLUME_MONITOR (volume_monitor);
-
- l = g_list_copy (monitor->drives);
- g_list_foreach (l, (GFunc)g_object_ref, NULL);
-
- return l;
-}
-
-static void
-g_unix_volume_monitor_class_init (GUnixVolumeMonitorClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GVolumeMonitorClass *monitor_class = G_VOLUME_MONITOR_CLASS (klass);
-
- gobject_class->finalize = g_unix_volume_monitor_finalize;
-
- monitor_class->get_mounted_volumes = get_mounted_volumes;
- monitor_class->get_connected_drives = get_connected_drives;
-}
-
-static void
-mountpoints_changed (gpointer user_data)
-{
- GUnixVolumeMonitor *unix_monitor = user_data;
-
- /* Update both to make sure drives are created before volumes */
- update_drives (unix_monitor);
- update_volumes (unix_monitor);
-}
-
-static void
-mounts_changed (gpointer user_data)
-{
- GUnixVolumeMonitor *unix_monitor = user_data;
-
- /* Update both to make sure drives are created before volumes */
- update_drives (unix_monitor);
- update_volumes (unix_monitor);
-}
-
-static void
-g_unix_volume_monitor_init (GUnixVolumeMonitor *unix_monitor)
-{
-
- unix_monitor->mount_monitor = _g_monitor_unix_mounts (mountpoints_changed,
- mounts_changed,
- unix_monitor);
- update_drives (unix_monitor);
- update_volumes (unix_monitor);
-
-}
-
-GVolumeMonitor *
-g_unix_volume_monitor_new (void)
-{
- GUnixVolumeMonitor *monitor;
-
- monitor = g_object_new (G_TYPE_UNIX_VOLUME_MONITOR, NULL);
-
- return G_VOLUME_MONITOR (monitor);
-}
-
-static void
-diff_sorted_lists (GList *list1, GList *list2, GCompareFunc compare,
- GList **added, GList **removed)
-{
- int order;
-
- *added = *removed = NULL;
-
- while (list1 != NULL &&
- list2 != NULL)
- {
- order = (*compare) (list1->data, list2->data);
- if (order < 0)
- {
- *removed = g_list_prepend (*removed, list1->data);
- list1 = list1->next;
- }
- else if (order > 0)
- {
- *added = g_list_prepend (*added, list2->data);
- list2 = list2->next;
- }
- else
- { /* same item */
- list1 = list1->next;
- list2 = list2->next;
- }
- }
-
- while (list1 != NULL)
- {
- *removed = g_list_prepend (*removed, list1->data);
- list1 = list1->next;
- }
- while (list2 != NULL)
- {
- *added = g_list_prepend (*added, list2->data);
- list2 = list2->next;
- }
-}
-
-GUnixDrive *
-g_unix_volume_monitor_lookup_drive_for_mountpoint (GUnixVolumeMonitor *monitor,
- const char *mountpoint)
-{
- GList *l;
-
- for (l = monitor->drives; l != NULL; l = l->next)
- {
- GUnixDrive *drive = l->data;
-
- if (g_unix_drive_has_mountpoint (drive, mountpoint))
- return drive;
- }
-
- return NULL;
-}
-
-static GUnixVolume *
-find_volume_by_mountpoint (GUnixVolumeMonitor *monitor,
- const char *mountpoint)
-{
- GList *l;
-
- for (l = monitor->volumes; l != NULL; l = l->next)
- {
- GUnixVolume *volume = l->data;
-
- if (g_unix_volume_has_mountpoint (volume, mountpoint))
- return volume;
- }
-
- return NULL;
-}
-
-static void
-update_drives (GUnixVolumeMonitor *monitor)
-{
- GList *new_mountpoints;
- GList *removed, *added;
- GList *l;
- GUnixDrive *drive;
-
- new_mountpoints = _g_get_unix_mount_points ();
-
- new_mountpoints = g_list_sort (new_mountpoints, (GCompareFunc) _g_unix_mount_point_compare);
-
- diff_sorted_lists (monitor->last_mountpoints,
- new_mountpoints, (GCompareFunc) _g_unix_mount_point_compare,
- &added, &removed);
-
- for (l = removed; l != NULL; l = l->next)
- {
- GUnixMountPoint *mountpoint = l->data;
-
- drive = g_unix_volume_monitor_lookup_drive_for_mountpoint (monitor, mountpoint->mount_path);
- if (drive)
- {
- g_unix_drive_disconnected (drive);
- monitor->drives = g_list_remove (monitor->drives, drive);
- g_signal_emit_by_name (monitor, "drive_disconnected", drive);
- g_object_unref (drive);
- }
- }
-
- for (l = added; l != NULL; l = l->next)
- {
- GUnixMountPoint *mountpoint = l->data;
-
- drive = g_unix_drive_new (G_VOLUME_MONITOR (monitor), mountpoint);
- if (drive)
- {
- monitor->drives = g_list_prepend (monitor->drives, drive);
- g_signal_emit_by_name (monitor, "drive_connected", drive);
- }
- }
-
- g_list_free (added);
- g_list_free (removed);
- g_list_foreach (monitor->last_mountpoints,
- (GFunc)_g_unix_mount_point_free, NULL);
- g_list_free (monitor->last_mountpoints);
- monitor->last_mountpoints = new_mountpoints;
-}
-
-static void
-update_volumes (GUnixVolumeMonitor *monitor)
-{
- GList *new_mounts;
- GList *removed, *added;
- GList *l;
- GUnixVolume *volume;
-
- new_mounts = _g_get_unix_mounts ();
-
- new_mounts = g_list_sort (new_mounts, (GCompareFunc) _g_unix_mount_compare);
-
- diff_sorted_lists (monitor->last_mounts,
- new_mounts, (GCompareFunc) _g_unix_mount_compare,
- &added, &removed);
-
- for (l = removed; l != NULL; l = l->next)
- {
- GUnixMount *mount = l->data;
-
- volume = find_volume_by_mountpoint (monitor, mount->mount_path);
- if (volume)
- {
- g_unix_volume_unmounted (volume);
- monitor->volumes = g_list_remove (monitor->volumes, volume);
- g_signal_emit_by_name (monitor, "volume_unmounted", volume);
- g_object_unref (volume);
- }
- }
-
- for (l = added; l != NULL; l = l->next)
- {
- GUnixMount *mount = l->data;
-
- volume = g_unix_volume_new (G_VOLUME_MONITOR (monitor), mount);
- if (volume)
- {
- monitor->volumes = g_list_prepend (monitor->volumes, volume);
- g_signal_emit_by_name (monitor, "volume_mounted", volume);
- }
- }
-
- g_list_free (added);
- g_list_free (removed);
- g_list_foreach (monitor->last_mounts,
- (GFunc)_g_unix_mount_free, NULL);
- g_list_free (monitor->last_mounts);
- monitor->last_mounts = new_mounts;
-}
diff --git a/gio/gunixvolumemonitor.h b/gio/gunixvolumemonitor.h
deleted file mode 100644
index f05f55c1..00000000
--- a/gio/gunixvolumemonitor.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __G_UNIX_VOLUME_MONITOR_H__
-#define __G_UNIX_VOLUME_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/gvolumemonitor.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_UNIX_VOLUME_MONITOR (g_unix_volume_monitor_get_type ())
-#define G_UNIX_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_UNIX_VOLUME_MONITOR, GUnixVolumeMonitor))
-#define G_UNIX_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_UNIX_VOLUME_MONITOR, GUnixVolumeMonitorClass))
-#define G_IS_UNIX_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_UNIX_VOLUME_MONITOR))
-#define G_IS_UNIX_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_UNIX_VOLUME_MONITOR))
-
-typedef struct _GUnixVolumeMonitor GUnixVolumeMonitor;
-typedef struct _GUnixVolumeMonitorClass GUnixVolumeMonitorClass;
-
-/* Forward definitions */
-typedef struct _GUnixVolume GUnixVolume;
-typedef struct _GUnixDrive GUnixDrive;
-
-struct _GUnixVolumeMonitorClass {
- GVolumeMonitorClass parent_class;
-
-};
-
-GType g_unix_volume_monitor_get_type (void) G_GNUC_CONST;
-
-GVolumeMonitor *g_unix_volume_monitor_new (void);
-GUnixDrive * g_unix_volume_monitor_lookup_drive_for_mountpoint (GUnixVolumeMonitor *monitor,
- const char *mountpoint);
-
-G_END_DECLS
-
-#endif /* __G_UNIX_VOLUME_MONITOR_H__ */
diff --git a/gio/gvfs-marshal.list b/gio/gvfs-marshal.list
deleted file mode 100644
index 57166631..00000000
--- a/gio/gvfs-marshal.list
+++ /dev/null
@@ -1,4 +0,0 @@
-BOOLEAN:STRING,STRING,STRING,INT
-BOOLEAN:STRING,POINTER
-VOID:BOOLEAN,POINTER
-VOID:OBJECT,OBJECT,INT
diff --git a/gio/gvfs.c b/gio/gvfs.c
deleted file mode 100644
index 7cb4ac01..00000000
--- a/gio/gvfs.c
+++ /dev/null
@@ -1,137 +0,0 @@
-#include <config.h>
-#include <string.h>
-#include <gmodule.h>
-#include "gvfs.h"
-#include "glocalvfs.h"
-#include "giomodule.h"
-#include <glib/gi18n-lib.h>
-
-G_DEFINE_TYPE (GVfs, g_vfs, G_TYPE_OBJECT);
-
-static void
-g_vfs_class_init (GVfsClass *klass)
-{
-}
-
-static void
-g_vfs_init (GVfs *vfs)
-{
-}
-
-const char *
-g_vfs_get_name (GVfs *vfs)
-{
- GVfsClass *class;
-
- class = G_VFS_GET_CLASS (vfs);
-
- return (* class->get_name) (vfs);
-}
-
-int
-g_vfs_get_priority (GVfs *vfs)
-{
- GVfsClass *class;
-
- class = G_VFS_GET_CLASS (vfs);
-
- return (* class->get_priority) (vfs);
-}
-
-GFile *
-g_vfs_get_file_for_path (GVfs *vfs,
- const char *path)
-{
- GVfsClass *class;
-
- class = G_VFS_GET_CLASS (vfs);
-
- return (* class->get_file_for_path) (vfs, path);
-}
-
-GFile *
-g_vfs_get_file_for_uri (GVfs *vfs,
- const char *uri)
-{
- GVfsClass *class;
-
- class = G_VFS_GET_CLASS (vfs);
-
- return (* class->get_file_for_uri) (vfs, uri);
-}
-
-GFile *
-g_vfs_parse_name (GVfs *vfs,
- const char *parse_name)
-{
- GVfsClass *class;
-
- class = G_VFS_GET_CLASS (vfs);
-
- return (* class->parse_name) (vfs, parse_name);
-}
-
-static gpointer
-get_default_vfs (gpointer arg)
-{
- GType local_type;
- GType *vfs_impls;
- int i;
- guint n_vfs_impls;
- const char *use_this;
- GVfs *vfs, *max_prio_vfs;
- int max_prio;
- GType (*casted_get_type)(void);
-
- use_this = g_getenv ("GIO_USE_VFS");
-
- /* Ensure GLocalVfs type is availible
- the cast is required to avoid any G_GNUC_CONST optimizations */
- casted_get_type = g_local_vfs_get_type;
- local_type = casted_get_type ();
-
- /* Ensure vfs in modules loaded */
- g_io_modules_ensure_loaded (GIO_MODULE_DIR);
-
- vfs_impls = g_type_children (G_TYPE_VFS, &n_vfs_impls);
-
- max_prio = G_MININT;
- max_prio_vfs = NULL;
- for (i = 0; i < n_vfs_impls; i++)
- {
- vfs = g_object_new (vfs_impls[i], NULL);
-
- if (use_this && strcmp (g_vfs_get_name (vfs), use_this) == 0)
- {
- max_prio = G_MAXINT;
- if (max_prio_vfs)
- g_object_unref (max_prio_vfs);
- max_prio_vfs = g_object_ref (vfs);
- }
-
- if (max_prio < g_vfs_get_priority (vfs))
- {
- max_prio = g_vfs_get_priority (vfs);
- if (max_prio_vfs)
- g_object_unref (max_prio_vfs);
- max_prio_vfs = g_object_ref (vfs);
- }
-
- g_object_unref (vfs);
- }
-
- g_free (vfs_impls);
-
- /* We should at least have gotten the local implementation */
- g_assert (max_prio_vfs != NULL);
-
- return max_prio_vfs;
-}
-
-GVfs *
-g_vfs_get_default (void)
-{
- static GOnce once_init = G_ONCE_INIT;
-
- return g_once (&once_init, get_default_vfs, NULL);
-}
diff --git a/gio/gvfs.h b/gio/gvfs.h
deleted file mode 100644
index 58277ccf..00000000
--- a/gio/gvfs.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef __G_VFS_IMPLEMENTATION_H__
-#define __G_VFS_IMPLEMENTATION_H__
-
-#include <glib-object.h>
-#include <gio/giotypes.h>
-#include <gio/gfile.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_VFS (g_vfs_get_type ())
-#define G_VFS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_VFS, GVfs))
-#define G_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_VFS, GVfsClass))
-#define G_VFS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_VFS, GVfsClass))
-#define G_IS_VFS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_VFS))
-#define G_IS_VFS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_VFS))
-
-typedef struct _GVfs GVfs; /* Dummy typedef */
-typedef struct _GVfsClass GVfsClass;
-
-struct _GVfs {
- GObject parent;
-};
-
-struct _GVfsClass
-{
- GObjectClass parent_class;
-
- /* Virtual Table */
-
- const char *(*get_name) (GVfs *vfs);
- int (*get_priority) (GVfs *vfs);
- GFile *(*get_file_for_path) (GVfs *vfs,
- const char *path);
- GFile *(*get_file_for_uri) (GVfs *vfs,
- const char *uri);
- GFile *(*parse_name) (GVfs *vfs,
- const char *parse_name);
-};
-
-GType g_vfs_get_type (void) G_GNUC_CONST;
-
-const char *g_vfs_get_name (GVfs *vfs);
-int g_vfs_get_priority (GVfs *vfs);
-GFile * g_vfs_get_file_for_path (GVfs *vfs,
- const char *path);
-GFile * g_vfs_get_file_for_uri (GVfs *vfs,
- const char *uri);
-GFile * g_vfs_parse_name (GVfs *vfs,
- const char *parse_name);
-
-GVfs * g_vfs_get_default (void);
-
-G_END_DECLS
-
-#endif /* __G_VFS_H__ */
diff --git a/gio/gvolume.c b/gio/gvolume.c
deleted file mode 100644
index 2bdfef2f..00000000
--- a/gio/gvolume.c
+++ /dev/null
@@ -1,214 +0,0 @@
-#include <config.h>
-#include "gvolume.h"
-#include "gvolumepriv.h"
-#include "gsimpleasyncresult.h"
-#include <glib/gi18n-lib.h>
-
-static void g_volume_base_init (gpointer g_class);
-static void g_volume_class_init (gpointer g_class,
- gpointer class_data);
-
-GType
-g_volume_get_type (void)
-{
- static GType volume_type = 0;
-
- if (! volume_type)
- {
- static const GTypeInfo volume_info =
- {
- sizeof (GVolumeIface), /* class_size */
- g_volume_base_init, /* base_init */
- NULL, /* base_finalize */
- g_volume_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- volume_type =
- g_type_register_static (G_TYPE_INTERFACE, I_("GVolume"),
- &volume_info, 0);
-
- g_type_interface_add_prerequisite (volume_type, G_TYPE_OBJECT);
- }
-
- return volume_type;
-}
-
-static void
-g_volume_class_init (gpointer g_class,
- gpointer class_data)
-{
-}
-
-static void
-g_volume_base_init (gpointer g_class)
-{
- static gboolean initialized = FALSE;
-
- if (! initialized)
- {
- g_signal_new (I_("changed"),
- G_TYPE_VOLUME,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GVolumeIface, changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- initialized = TRUE;
- }
-}
-
-GFile *
-g_volume_get_root (GVolume *volume)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- return (* iface->get_root) (volume);
-}
-
-char *
-g_volume_get_name (GVolume *volume)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- return (* iface->get_name) (volume);
-}
-
-GIcon *
-g_volume_get_icon (GVolume *volume)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- return (* iface->get_icon) (volume);
-}
-
-GDrive *
-g_volume_get_drive (GVolume *volume)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- return (* iface->get_drive) (volume);
-}
-
-gboolean
-g_volume_can_unmount (GVolume *volume)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- return (* iface->can_unmount) (volume);
-}
-
-gboolean
-g_volume_can_eject (GVolume *volume)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- return (* iface->can_eject) (volume);
-}
-
-void
-g_volume_unmount (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- if (iface->unmount == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (volume),
- callback, user_data,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("volume doesn't implement unmount"));
-
- return;
- }
-
- return (* iface->unmount) (volume, callback, user_data);
-}
-
-gboolean
-g_volume_unmount_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error)
-{
- GVolumeIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
- iface = G_VOLUME_GET_IFACE (volume);
- return (* iface->unmount_finish) (volume, result, error);
-}
-
-void
-g_volume_eject (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- if (iface->eject == NULL)
- {
- g_simple_async_report_error_in_idle (G_OBJECT (volume),
- callback, user_data,
- G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("volume doesn't implement eject"));
-
- return;
- }
-
- return (* iface->eject) (volume, callback, user_data);
-}
-
-gboolean
-g_volume_eject_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error)
-{
- GVolumeIface *iface;
-
- if (G_IS_SIMPLE_ASYNC_RESULT (result))
- {
- GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
- if (g_simple_async_result_propagate_error (simple, error))
- return FALSE;
- }
-
- iface = G_VOLUME_GET_IFACE (volume);
- return (* iface->eject_finish) (volume, result, error);
-}
-
-char *
-g_volume_get_platform_id (GVolume *volume)
-{
- GVolumeIface *iface;
-
- iface = G_VOLUME_GET_IFACE (volume);
-
- return (* iface->get_platform_id) (volume);
-}
diff --git a/gio/gvolume.h b/gio/gvolume.h
deleted file mode 100644
index 74f63a84..00000000
--- a/gio/gvolume.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef __G_VOLUME_H__
-#define __G_VOLUME_H__
-
-#include <glib-object.h>
-#include <gio/gfile.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_VOLUME (g_volume_get_type ())
-#define G_VOLUME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_VOLUME, GVolume))
-#define G_IS_VOLUME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_VOLUME))
-#define G_VOLUME_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_VOLUME, GVolumeIface))
-
-typedef struct _GDrive GDrive; /* Dummy typedef */
-typedef struct _GVolume GVolume; /* Dummy typedef */
-typedef struct _GVolumeIface GVolumeIface;
-
-struct _GVolumeIface
-{
- GTypeInterface g_iface;
-
- /* signals */
-
- void (*changed) (GVolume *volume);
-
- /* Virtual Table */
-
- GFile * (*get_root) (GVolume *volume);
- char * (*get_name) (GVolume *volume);
- GIcon * (*get_icon) (GVolume *volume);
- GDrive * (*get_drive) (GVolume *volume);
- gboolean (*can_unmount) (GVolume *volume);
- gboolean (*can_eject) (GVolume *volume);
- void (*unmount) (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*unmount_finish) (GVolume *volume,
- GAsyncResult *result,
- GError **error);
- void (*eject) (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*eject_finish) (GVolume *volume,
- GAsyncResult *result,
- GError **error);
- char * (*get_platform_id)(GVolume *volume);
-};
-
-GType g_volume_get_type (void) G_GNUC_CONST;
-
-GFile *g_volume_get_root (GVolume *volume);
-char * g_volume_get_name (GVolume *volume);
-GIcon * g_volume_get_icon (GVolume *volume);
-GDrive * g_volume_get_drive (GVolume *volume);
-gboolean g_volume_can_unmount (GVolume *volume);
-gboolean g_volume_can_eject (GVolume *volume);
-void g_volume_unmount (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_volume_unmount_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error);
-void g_volume_eject (GVolume *volume,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean g_volume_eject_finish (GVolume *volume,
- GAsyncResult *result,
- GError **error);
-
-
-
-G_END_DECLS
-
-#endif /* __G_VOLUME_H__ */
diff --git a/gio/gvolumemonitor.c b/gio/gvolumemonitor.c
deleted file mode 100644
index c091b4ad..00000000
--- a/gio/gvolumemonitor.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include <config.h>
-#include "gvolumemonitor.h"
-#include <glib/gi18n-lib.h>
-
-G_DEFINE_TYPE (GVolumeMonitor, g_volume_monitor, G_TYPE_OBJECT);
-
-enum {
- VOLUME_MOUNTED,
- VOLUME_PRE_UNMOUNT,
- VOLUME_UNMOUNTED,
- DRIVE_CONNECTED,
- DRIVE_DISCONNECTED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-
-static void
-g_volume_monitor_finalize (GObject *object)
-{
- GVolumeMonitor *monitor;
-
- monitor = G_VOLUME_MONITOR (object);
-
- if (G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize) (object);
-}
-
-static void
-g_volume_monitor_class_init (GVolumeMonitorClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_volume_monitor_finalize;
-
- signals[VOLUME_MOUNTED] = g_signal_new (I_("volume_mounted"),
- G_TYPE_VOLUME_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GVolumeMonitorClass, volume_mounted),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_VOLUME);
-
- signals[VOLUME_PRE_UNMOUNT] = g_signal_new (I_("volume_pre_unmount"),
- G_TYPE_VOLUME_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GVolumeMonitorClass, volume_pre_unmount),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_VOLUME);
-
- signals[VOLUME_UNMOUNTED] = g_signal_new (I_("volume_unmounted"),
- G_TYPE_VOLUME_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GVolumeMonitorClass, volume_unmounted),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_VOLUME);
-
- signals[DRIVE_CONNECTED] = g_signal_new (I_("drive_connected"),
- G_TYPE_VOLUME_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GVolumeMonitorClass, drive_connected),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_DRIVE);
-
-
- signals[DRIVE_DISCONNECTED] = g_signal_new (I_("drive_disconnected"),
- G_TYPE_VOLUME_MONITOR,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GVolumeMonitorClass, drive_disconnected),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_DRIVE);
-}
-
-static void
-g_volume_monitor_init (GVolumeMonitor *monitor)
-{
-}
-
-
-GList *
-g_volume_monitor_get_mounted_volumes (GVolumeMonitor *volume_monitor)
-{
- GVolumeMonitorClass *class;
-
- class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
-
- return class->get_mounted_volumes (volume_monitor);
-}
-
-GList *
-g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor)
-{
- GVolumeMonitorClass *class;
-
- class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
-
- return class->get_connected_drives (volume_monitor);
-}
-
diff --git a/gio/gvolumemonitor.h b/gio/gvolumemonitor.h
deleted file mode 100644
index 4d025b62..00000000
--- a/gio/gvolumemonitor.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef __G_VOLUME_MONITOR_H__
-#define __G_VOLUME_MONITOR_H__
-
-#include <glib-object.h>
-#include <gio/gvolume.h>
-#include <gio/gdrive.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_VOLUME_MONITOR (g_volume_monitor_get_type ())
-#define G_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_VOLUME_MONITOR, GVolumeMonitor))
-#define G_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_VOLUME_MONITOR, GVolumeMonitorClass))
-#define G_VOLUME_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_VOLUME_MONITOR, GVolumeMonitorClass))
-#define G_IS_VOLUME_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_VOLUME_MONITOR))
-#define G_IS_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_VOLUME_MONITOR))
-
-typedef struct _GVolumeMonitor GVolumeMonitor;
-typedef struct _GVolumeMonitorClass GVolumeMonitorClass;
-
-struct _GVolumeMonitor {
- GObject parent;
- gpointer priv;
-};
-
-struct _GVolumeMonitorClass {
- GObjectClass parent_class;
-
- /*< public >*/
- /* signals */
- void (* volume_mounted) (GVolumeMonitor *volume_monitor,
- GVolume *volume);
- void (* volume_pre_unmount) (GVolumeMonitor *volume_monitor,
- GVolume *volume);
- void (* volume_unmounted) (GVolumeMonitor *volume_monitor,
- GVolume *volume);
- void (* drive_connected) (GVolumeMonitor *volume_monitor,
- GDrive *drive);
- void (* drive_disconnected) (GVolumeMonitor *volume_monitor,
- GDrive *drive);
-
- /* Vtable */
-
- GList * (*get_mounted_volumes) (GVolumeMonitor *volume_monitor);
- GList * (*get_connected_drives) (GVolumeMonitor *volume_monitor);
-};
-
-GType g_volume_monitor_get_type (void) G_GNUC_CONST;
-
-GVolumeMonitor *g_get_volume_monitor (void);
-GList * g_volume_monitor_get_mounted_volumes (GVolumeMonitor *volume_monitor);
-GList * g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor);
-
-G_END_DECLS
-
-#endif /* __G_VOLUME_MONITOR_H__ */
diff --git a/gio/gvolumepriv.h b/gio/gvolumepriv.h
deleted file mode 100644
index 13d59d39..00000000
--- a/gio/gvolumepriv.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __G_VOLUMEPRIV_H__
-#define __G_VOLUMEPRIV_H__
-
-#include <gio/gvolume.h>
-
-G_BEGIN_DECLS
-
-char *g_volume_get_platform_id (GVolume *volume);
-
-G_END_DECLS
-
-#endif /* __G_VOLUMEPRIV_H__ */
diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c
deleted file mode 100644
index af18210b..00000000
--- a/gio/gwin32appinfo.c
+++ /dev/null
@@ -1,590 +0,0 @@
-#include <config.h>
-
-#include <string.h>
-
-#include "gcontenttypeprivate.h"
-#include "gwin32appinfo.h"
-#include "gioerror.h"
-#include <glib/gi18n-lib.h>
-#include <glib/gstdio.h>
-
-#include <windows.h>
-#include <shlwapi.h>
-
-#ifndef ASSOCF_INIT_BYEXENAME
-#define ASSOCF_INIT_BYEXENAME 0x00000002
-#endif
-
-/* These were wrong in MingW */
-#define REAL_ASSOCSTR_COMMAND 1
-#define REAL_ASSOCSTR_EXECUTABLE 2
-#define REAL_ASSOCSTR_FRIENDLYDOCNAME 3
-#define REAL_ASSOCSTR_FRIENDLYAPPNAME 4
-
-
-static void g_win32_app_info_iface_init (GAppInfoIface *iface);
-
-struct _GWin32AppInfo
-{
- GObject parent_instance;
- wchar_t *id;
- gboolean id_is_exename;
- char *executable;
- char *name;
- gboolean no_open_with;
-};
-
-G_DEFINE_TYPE_WITH_CODE (GWin32AppInfo, g_win32_app_info, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (G_TYPE_APP_INFO,
- g_win32_app_info_iface_init))
-
-
-static void
-g_win32_app_info_finalize (GObject *object)
-{
- GWin32AppInfo *info;
-
- info = G_WIN32_APP_INFO (object);
-
- g_free (info->id);
- g_free (info->name);
- g_free (info->executable);
-
- if (G_OBJECT_CLASS (g_win32_app_info_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_win32_app_info_parent_class)->finalize) (object);
-}
-
-static void
-g_win32_app_info_class_init (GWin32AppInfoClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = g_win32_app_info_finalize;
-}
-
-static void
-g_win32_app_info_init (GWin32AppInfo *local)
-{
-}
-
-static GAppInfo *
-g_desktop_app_info_new_from_id (wchar_t *id /* takes ownership */,
- gboolean id_is_exename)
-{
- ASSOCF flags;
- wchar_t buffer[1024];
- DWORD buffer_size;
- GWin32AppInfo *info;
- HKEY app_key;
-
- info = g_object_new (G_TYPE_WIN32_APP_INFO, NULL);
- info->id = id; /* Takes ownership */
- info->id_is_exename = id_is_exename;
-
- flags = 0;
- if (id_is_exename)
- flags |= ASSOCF_INIT_BYEXENAME;
-
- buffer_size = 1024;
- if (AssocQueryStringW(flags,
- REAL_ASSOCSTR_EXECUTABLE,
- id,
- NULL,
- buffer,
- &buffer_size) == S_OK)
- info->executable = g_utf16_to_utf8 (buffer, -1, NULL, NULL, NULL);
-
- buffer_size = 1024;
- if (AssocQueryStringW(flags,
- REAL_ASSOCSTR_FRIENDLYAPPNAME,
- id,
- NULL,
- buffer,
- &buffer_size) == S_OK)
- info->name = g_utf16_to_utf8 (buffer, -1, NULL, NULL, NULL);
-
- if (info->name == NULL)
- {
- /* TODO: Should look up name from executable resources */
- if (info->executable)
- info->name = g_path_get_basename (info->executable);
- else
- info->name = g_utf16_to_utf8 (info->id, -1, NULL, NULL, NULL);
- }
-
- if (AssocQueryKeyW(flags,
- ASSOCKEY_APP,
- info->id,
- NULL,
- &app_key) == S_OK)
- {
- if (RegQueryValueExW (app_key, L"NoOpenWith", 0,
- NULL, NULL, NULL) == ERROR_SUCCESS)
- info->no_open_with = TRUE;
- RegCloseKey (app_key);
- }
-
- return G_APP_INFO (info);
-}
-
-static wchar_t *
-dup_wstring (wchar_t *str)
-{
- gsize len;
- for (len = 0; str[len] != 0; len++)
- ;
- return (wchar_t *)g_memdup (str, (len + 1) * 2);
-}
-
-static GAppInfo *
-g_win32_app_info_dup (GAppInfo *appinfo)
-{
- GWin32AppInfo *info = G_WIN32_APP_INFO (appinfo);
- GWin32AppInfo *new_info;
-
- new_info = g_object_new (G_TYPE_WIN32_APP_INFO, NULL);
-
- new_info->id = dup_wstring (info->id);
- new_info->id_is_exename = info->id_is_exename;
- new_info->name = g_strdup (info->name);
- new_info->executable = g_strdup (info->executable);
- new_info->no_open_with = info->no_open_with;
-
- return G_APP_INFO (new_info);
-}
-
-static gboolean
-g_win32_app_info_equal (GAppInfo *appinfo1,
- GAppInfo *appinfo2)
-{
- GWin32AppInfo *info1 = G_WIN32_APP_INFO (appinfo1);
- GWin32AppInfo *info2 = G_WIN32_APP_INFO (appinfo2);
-
- if (info1->executable == NULL ||
- info2->executable == NULL)
- return FALSE;
-
- return strcmp (info1->executable, info2->executable) == 0;
-}
-
-static char *
-g_win32_app_info_get_name (GAppInfo *appinfo)
-{
- GWin32AppInfo *info = G_WIN32_APP_INFO (appinfo);
-
- if (info->name == NULL)
- return g_strdup (_("Unnamed"));
-
- return g_strdup (info->name);
-}
-
-static char *
-g_win32_app_info_get_description (GAppInfo *appinfo)
-{
- /* Win32 has no app descriptions */
- return NULL;
-}
-
-static char *
-g_win32_app_info_get_icon (GAppInfo *appinfo)
-{
- /* GWin32AppInfo *info = G_WIN32_APP_INFO (appinfo); */
-
- /* TODO: How to handle icons */
- return NULL;
-}
-
-static gboolean
-g_win32_app_info_launch (GAppInfo *appinfo,
- GList *filenames,
- char **envp,
- GError **error)
-{
- GWin32AppInfo *info = G_WIN32_APP_INFO (appinfo);
- ASSOCF flags;
- HKEY class_key;
- SHELLEXECUTEINFOW exec_info = {0};
- GList *l;
-
- /* TODO: How do we pass envp if its != NULL ?? */
-
- flags = 0;
- if (info->id_is_exename)
- flags |= ASSOCF_INIT_BYEXENAME;
-
- if (AssocQueryKeyW(flags,
- ASSOCKEY_SHELLEXECCLASS,
- info->id,
- NULL,
- &class_key) != S_OK)
- {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Can't find application"));
- return FALSE;
- }
-
- for (l = filenames; l != NULL; l = l->next)
- {
- wchar_t *wfilename = g_utf8_to_utf16 (l->data, -1, NULL, NULL, NULL);
-
- memset (&exec_info, 0, sizeof (exec_info));
- exec_info.cbSize = sizeof (exec_info);
- exec_info.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_CLASSKEY;
- exec_info.lpFile = wfilename;
- exec_info.nShow = SW_SHOWNORMAL;
- exec_info.hkeyClass = class_key;
-
- if (!ShellExecuteExW(&exec_info))
- {
- DWORD last_error;
- LPVOID message;
- char *message_utf8;
-
- last_error = GetLastError ();
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- last_error,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &message,
- 0, NULL );
-
- message_utf8 = g_utf16_to_utf8 (message, -1, NULL, NULL, NULL);
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Error launching application: %s"), message_utf8);
- g_free (message_utf8);
- LocalFree (message);
-
- g_free (wfilename);
- RegCloseKey (class_key);
- return FALSE;
- }
-
- g_free (wfilename);
- }
-
- RegCloseKey (class_key);
-
- return TRUE;
-}
-
-static gboolean
-g_win32_app_info_supports_uris (GAppInfo *appinfo)
-{
- return FALSE;
-}
-
-static gboolean
-g_win32_app_info_launch_uris (GAppInfo *appinfo,
- GList *uris,
- char **envp,
- GError **error)
-{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("URIs not supported"));
- return FALSE;
-}
-
-static gboolean
-g_win32_app_info_should_show (GAppInfo *appinfo,
- const char *win32_env)
-{
- GWin32AppInfo *info = G_WIN32_APP_INFO (appinfo);
-
- if (info->no_open_with)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-g_win32_app_info_set_as_default_for_type (GAppInfo *appinfo,
- const char *content_type,
- GError **error)
-{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("association changes not supported on win32"));
- return FALSE;
-}
-
-GAppInfo *
-g_app_info_create_from_commandline (const char *commandline,
- const char *application_name,
- GError **error)
-{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("Association createion not supported on win32"));
- return NULL;
-}
-
-
-static void
-g_win32_app_info_iface_init (GAppInfoIface *iface)
-{
- iface->dup = g_win32_app_info_dup;
- iface->equal = g_win32_app_info_equal;
- iface->get_name = g_win32_app_info_get_name;
- iface->get_description = g_win32_app_info_get_description;
- iface->get_icon = g_win32_app_info_get_icon;
- iface->launch = g_win32_app_info_launch;
- iface->supports_uris = g_win32_app_info_supports_uris;
- iface->launch_uris = g_win32_app_info_launch_uris;
- iface->should_show = g_win32_app_info_should_show;
- iface->set_as_default_for_type = g_win32_app_info_set_as_default_for_type;
-}
-
-static void
-enumerate_open_with_list (HKEY dir_key,
- GList **prognames)
-{
- DWORD index;
- wchar_t name[256];
- DWORD name_len, nbytes;
- wchar_t data[256];
- wchar_t *data_alloc;
- DWORD type;
-
- /* Must also look inside for a,b,c, + MRUList */
- index = 0;
- name_len = 256;
- nbytes = sizeof (data) - 2;
- while (RegEnumValueW(dir_key,
- index,
- name,
- &name_len,
- 0,
- &type,
- (LPBYTE)data,
- &nbytes) == ERROR_SUCCESS)
- {
- data[nbytes/2] = '\0';
- if (type == REG_SZ &&
- /* Ignore things like MRUList, just look at 'a', 'b', 'c', etc */
- name_len == 1)
- {
- data_alloc = (wchar_t *)g_memdup (data, nbytes + 2);
- data_alloc[nbytes/2] = 0;
- *prognames = g_list_prepend (*prognames, data_alloc);
- }
- index++;
- name_len = 256;
- nbytes = sizeof (data) - 2;
- }
-
- index = 0;
- name_len = 256;
- while (RegEnumKeyExW(dir_key,
- index,
- name,
- &name_len,
- NULL,
- NULL,
- NULL,
- NULL) == ERROR_SUCCESS)
- {
- *prognames = g_list_prepend (*prognames, g_memdup (name, (name_len + 1) * 2));
- index++;
- name_len = 256;
- }
-}
-
-static void
-enumerate_open_with_progids (HKEY dir_key,
- GList **progids)
-{
- DWORD index;
- wchar_t name[256];
- DWORD name_len, type;
-
- index = 0;
- name_len = 256;
- while (RegEnumValueW(dir_key,
- index,
- name,
- &name_len,
- 0,
- &type,
- NULL,
- 0) == ERROR_SUCCESS)
- {
- *progids = g_list_prepend (*progids, g_memdup (name, (name_len + 1) * 2));
- index++;
- name_len = 256;
- }
-}
-
-static void
-enumerate_open_with_root (HKEY dir_key,
- GList **progids,
- GList **prognames)
-{
- HKEY reg_key = NULL;
-
- if (RegOpenKeyExW (dir_key, L"OpenWithList", 0,
- KEY_READ, &reg_key) == ERROR_SUCCESS)
- {
- enumerate_open_with_list (reg_key, prognames);
- RegCloseKey (reg_key);
- }
-
- if (RegOpenKeyExW (dir_key, L"OpenWithProgids", 0,
- KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS)
- {
- enumerate_open_with_progids (reg_key, progids);
- RegCloseKey (reg_key);
- }
-}
-
-static gboolean
-app_info_in_list (GAppInfo *info, GList *l)
-{
- while (l != NULL)
- {
- if (g_app_info_equal (info, l->data))
- return TRUE;
- l = l->next;
- }
- return FALSE;
-}
-
-GList *
-g_get_all_app_info_for_type (const char *content_type)
-{
- GList *progids = NULL;
- GList *prognames = NULL;
- HKEY reg_key, sys_file_assoc_key, reg_key2;
- wchar_t percieved_type[128];
- DWORD nchars, key_type;
- wchar_t *wc_key;
- GList *l;
- GList *infos;
-
- wc_key = g_utf8_to_utf16 (content_type, -1, NULL, NULL, NULL);
- if (RegOpenKeyExW (HKEY_CLASSES_ROOT, wc_key, 0,
- KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS)
- {
- enumerate_open_with_root (reg_key, &progids, &prognames);
-
- nchars = sizeof (percieved_type) / sizeof(wchar_t);
- if (RegQueryValueExW (reg_key, L"PerceivedType", 0,
- &key_type, (LPBYTE) percieved_type, &nchars) == ERROR_SUCCESS)
- {
- if (key_type == REG_SZ &&
- RegOpenKeyExW (HKEY_CLASSES_ROOT, L"SystemFileAssociations", 0,
- KEY_QUERY_VALUE, &sys_file_assoc_key) == ERROR_SUCCESS)
- {
- if (RegOpenKeyExW (sys_file_assoc_key, percieved_type, 0,
- KEY_QUERY_VALUE, &reg_key2) == ERROR_SUCCESS)
- {
- enumerate_open_with_root (reg_key2, &progids, &prognames);
- RegCloseKey (reg_key2);
- }
-
- RegCloseKey (sys_file_assoc_key);
- }
- }
- RegCloseKey (reg_key);
- }
-
- if (RegOpenKeyExW (HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts", 0,
- KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS)
- {
- if (RegOpenKeyExW (reg_key, wc_key, 0,
- KEY_QUERY_VALUE, &reg_key2) == ERROR_SUCCESS)
- {
- enumerate_open_with_root (reg_key2, &progids, &prognames);
- RegCloseKey (reg_key2);
- }
-
- RegCloseKey (reg_key);
- }
-
- infos = NULL;
- for (l = prognames; l != NULL; l = l->next)
- {
- GAppInfo *info;
-
- /* l->data ownership is taken */
- info = g_desktop_app_info_new_from_id ((wchar_t *)l->data, TRUE);
- if (app_info_in_list (info, infos))
- g_object_unref (info);
- else
- infos = g_list_prepend (infos, info);
- }
- g_list_free (prognames);
-
- for (l = progids; l != NULL; l = l->next)
- {
- GAppInfo *info;
-
- /* l->data ownership is taken */
- info = g_desktop_app_info_new_from_id ((wchar_t *)l->data, FALSE);
- if (app_info_in_list (info, infos))
- g_object_unref (info);
- else
- infos = g_list_prepend (infos, info);
- }
- g_list_free (progids);
-
- g_free (wc_key);
- return g_list_reverse (infos);
-}
-
-GAppInfo *
-g_get_default_app_info_for_type (const char *content_type)
-{
- wchar_t *wtype;
- wchar_t buffer[1024];
- DWORD buffer_size;
-
- wtype = g_utf8_to_utf16 (content_type, -1, NULL, NULL, NULL);
-
- /* Verify that we have some sort of app registered for this type */
- buffer_size = 1024;
- if (AssocQueryStringW(0,
- REAL_ASSOCSTR_COMMAND,
- wtype,
- NULL,
- buffer,
- &buffer_size) == S_OK)
- /* Takes ownership of wtype */
- return g_desktop_app_info_new_from_id (wtype, FALSE);
-
- g_free (wtype);
- return NULL;
-}
-
-GList *
-g_get_all_app_info (void)
-{
- DWORD index;
- wchar_t name[256];
- DWORD name_len;
- HKEY reg_key;
- GList *infos;
- GAppInfo *info;
-
- if (RegOpenKeyExW (HKEY_CLASSES_ROOT, L"Applications", 0,
- KEY_READ, &reg_key) != ERROR_SUCCESS)
- return NULL;
-
- infos = NULL;
- index = 0;
- name_len = 256;
- while (RegEnumKeyExW(reg_key,
- index,
- name,
- &name_len,
- NULL,
- NULL,
- NULL,
- NULL) == ERROR_SUCCESS)
- {
- wchar_t *name_dup = g_memdup (name, (name_len+1)*2);
- /* name_dup ownership is taken */
- info = g_desktop_app_info_new_from_id (name_dup, TRUE);
- infos = g_list_prepend (infos, info);
-
- index++;
- name_len = 256;
- }
-
- RegCloseKey (reg_key);
-
- return g_list_reverse (infos);
-}
diff --git a/gio/gwin32appinfo.h b/gio/gwin32appinfo.h
deleted file mode 100644
index 81982297..00000000
--- a/gio/gwin32appinfo.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __G_WIN32_APP_INFO_H__
-#define __G_WIN32_APP_INFO_H__
-
-#include <gio/gappinfo.h>
-
-G_BEGIN_DECLS
-
-#define G_TYPE_WIN32_APP_INFO (g_win32_app_info_get_type ())
-#define G_WIN32_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_WIN32_APP_INFO, GWin32AppInfo))
-#define G_WIN32_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_WIN32_APP_INFO, GWin32AppInfoClass))
-#define G_IS_WIN32_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_WIN32_APP_INFO))
-#define G_IS_WIN32_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_WIN32_APP_INFO))
-#define G_WIN32_APP_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_WIN32_APP_INFO, GWin32AppInfoClass))
-
-typedef struct _GWin32AppInfo GWin32AppInfo;
-typedef struct _GWin32AppInfoClass GWin32AppInfoClass;
-
-struct _GWin32AppInfoClass
-{
- GObjectClass parent_class;
-};
-
-GType g_win32_app_info_get_type (void) G_GNUC_CONST;
-
-G_END_DECLS
-
-
-#endif /* __G_WIN32_APP_INFO_H__ */
diff --git a/gio/inotify/Makefile.am b/gio/inotify/Makefile.am
deleted file mode 100644
index 020a558a..00000000
--- a/gio/inotify/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-NULL =
-
-INCLUDES = -I$(top_srcdir) \
- $(GLIB_CFLAGS) \
- -DG_DISABLE_DEPRECATED
-
-noinst_LTLIBRARIES = libinotify.la
-
-libinotify_la_SOURCES = \
- inotify-kernel.c \
- inotify-sub.c \
- inotify-path.c \
- inotify-missing.c \
- inotify-helper.c \
- inotify-diag.c \
- inotify-diag.h \
- inotify-kernel.h \
- inotify-missing.h \
- inotify-path.h \
- inotify-sub.h \
- inotify-helper.h \
- local_inotify.h \
- local_inotify_syscalls.h \
- $(NULL)
-
diff --git a/gio/inotify/inotify-diag.c b/gio/inotify/inotify-diag.c
deleted file mode 100644
index 279434fb..00000000
--- a/gio/inotify/inotify-diag.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
-
-/* inotify-helper.c - Gnome VFS Monitor based on inotify.
-
- Copyright (C) 2005 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#include "config.h"
-#include <glib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include "inotify-missing.h"
-#include "inotify-path.h"
-#include "inotify-diag.h"
-
-#define DIAG_DUMP_TIME 20000 /* 20 seconds */
-
-G_LOCK_EXTERN (inotify_lock);
-
-static gboolean
-id_dump (gpointer userdata)
-{
- G_LOCK (inotify_lock);
- GIOChannel *ioc = NULL;
- pid_t pid = getpid ();
- char *fname;
-
- fname = g_strdup_printf ("/tmp/gvfsid.%d", pid);
- ioc = g_io_channel_new_file (fname, "w", NULL);
- g_free (fname);
-
- if (!ioc)
- {
- G_UNLOCK (inotify_lock);
- return TRUE;
- }
-
- _im_diag_dump (ioc);
-
- g_io_channel_shutdown (ioc, TRUE, NULL);
- g_io_channel_unref (ioc);
-
- G_UNLOCK (inotify_lock);
- return TRUE;
-}
-
-void
-_id_startup (void)
-{
- if (!g_getenv ("GVFS_INOTIFY_DIAG"))
- return;
-
- g_timeout_add (DIAG_DUMP_TIME, id_dump, NULL);
-}
diff --git a/gio/inotify/inotify-diag.h b/gio/inotify/inotify-diag.h
deleted file mode 100644
index f818f161..00000000
--- a/gio/inotify/inotify-diag.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* inotify-helper.h - GNOME VFS Monitor using inotify
-
- Copyright (C) 2006 John McCutchan <john@johnmccutchan.com>
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: John McCutchan <john@johnmccutchan.com>
-*/
-
-
-#ifndef __INOTIFY_DIAG_H
-#define __INOTIFY_DIAG_H
-
-void _id_startup (void);
-
-#endif /* __INOTIFY_DIAG_H */
diff --git a/gio/inotify/inotify-helper.c b/gio/inotify/inotify-helper.c
deleted file mode 100644
index 20f58756..00000000
--- a/gio/inotify/inotify-helper.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
-
-/* inotify-helper.c - GVFS Monitor based on inotify.
-
- Copyright (C) 2007 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#include "config.h"
-#include <errno.h>
-#include <time.h>
-#include <string.h>
-#include <sys/ioctl.h>
-/* Just include the local header to stop all the pain */
-#include "local_inotify.h"
-#if 0
-#ifdef HAVE_SYS_INOTIFY_H
-/* We don't actually include the libc header, because there has been
- * problems with libc versions that was built without inotify support.
- * Instead we use the local version.
- */
-#include "local_inotify.h"
-#elif defined (HAVE_LINUX_INOTIFY_H)
-#include <linux/inotify.h>
-#endif
-#endif
-#include <gio/glocalfile.h>
-#include <gio/gfilemonitorpriv.h>
-#include <gio/gdirectorymonitorpriv.h>
-#include "inotify-helper.h"
-#include "inotify-missing.h"
-#include "inotify-path.h"
-#include "inotify-diag.h"
-
-static gboolean ih_debug_enabled = FALSE;
-#define IH_W if (ih_debug_enabled) g_warning
-
-static void ih_event_callback (ik_event_t *event, inotify_sub *sub);
-static void ih_not_missing_callback (inotify_sub *sub);
-
-/* We share this lock with inotify-kernel.c and inotify-missing.c
- *
- * inotify-kernel.c takes the lock when it reads events from
- * the kernel and when it processes those events
- *
- * inotify-missing.c takes the lock when it is scanning the missing
- * list.
- *
- * We take the lock in all public functions
- */
-G_LOCK_DEFINE (inotify_lock);
-
-static GFileMonitorEvent ih_mask_to_EventFlags (guint32 mask);
-
-/**
- * Initializes the inotify backend. This must be called before
- * any other functions in this module.
- *
- * @returns TRUE if initialization succeeded, FALSE otherwise
- */
-gboolean
-_ih_startup (void)
-{
- static gboolean initialized = FALSE;
- static gboolean result = FALSE;
-
- G_LOCK (inotify_lock);
-
- if (initialized == TRUE)
- {
- G_UNLOCK (inotify_lock);
- return result;
- }
-
- result = _ip_startup (ih_event_callback);
- if (!result)
- {
- g_warning ("Could not initialize inotify\n");
- G_UNLOCK (inotify_lock);
- return FALSE;
- }
- _im_startup (ih_not_missing_callback);
- _id_startup ();
-
- IH_W ("started gvfs inotify backend\n");
-
- initialized = TRUE;
-
- G_UNLOCK (inotify_lock);
-
- return TRUE;
-}
-
-/**
- * Adds a subscription to be monitored.
- */
-gboolean
-_ih_sub_add (inotify_sub * sub)
-{
- G_LOCK (inotify_lock);
-
- if (!_ip_start_watching (sub))
- _im_add (sub);
-
- G_UNLOCK (inotify_lock);
- return TRUE;
-}
-
-/**
- * Cancels a subscription which was being monitored.
- */
-gboolean
-_ih_sub_cancel (inotify_sub * sub)
-{
- G_LOCK (inotify_lock);
-
- if (!sub->cancelled)
- {
- IH_W ("cancelling %s\n", sub->dirname);
- sub->cancelled = TRUE;
- _im_rm (sub);
- _ip_stop_watching (sub);
- }
-
- G_UNLOCK (inotify_lock);
-
- return TRUE;
-}
-
-
-static void
-ih_event_callback (ik_event_t *event, inotify_sub *sub)
-{
- gchar *fullpath;
- GFileMonitorEvent eflags;
- GFile* parent;
- GFile* child;
-
- eflags = ih_mask_to_EventFlags (event->mask);
- parent = g_file_new_for_path (sub->dirname);
- if (event->name)
- fullpath = g_strdup_printf ("%s/%s", sub->dirname, event->name);
- else
- fullpath = g_strdup_printf ("%s/", sub->dirname);
-
- child = g_file_new_for_path (fullpath);
- g_free (fullpath);
-
- if (G_IS_DIRECTORY_MONITOR (sub->user_data))
- {
- GDirectoryMonitor* monitor = G_DIRECTORY_MONITOR (sub->user_data);
- g_directory_monitor_emit_event (monitor,
- child, NULL, eflags);
- }
- else if (G_IS_FILE_MONITOR (sub->user_data))
- {
- GFileMonitor* monitor = G_FILE_MONITOR (sub->user_data);
- g_file_monitor_emit_event (monitor,
- child, NULL, eflags);
- }
-
- g_object_unref (child);
- g_object_unref (parent);
-}
-
-static void
-ih_not_missing_callback (inotify_sub *sub)
-{
- gchar *fullpath;
- GFileMonitorEvent eflags;
- guint32 mask;
- GFile* parent;
- GFile* child;
-
- parent = g_file_new_for_path (sub->dirname);
-
- if (sub->filename)
- {
- fullpath = g_strdup_printf ("%s/%s", sub->dirname, sub->filename);
- g_warning ("Missing callback called fullpath = %s\n", fullpath);
- if (!g_file_test (fullpath, G_FILE_TEST_EXISTS))
- {
- g_free (fullpath);
- return;
- }
- mask = IN_CREATE;
- }
- else
- {
- fullpath = g_strdup_printf ("%s", sub->dirname);
- mask = IN_CREATE|IN_ISDIR;
- }
-
- eflags = ih_mask_to_EventFlags (mask);
- child = g_file_new_for_path (fullpath);
- g_free (fullpath);
-
- if (G_IS_DIRECTORY_MONITOR (sub->user_data))
- {
- GDirectoryMonitor* monitor = G_DIRECTORY_MONITOR (sub->user_data);
- g_directory_monitor_emit_event (monitor, child, NULL, eflags);
- }
- else if (G_IS_FILE_MONITOR (sub->user_data))
- {
- GFileMonitor* monitor = G_FILE_MONITOR (sub->user_data);
- g_file_monitor_emit_event (monitor,
- child, NULL, eflags);
- }
-
- g_object_unref (child);
- g_object_unref (parent);
-}
-
-/* Transforms a inotify event to a GVFS event. */
-static GFileMonitorEvent
-ih_mask_to_EventFlags (guint32 mask)
-{
- mask &= ~IN_ISDIR;
- switch (mask)
- {
- case IN_MODIFY:
- return G_FILE_MONITOR_EVENT_CHANGED;
- case IN_CLOSE_WRITE:
- return G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT;
- case IN_ATTRIB:
- return G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED;
- case IN_MOVE_SELF:
- case IN_MOVED_FROM:
- case IN_DELETE:
- case IN_DELETE_SELF:
- return G_FILE_MONITOR_EVENT_DELETED;
- case IN_CREATE:
- case IN_MOVED_TO:
- return G_FILE_MONITOR_EVENT_CREATED;
- case IN_UNMOUNT:
- return G_FILE_MONITOR_EVENT_UNMOUNTED;
- case IN_Q_OVERFLOW:
- case IN_OPEN:
- case IN_CLOSE_NOWRITE:
- case IN_ACCESS:
- case IN_IGNORED:
- default:
- return -1;
- }
-}
diff --git a/gio/inotify/inotify-helper.h b/gio/inotify/inotify-helper.h
deleted file mode 100644
index 1fd9701d..00000000
--- a/gio/inotify/inotify-helper.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* inotify-helper.h - GVFS Directory Monitor using inotify
-
- Copyright (C) 2007 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: John McCutchan <john@johnmccutchan.com>
-*/
-
-
-#ifndef __INOTIFY_HELPER_H
-#define __INOTIFY_HELPER_H
-
-#include "inotify-sub.h"
-
-gboolean _ih_startup (void);
-gboolean _ih_sub_add (inotify_sub *sub);
-gboolean _ih_sub_cancel (inotify_sub *sub);
-
-#endif /* __INOTIFY_HELPER_H */
diff --git a/gio/inotify/inotify-kernel.c b/gio/inotify/inotify-kernel.c
deleted file mode 100644
index 7979a27a..00000000
--- a/gio/inotify/inotify-kernel.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- Copyright (C) 2005 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:.
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#include "config.h"
-
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <glib.h>
-#include "inotify-kernel.h"
-
-/* Just include the local headers to stop all the pain */
-#include "local_inotify.h"
-#include "local_inotify_syscalls.h"
-#if 0
-#ifdef HAVE_SYS_INOTIFY_H
-/* We don't actually include the libc header, because there has been
- * problems with libc versions that was built without inotify support.
- * Instead we use the local version.
- */
-#include "local_inotify.h"
-#include "local_inotify_syscalls.h"
-#elif defined (HAVE_LINUX_INOTIFY_H)
-#include <linux/inotify.h>
-#include "local_inotify_syscalls.h"
-#endif
-#endif
-
-/* Timings for pairing MOVED_TO / MOVED_FROM events */
-#define PROCESS_EVENTS_TIME 1000 /* milliseconds (1 hz) */
-#define DEFAULT_HOLD_UNTIL_TIME 0 /* 0 millisecond */
-#define MOVE_HOLD_UNTIL_TIME 0 /* 0 milliseconds */
-
-static int inotify_instance_fd = -1;
-static GQueue *events_to_process = NULL;
-static GQueue *event_queue = NULL;
-static GHashTable * cookie_hash = NULL;
-static GIOChannel *inotify_read_ioc;
-static GPollFD ik_poll_fd;
-static gboolean ik_poll_fd_enabled = TRUE;
-static void (*user_cb)(ik_event_t *event);
-
-static gboolean ik_read_callback (gpointer user_data);
-static gboolean ik_process_eq_callback (gpointer user_data);
-
-static guint32 ik_move_matches = 0;
-static guint32 ik_move_misses = 0;
-
-static gboolean process_eq_running = FALSE;
-
-/* We use the lock from inotify-helper.c
- *
- * There are two places that we take this lock
- *
- * 1) In ik_read_callback
- *
- * 2) ik_process_eq_callback.
- *
- *
- * The rest of locking is taken care of in inotify-helper.c
- */
-G_LOCK_EXTERN (inotify_lock);
-
-typedef struct ik_event_internal {
- ik_event_t *event;
- gboolean seen;
- gboolean sent;
- GTimeVal hold_until;
- struct ik_event_internal *pair;
-} ik_event_internal_t;
-
-/* In order to perform non-sleeping inotify event chunking we need
- * a custom GSource
- */
-static gboolean
-ik_source_prepare (GSource *source,
- gint *timeout)
-{
- return FALSE;
-}
-
-static gboolean
-ik_source_timeout (gpointer data)
-{
- GSource *source = (GSource *)data;
-
- /* Re-active the PollFD */
- g_source_add_poll (source, &ik_poll_fd);
- g_source_unref (source);
- ik_poll_fd_enabled = TRUE;
-
- return FALSE;
-}
-
-#define MAX_PENDING_COUNT 2
-#define PENDING_THRESHOLD(qsize) ((qsize) >> 1)
-#define PENDING_MARGINAL_COST(p) ((unsigned int)(1 << (p)))
-#define MAX_QUEUED_EVENTS 2048
-#define AVERAGE_EVENT_SIZE sizeof (struct inotify_event) + 16
-#define TIMEOUT_MILLISECONDS 10
-
-static gboolean
-ik_source_check (GSource *source)
-{
- static int prev_pending = 0, pending_count = 0;
-
- /* We already disabled the PollFD or
- * nothing to be read from inotify */
- if (!ik_poll_fd_enabled || !(ik_poll_fd.revents & G_IO_IN))
- return FALSE;
-
- if (pending_count < MAX_PENDING_COUNT)
- {
- unsigned int pending;
-
- if (ioctl (inotify_instance_fd, FIONREAD, &pending) == -1)
- goto do_read;
-
- pending /= AVERAGE_EVENT_SIZE;
-
- /* Don't wait if the number of pending events is too close
- * to the maximum queue size.
- */
- if (pending > PENDING_THRESHOLD (MAX_QUEUED_EVENTS))
- goto do_read;
-
- /* With each successive iteration, the minimum rate for
- * further sleep doubles. */
- if (pending-prev_pending < PENDING_MARGINAL_COST (pending_count))
- goto do_read;
-
- prev_pending = pending;
- pending_count++;
-
- /* We are going to wait to read the events: */
-
- /* Remove the PollFD from the source */
- g_source_remove_poll (source, &ik_poll_fd);
- /* To avoid threading issues we need to flag that we've done that */
- ik_poll_fd_enabled = FALSE;
- /* Set a timeout to re-add the PollFD to the source */
- g_source_ref (source);
- g_timeout_add (TIMEOUT_MILLISECONDS, ik_source_timeout, source);
-
- return FALSE;
- }
-
-do_read:
- /* We are ready to read events from inotify */
-
- prev_pending = 0;
- pending_count = 0;
-
- return TRUE;
-}
-
-static gboolean
-ik_source_dispatch (GSource *source,
- GSourceFunc callback,
- gpointer user_data)
-{
- if (callback)
- return callback (user_data);
- return TRUE;
-}
-
-GSourceFuncs ik_source_funcs =
-{
- ik_source_prepare,
- ik_source_check,
- ik_source_dispatch,
- NULL
-};
-
-gboolean _ik_startup (void (*cb)(ik_event_t *event))
-{
- static gboolean initialized = FALSE;
- GSource *source;
-
- user_cb = cb;
- /* Ignore multi-calls */
- if (initialized)
- return inotify_instance_fd >= 0;
-
- initialized = TRUE;
- inotify_instance_fd = inotify_init ();
-
- if (inotify_instance_fd < 0)
- return FALSE;
-
- inotify_read_ioc = g_io_channel_unix_new (inotify_instance_fd);
- ik_poll_fd.fd = inotify_instance_fd;
- ik_poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
- g_io_channel_set_encoding (inotify_read_ioc, NULL, NULL);
- g_io_channel_set_flags (inotify_read_ioc, G_IO_FLAG_NONBLOCK, NULL);
-
- source = g_source_new (&ik_source_funcs, sizeof(GSource));
- g_source_add_poll (source, &ik_poll_fd);
- g_source_set_callback (source, ik_read_callback, NULL, NULL);
- g_source_attach (source, NULL);
- g_source_unref (source);
-
- cookie_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
- event_queue = g_queue_new ();
- events_to_process = g_queue_new ();
-
- return TRUE;
-}
-
-static ik_event_internal_t *
-ik_event_internal_new (ik_event_t *event)
-{
- ik_event_internal_t *internal_event = g_new0 (ik_event_internal_t, 1);
- GTimeVal tv;
-
- g_assert (event);
-
- g_get_current_time (&tv);
- g_time_val_add (&tv, DEFAULT_HOLD_UNTIL_TIME);
- internal_event->event = event;
- internal_event->hold_until = tv;
-
- return internal_event;
-}
-
-static ik_event_t *
-ik_event_new (char *buffer)
-{
- struct inotify_event *kevent = (struct inotify_event *)buffer;
- ik_event_t *event = g_new0(ik_event_t,1);
-
- g_assert (buffer);
-
- event->wd = kevent->wd;
- event->mask = kevent->mask;
- event->cookie = kevent->cookie;
- event->len = kevent->len;
- if (event->len)
- event->name = g_strdup (kevent->name);
- else
- event->name = g_strdup ("");
-
- return event;
-}
-
-ik_event_t *
-_ik_event_new_dummy (const char *name, gint32 wd, guint32 mask)
-{
- ik_event_t *event = g_new0 (ik_event_t,1);
- event->wd = wd;
- event->mask = mask;
- event->cookie = 0;
- if (name)
- event->name = g_strdup (name);
- else
- event->name = g_strdup("");
-
- event->len = strlen (event->name);
-
- return event;
-}
-
-void
-_ik_event_free (ik_event_t *event)
-{
- if (event->pair)
- _ik_event_free (event->pair);
- g_free (event->name);
- g_free (event);
-}
-
-gint32
-_ik_watch (const char *path, guint32 mask, int *err)
-{
- gint32 wd = -1;
-
- g_assert (path != NULL);
- g_assert (inotify_instance_fd >= 0);
-
- wd = inotify_add_watch (inotify_instance_fd, path, mask);
-
- if (wd < 0)
- {
- int e = errno;
- /* FIXME: debug msg failed to add watch */
- if (err)
- *err = e;
- return wd;
- }
-
- g_assert (wd >= 0);
- return wd;
-}
-
-int
-_ik_ignore(const char *path, gint32 wd)
-{
- g_assert (wd >= 0);
- g_assert (inotify_instance_fd >= 0);
-
- if (inotify_rm_watch (inotify_instance_fd, wd) < 0)
- {
- /* int e = errno; */
- /* failed to rm watch */
- return -1;
- }
-
- return 0;
-}
-
-void
-_ik_move_stats (guint32 *matches, guint32 *misses)
-{
- if (matches)
- *matches = ik_move_matches;
-
- if (misses)
- *misses = ik_move_misses;
-}
-
-const char *
-_ik_mask_to_string (guint32 mask)
-{
- gboolean is_dir = mask & IN_ISDIR;
- mask &= ~IN_ISDIR;
-
- if (is_dir)
- {
- switch (mask)
- {
- case IN_ACCESS:
- return "ACCESS (dir)";
- case IN_MODIFY:
- return "MODIFY (dir)";
- case IN_ATTRIB:
- return "ATTRIB (dir)";
- case IN_CLOSE_WRITE:
- return "CLOSE_WRITE (dir)";
- case IN_CLOSE_NOWRITE:
- return "CLOSE_NOWRITE (dir)";
- case IN_OPEN:
- return "OPEN (dir)";
- case IN_MOVED_FROM:
- return "MOVED_FROM (dir)";
- case IN_MOVED_TO:
- return "MOVED_TO (dir)";
- case IN_DELETE:
- return "DELETE (dir)";
- case IN_CREATE:
- return "CREATE (dir)";
- case IN_DELETE_SELF:
- return "DELETE_SELF (dir)";
- case IN_UNMOUNT:
- return "UNMOUNT (dir)";
- case IN_Q_OVERFLOW:
- return "Q_OVERFLOW (dir)";
- case IN_IGNORED:
- return "IGNORED (dir)";
- default:
- return "UNKNOWN_EVENT (dir)";
- }
- }
- else
- {
- switch (mask)
- {
- case IN_ACCESS:
- return "ACCESS";
- case IN_MODIFY:
- return "MODIFY";
- case IN_ATTRIB:
- return "ATTRIB";
- case IN_CLOSE_WRITE:
- return "CLOSE_WRITE";
- case IN_CLOSE_NOWRITE:
- return "CLOSE_NOWRITE";
- case IN_OPEN:
- return "OPEN";
- case IN_MOVED_FROM:
- return "MOVED_FROM";
- case IN_MOVED_TO:
- return "MOVED_TO";
- case IN_DELETE:
- return "DELETE";
- case IN_CREATE:
- return "CREATE";
- case IN_DELETE_SELF:
- return "DELETE_SELF";
- case IN_UNMOUNT:
- return "UNMOUNT";
- case IN_Q_OVERFLOW:
- return "Q_OVERFLOW";
- case IN_IGNORED:
- return "IGNORED";
- default:
- return "UNKNOWN_EVENT";
- }
- }
-}
-
-
-static void
-ik_read_events (gsize *buffer_size_out, gchar **buffer_out)
-{
- static gchar *buffer = NULL;
- static gsize buffer_size;
-
- /* Initialize the buffer on our first call */
- if (buffer == NULL)
- {
- buffer_size = AVERAGE_EVENT_SIZE;
- buffer_size *= MAX_QUEUED_EVENTS;
- buffer = g_malloc (buffer_size);
- }
-
- *buffer_size_out = 0;
- *buffer_out = NULL;
-
- memset (buffer, 0, buffer_size);
-
- if (g_io_channel_read_chars (inotify_read_ioc, (char *)buffer, buffer_size, buffer_size_out, NULL) != G_IO_STATUS_NORMAL) {
- /* error reading */
- }
- *buffer_out = buffer;
-}
-
-static gboolean
-ik_read_callback (gpointer user_data)
-{
- gchar *buffer;
- gsize buffer_size, buffer_i, events;
-
- G_LOCK (inotify_lock);
- ik_read_events (&buffer_size, &buffer);
-
- buffer_i = 0;
- events = 0;
- while (buffer_i < buffer_size)
- {
- struct inotify_event *event;
- gsize event_size;
- event = (struct inotify_event *)&buffer[buffer_i];
- event_size = sizeof(struct inotify_event) + event->len;
- g_queue_push_tail (events_to_process, ik_event_internal_new (ik_event_new (&buffer[buffer_i])));
- buffer_i += event_size;
- events++;
- }
-
- /* If the event process callback is off, turn it back on */
- if (!process_eq_running && events)
- {
- process_eq_running = TRUE;
- g_timeout_add (PROCESS_EVENTS_TIME, ik_process_eq_callback, NULL);
- }
-
- G_UNLOCK (inotify_lock);
-
- return TRUE;
-}
-
-static gboolean
-g_timeval_lt (GTimeVal *val1, GTimeVal *val2)
-{
- if (val1->tv_sec < val2->tv_sec)
- return TRUE;
-
- if (val1->tv_sec > val2->tv_sec)
- return FALSE;
-
- /* val1->tv_sec == val2->tv_sec */
- if (val1->tv_usec < val2->tv_usec)
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-g_timeval_eq (GTimeVal *val1, GTimeVal *val2)
-{
- return (val1->tv_sec == val2->tv_sec) && (val1->tv_usec == val2->tv_usec);
-}
-
-static void
-ik_pair_events (ik_event_internal_t *event1, ik_event_internal_t *event2)
-{
- g_assert (event1 && event2);
- /* We should only be pairing events that have the same cookie */
- g_assert (event1->event->cookie == event2->event->cookie);
- /* We shouldn't pair an event that already is paired */
- g_assert (event1->pair == NULL && event2->pair == NULL);
-
- /* Pair the internal structures and the ik_event_t structures */
- event1->pair = event2;
- event1->event->pair = event2->event;
-
- if (g_timeval_lt (&event1->hold_until, &event2->hold_until))
- event1->hold_until = event2->hold_until;
-
- event2->hold_until = event1->hold_until;
-}
-
-static void
-ik_event_add_microseconds (ik_event_internal_t *event, glong ms)
-{
- g_assert (event);
- g_time_val_add (&event->hold_until, ms);
-}
-
-static gboolean
-ik_event_ready (ik_event_internal_t *event)
-{
- GTimeVal tv;
- g_assert (event);
-
- g_get_current_time (&tv);
-
- /* An event is ready if,
- *
- * it has no cookie -- there is nothing to be gained by holding it
- * or, it is already paired -- we don't need to hold it anymore
- * or, we have held it long enough
- */
- return
- event->event->cookie == 0 ||
- event->pair != NULL ||
- g_timeval_lt (&event->hold_until, &tv) ||
- g_timeval_eq (&event->hold_until, &tv);
-}
-
-static void
-ik_pair_moves (gpointer data, gpointer user_data)
-{
- ik_event_internal_t *event = (ik_event_internal_t *)data;
-
- if (event->seen == TRUE || event->sent == TRUE)
- return;
-
- if (event->event->cookie != 0)
- {
- /* When we get a MOVED_FROM event we delay sending the event by
- * MOVE_HOLD_UNTIL_TIME microseconds. We need to do this because a
- * MOVED_TO pair _might_ be coming in the near future */
- if (event->event->mask & IN_MOVED_FROM)
- {
- g_hash_table_insert (cookie_hash, GINT_TO_POINTER (event->event->cookie), event);
- /* because we don't deliver move events there is no point in waiting for the match right now. */
- ik_event_add_microseconds (event, MOVE_HOLD_UNTIL_TIME);
- }
- else if (event->event->mask & IN_MOVED_TO)
- {
- /* We need to check if we are waiting for this MOVED_TO events cookie to pair it with
- * a MOVED_FROM */
- ik_event_internal_t *match = NULL;
- match = g_hash_table_lookup (cookie_hash, GINT_TO_POINTER (event->event->cookie));
- if (match)
- {
- g_hash_table_remove (cookie_hash, GINT_TO_POINTER (event->event->cookie));
- ik_pair_events (match, event);
- }
- }
- }
- event->seen = TRUE;
-}
-
-static void
-ik_process_events ()
-{
- g_queue_foreach (events_to_process, ik_pair_moves, NULL);
-
- while (!g_queue_is_empty (events_to_process))
- {
- ik_event_internal_t *event = g_queue_peek_head (events_to_process);
-
- /* This must have been sent as part of a MOVED_TO/MOVED_FROM */
- if (event->sent)
- {
- /* Pop event */
- g_queue_pop_head (events_to_process);
- /* Free the internal event structure */
- g_free (event);
- continue;
- }
-
- /* The event isn't ready yet */
- if (!ik_event_ready (event))
- break;
-
- /* Pop it */
- event = g_queue_pop_head (events_to_process);
-
- /* Check if this is a MOVED_FROM that is also sitting in the cookie_hash */
- if (event->event->cookie && event->pair == NULL &&
- g_hash_table_lookup (cookie_hash, GINT_TO_POINTER (event->event->cookie)))
- g_hash_table_remove (cookie_hash, GINT_TO_POINTER (event->event->cookie));
-
- if (event->pair)
- {
- /* We send out paired MOVED_FROM/MOVED_TO events in the same event buffer */
- /* g_assert (event->event->mask == IN_MOVED_FROM && event->pair->event->mask == IN_MOVED_TO); */
- /* Copy the paired data */
- event->pair->sent = TRUE;
- event->sent = TRUE;
- ik_move_matches++;
- }
- else if (event->event->cookie)
- {
- /* If we couldn't pair a MOVED_FROM and MOVED_TO together, we change
- * the event masks */
- /* Changeing MOVED_FROM to DELETE and MOVED_TO to create lets us make
- * the gaurantee that you will never see a non-matched MOVE event */
-
- if (event->event->mask & IN_MOVED_FROM)
- {
- event->event->mask = IN_DELETE|(event->event->mask & IN_ISDIR);
- ik_move_misses++; /* not super accurate, if we aren't watching the destination it still counts as a miss */
- }
- if (event->event->mask & IN_MOVED_TO)
- event->event->mask = IN_CREATE|(event->event->mask & IN_ISDIR);
- }
-
- /* Push the ik_event_t onto the event queue */
- g_queue_push_tail (event_queue, event->event);
- /* Free the internal event structure */
- g_free (event);
- }
-}
-
-static gboolean
-ik_process_eq_callback (gpointer user_data)
-{
- gboolean res;
-
- /* Try and move as many events to the event queue */
- G_LOCK (inotify_lock);
- ik_process_events ();
-
- while (!g_queue_is_empty (event_queue))
- {
- ik_event_t *event = g_queue_pop_head (event_queue);
-
- user_cb (event);
- }
-
- res = TRUE;
-
- if (g_queue_get_length (events_to_process) == 0)
- {
- process_eq_running = FALSE;
- res = FALSE;
- }
-
- G_UNLOCK (inotify_lock);
-
- return res;
-}
diff --git a/gio/inotify/inotify-kernel.h b/gio/inotify/inotify-kernel.h
deleted file mode 100644
index b406d71d..00000000
--- a/gio/inotify/inotify-kernel.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (C) 2005 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:.
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#ifndef __INOTIFY_KERNEL_H
-#define __INOTIFY_KERNEL_H
-
-typedef struct ik_event_s {
- gint32 wd;
- guint32 mask;
- guint32 cookie;
- guint32 len;
- char * name;
- struct ik_event_s *pair;
-} ik_event_t;
-
-gboolean _ik_startup (void (*cb) (ik_event_t *event));
-
-ik_event_t *_ik_event_new_dummy (const char *name,
- gint32 wd,
- guint32 mask);
-void _ik_event_free (ik_event_t *event);
-
-gint32 _ik_watch (const char *path,
- guint32 mask,
- int *err);
-int _ik_ignore (const char *path,
- gint32 wd);
-
-
-/* The miss count will probably be enflated */
-void _ik_move_stats (guint32 *matches,
- guint32 *misses);
-const char *_ik_mask_to_string (guint32 mask);
-
-
-#endif
diff --git a/gio/inotify/inotify-missing.c b/gio/inotify/inotify-missing.c
deleted file mode 100644
index 96126b3c..00000000
--- a/gio/inotify/inotify-missing.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
-
-/* inotify-helper.c - Gnome VFS Monitor based on inotify.
-
- Copyright (C) 2005 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#include "config.h"
-#include <glib.h>
-#include "inotify-missing.h"
-#include "inotify-path.h"
-
-#define SCAN_MISSING_TIME 4000 /* 1/4 Hz */
-
-static gboolean im_debug_enabled = FALSE;
-#define IM_W if (im_debug_enabled) g_warning
-
-/* We put inotify_sub's that are missing on this list */
-static GList *missing_sub_list = NULL;
-static gboolean im_scan_missing (gpointer user_data);
-static gboolean scan_missing_running = FALSE;
-static void (*missing_cb)(inotify_sub *sub) = NULL;
-
-G_LOCK_EXTERN (inotify_lock);
-
-/* inotify_lock must be held before calling */
-void
-_im_startup (void (*callback)(inotify_sub *sub))
-{
- static gboolean initialized = FALSE;
-
- if (!initialized)
- {
- missing_cb = callback;
- initialized = TRUE;
- }
-}
-
-/* inotify_lock must be held before calling */
-void
-_im_add (inotify_sub *sub)
-{
- if (g_list_find (missing_sub_list, sub))
- {
- IM_W ("asked to add %s to missing list but it's already on the list!\n", sub->dirname);
- return;
- }
-
- IM_W ("adding %s to missing list\n", sub->dirname);
- missing_sub_list = g_list_prepend (missing_sub_list, sub);
-
- /* If the timeout is turned off, we turn it back on */
- if (!scan_missing_running)
- {
- scan_missing_running = TRUE;
- g_timeout_add (SCAN_MISSING_TIME, im_scan_missing, NULL);
- }
-}
-
-/* inotify_lock must be held before calling */
-void
-_im_rm (inotify_sub *sub)
-{
- GList *link;
-
- link = g_list_find (missing_sub_list, sub);
-
- if (!link)
- {
- IM_W ("asked to remove %s from missing list but it isn't on the list!\n", sub->dirname);
- return;
- }
-
- IM_W ("removing %s from missing list\n", sub->dirname);
-
- missing_sub_list = g_list_remove_link (missing_sub_list, link);
- g_list_free_1 (link);
-}
-
-/* Scans the list of missing subscriptions checking if they
- * are available yet.
- */
-static gboolean
-im_scan_missing (gpointer user_data)
-{
- GList *nolonger_missing = NULL;
- GList *l;
-
- G_LOCK (inotify_lock);
-
- IM_W ("scanning missing list with %d items\n", g_list_length (missing_sub_list));
- for (l = missing_sub_list; l; l = l->next)
- {
- inotify_sub *sub = l->data;
- gboolean not_m = FALSE;
-
- IM_W ("checking %p\n", sub);
- g_assert (sub);
- g_assert (sub->dirname);
- not_m = _ip_start_watching (sub);
-
- if (not_m)
- {
- missing_cb (sub);
- IM_W ("removed %s from missing list\n", sub->dirname);
- /* We have to build a list of list nodes to remove from the
- * missing_sub_list. We do the removal outside of this loop.
- */
- nolonger_missing = g_list_prepend (nolonger_missing, l);
- }
- }
-
- for (l = nolonger_missing; l ; l = l->next)
- {
- GList *llink = l->data;
- missing_sub_list = g_list_remove_link (missing_sub_list, llink);
- g_list_free_1 (llink);
- }
-
- g_list_free (nolonger_missing);
-
- /* If the missing list is now empty, we disable the timeout */
- if (missing_sub_list == NULL)
- {
- scan_missing_running = FALSE;
- G_UNLOCK (inotify_lock);
- return FALSE;
- }
- else
- {
- G_UNLOCK (inotify_lock);
- return TRUE;
- }
-}
-
-
-/* inotify_lock must be held */
-void
-_im_diag_dump (GIOChannel *ioc)
-{
- GList *l;
- g_io_channel_write_chars (ioc, "missing list:\n", -1, NULL, NULL);
- for (l = missing_sub_list; l; l = l->next)
- {
- inotify_sub *sub = l->data;
- g_io_channel_write_chars (ioc, sub->dirname, -1, NULL, NULL);
- g_io_channel_write_chars (ioc, "\n", -1, NULL, NULL);
- }
-}
diff --git a/gio/inotify/inotify-missing.h b/gio/inotify/inotify-missing.h
deleted file mode 100644
index b67b5952..00000000
--- a/gio/inotify/inotify-missing.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* inotify-helper.h - GNOME VFS Monitor using inotify
-
- Copyright (C) 2006 John McCutchan <john@johnmccutchan.com>
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: John McCutchan <ttb@tentacle.dhs.org>
-*/
-
-
-#ifndef __INOTIFY_MISSING_H
-#define __INOTIFY_MISSING_H
-
-#include "inotify-sub.h"
-
-void _im_startup (void (*missing_cb)(inotify_sub *sub));
-void _im_add (inotify_sub *sub);
-void _im_rm (inotify_sub *sub);
-void _im_diag_dump (GIOChannel *ioc);
-
-
-#endif /* __INOTIFY_MISSING_H */
diff --git a/gio/inotify/inotify-path.c b/gio/inotify/inotify-path.c
deleted file mode 100644
index b78768de..00000000
--- a/gio/inotify/inotify-path.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
-
-/* inotify-path.c - GVFS Directory Monitor based on inotify.
-
- Copyright (C) 2006 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#include "config.h"
-
-/* Don't put conflicting kernel types in the global namespace: */
-#define __KERNEL_STRICT_NAMES
-
-#include "local_inotify.h"
-#if 0
-#ifdef HAVE_SYS_INOTIFY_H
-/* We don't actually include the libc header, because there has been
- * problems with libc versions that was built without inotify support.
- * Instead we use the local version.
- */
-#include "local_inotify.h"
-#elif defined (HAVE_LINUX_INOTIFY_H)
-#include <linux/inotify.h>
-#endif
-#endif
-#include <string.h>
-#include <glib.h>
-#include "inotify-kernel.h"
-#include "inotify-path.h"
-#include "inotify-missing.h"
-
-#define IP_INOTIFY_MASK (IN_MODIFY|IN_ATTRIB|IN_MOVED_FROM|IN_MOVED_TO|IN_DELETE|IN_CREATE|IN_DELETE_SELF|IN_UNMOUNT|IN_MOVE_SELF|IN_CLOSE_WRITE)
-
-typedef struct ip_watched_dir_s {
- char *path;
- /* TODO: We need to maintain a tree of watched directories
- * so that we can deliver move/delete events to sub folders.
- * Or the application could do it...
- */
- struct ip_watched_dir_s* parent;
- GList* children;
-
- /* Inotify state */
- gint32 wd;
-
- /* List of inotify subscriptions */
- GList *subs;
-} ip_watched_dir_t;
-
-static gboolean ip_debug_enabled = FALSE;
-#define IP_W if (ip_debug_enabled) g_warning
-
-/* path -> ip_watched_dir */
-static GHashTable * path_dir_hash = NULL;
-/* inotify_sub * -> ip_watched_dir *
- *
- * Each subscription is attached to a watched directory or it is on
- * the missing list
- */
-static GHashTable * sub_dir_hash = NULL;
-/* This hash holds GLists of ip_watched_dir_t *'s
- * We need to hold a list because symbolic links can share
- * the same wd
- */
-static GHashTable * wd_dir_hash = NULL;
-
-static ip_watched_dir_t *ip_watched_dir_new (const char *path,
- int wd);
-static void ip_watched_dir_free (ip_watched_dir_t *dir);
-static void ip_event_callback (ik_event_t *event);
-
-
-static void (*event_callback)(ik_event_t *event, inotify_sub *sub);
-
-gboolean
-_ip_startup (void (*cb)(ik_event_t *event, inotify_sub *sub))
-{
- static gboolean initialized = FALSE;
- static gboolean result = FALSE;
-
- if (initialized == TRUE)
- return result;
-
- event_callback = cb;
- result = _ik_startup (ip_event_callback);
-
- if (!result)
- return FALSE;
-
- path_dir_hash = g_hash_table_new (g_str_hash, g_str_equal);
- sub_dir_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
- wd_dir_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
-
- initialized = TRUE;
- return TRUE;
-}
-
-static void
-ip_map_path_dir (const char *path, ip_watched_dir_t *dir)
-{
- g_assert (path && dir);
- g_hash_table_insert (path_dir_hash, dir->path, dir);
-}
-
-static void
-ip_map_sub_dir (inotify_sub *sub, ip_watched_dir_t *dir)
-{
- /* Associate subscription and directory */
- g_assert (dir && sub);
- g_hash_table_insert (sub_dir_hash, sub, dir);
- dir->subs = g_list_prepend (dir->subs, sub);
-}
-
-static void
-ip_map_wd_dir (gint32 wd, ip_watched_dir_t *dir)
-{
- GList *dir_list;
-
- g_assert (wd >= 0 && dir);
- dir_list = g_hash_table_lookup (wd_dir_hash, GINT_TO_POINTER (wd));
- dir_list = g_list_prepend (dir_list, dir);
- g_hash_table_replace (wd_dir_hash, GINT_TO_POINTER (dir->wd), dir_list);
-}
-
-gboolean
-_ip_start_watching (inotify_sub *sub)
-{
- gint32 wd;
- int err;
- ip_watched_dir_t *dir;
-
- g_assert (sub);
- g_assert (!sub->cancelled);
- g_assert (sub->dirname);
-
- IP_W ("Starting to watch %s\n", sub->dirname);
- dir = g_hash_table_lookup (path_dir_hash, sub->dirname);
- if (dir)
- {
- IP_W ("Already watching\n");
- goto out;
- }
-
- IP_W ("Trying to add inotify watch ");
- wd = _ik_watch (sub->dirname, IP_INOTIFY_MASK|IN_ONLYDIR, &err);
- if (wd < 0)
- {
- IP_W("Failed\n");
- return FALSE;
- }
- else
- {
- /* Create new watched directory and associate it with the
- * wd hash and path hash
- */
- IP_W ("Success\n");
- dir = ip_watched_dir_new (sub->dirname, wd);
- ip_map_wd_dir (wd, dir);
- ip_map_path_dir (sub->dirname, dir);
- }
-
- out:
- ip_map_sub_dir (sub, dir);
-
- return TRUE;
-}
-
-static void
-ip_unmap_path_dir (const char *path, ip_watched_dir_t *dir)
-{
- g_assert (path && dir);
- g_hash_table_remove (path_dir_hash, dir->path);
-}
-
-static void
-ip_unmap_wd_dir (gint32 wd, ip_watched_dir_t *dir)
-{
- GList *dir_list = g_hash_table_lookup (wd_dir_hash, GINT_TO_POINTER (wd));
-
- if (!dir_list)
- return;
-
- g_assert (wd >= 0 && dir);
- dir_list = g_list_remove (dir_list, dir);
- if (dir_list == NULL)
- g_hash_table_remove (wd_dir_hash, GINT_TO_POINTER (dir->wd));
- else
- g_hash_table_replace (wd_dir_hash, GINT_TO_POINTER (dir->wd), dir_list);
-}
-
-static void
-ip_unmap_wd (gint32 wd)
-{
- GList *dir_list = g_hash_table_lookup (wd_dir_hash, GINT_TO_POINTER (wd));
- if (!dir_list)
- return;
- g_assert (wd >= 0);
- g_hash_table_remove (wd_dir_hash, GINT_TO_POINTER (wd));
- g_list_free (dir_list);
-}
-
-static void
-ip_unmap_sub_dir (inotify_sub *sub, ip_watched_dir_t *dir)
-{
- g_assert (sub && dir);
- g_hash_table_remove (sub_dir_hash, sub);
- dir->subs = g_list_remove (dir->subs, sub);
-}
-
-static void
-ip_unmap_all_subs (ip_watched_dir_t *dir)
-{
- GList *l = NULL;
-
- for (l = dir->subs; l; l = l->next)
- {
- inotify_sub *sub = l->data;
- g_hash_table_remove (sub_dir_hash, sub);
- }
- g_list_free (dir->subs);
- dir->subs = NULL;
-}
-
-gboolean
-_ip_stop_watching (inotify_sub *sub)
-{
- ip_watched_dir_t *dir = NULL;
-
- dir = g_hash_table_lookup (sub_dir_hash, sub);
- if (!dir)
- return TRUE;
-
- ip_unmap_sub_dir (sub, dir);
-
- /* No one is subscribing to this directory any more */
- if (dir->subs == NULL)
- {
- _ik_ignore (dir->path, dir->wd);
- ip_unmap_wd_dir (dir->wd, dir);
- ip_unmap_path_dir (dir->path, dir);
- ip_watched_dir_free (dir);
- }
-
- return TRUE;
-}
-
-
-static ip_watched_dir_t *
-ip_watched_dir_new (const char *path, gint32 wd)
-{
- ip_watched_dir_t *dir = g_new0 (ip_watched_dir_t, 1);
-
- dir->path = g_strdup (path);
- dir->wd = wd;
-
- return dir;
-}
-
-static void
-ip_watched_dir_free (ip_watched_dir_t * dir)
-{
- g_assert (dir->subs == NULL);
- g_free (dir->path);
- g_free (dir);
-}
-
-static void
-ip_wd_delete (gpointer data, gpointer user_data)
-{
- ip_watched_dir_t *dir = data;
- GList *l = NULL;
-
- for (l = dir->subs; l; l = l->next)
- {
- inotify_sub *sub = l->data;
- /* Add subscription to missing list */
- _im_add (sub);
- }
- ip_unmap_all_subs (dir);
- /* Unassociate the path and the directory */
- ip_unmap_path_dir (dir->path, dir);
- ip_watched_dir_free (dir);
-}
-
-static void
-ip_event_dispatch (GList *dir_list, GList* pair_dir_list, ik_event_t *event)
-{
- GList *dirl;
-
- if (!event)
- return;
-
- for (dirl = dir_list; dirl; dirl = dirl->next)
- {
- GList *subl;
- ip_watched_dir_t *dir = dirl->data;
-
- for (subl = dir->subs; subl; subl = subl->next)
- {
- inotify_sub *sub = subl->data;
-
- /* If the subscription and the event
- * contain a filename and they don't
- * match, we don't deliver this event.
- */
- if (sub->filename &&
- event->name &&
- strcmp (sub->filename, event->name))
- continue;
-
- /* If the subscription has a filename
- * but this event doesn't, we don't
- * deliever this event.
- */
- if (sub->filename && !event->name)
- continue;
-
- /* FIXME: We might need to synthesize
- * DELETE/UNMOUNT events when
- * the filename doesn't match
- */
-
- event_callback (event, sub);
- }
- }
-
- if (!event->pair)
- return;
-
- for (dirl = pair_dir_list; dirl; dirl = dirl->next)
- {
- GList *subl;
- ip_watched_dir_t *dir = dirl->data;
-
- for (subl = dir->subs; subl; subl = subl->next)
- {
- inotify_sub *sub = subl->data;
-
- /* If the subscription and the event
- * contain a filename and they don't
- * match, we don't deliver this event.
- */
- if (sub->filename &&
- event->pair->name &&
- strcmp (sub->filename, event->pair->name))
- continue;
-
- /* If the subscription has a filename
- * but this event doesn't, we don't
- * deliever this event.
- */
- if (sub->filename && !event->pair->name)
- continue;
-
- /* FIXME: We might need to synthesize
- * DELETE/UNMOUNT events when
- * the filename doesn't match
- */
-
- event_callback (event->pair, sub);
- }
- }
-}
-
-static void
-ip_event_callback (ik_event_t *event)
-{
- GList* dir_list = NULL;
- GList* pair_dir_list = NULL;
-
- dir_list = g_hash_table_lookup (wd_dir_hash, GINT_TO_POINTER (event->wd));
-
- /* We can ignore the IGNORED events */
- if (event->mask & IN_IGNORED)
- {
- _ik_event_free (event);
- return;
- }
-
- if (event->pair)
- pair_dir_list = g_hash_table_lookup (wd_dir_hash, GINT_TO_POINTER (event->pair->wd));
-
- if (event->mask & IP_INOTIFY_MASK)
- ip_event_dispatch (dir_list, pair_dir_list, event);
-
- /* We have to manage the missing list
- * when we get an event that means the
- * file has been deleted/moved/unmounted.
- */
- if (event->mask & IN_DELETE_SELF ||
- event->mask & IN_MOVE_SELF ||
- event->mask & IN_UNMOUNT)
- {
- /* Add all subscriptions to missing list */
- g_list_foreach (dir_list, ip_wd_delete, NULL);
- /* Unmap all directories attached to this wd */
- ip_unmap_wd (event->wd);
- }
-
- _ik_event_free (event);
-}
diff --git a/gio/inotify/inotify-path.h b/gio/inotify/inotify-path.h
deleted file mode 100644
index c613b9f8..00000000
--- a/gio/inotify/inotify-path.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Copyright (C) 2005 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:.
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#ifndef __INOTIFY_PATH_H
-#define __INOTIFY_PATH_H
-
-#include "inotify-kernel.h"
-#include "inotify-sub.h"
-
-gboolean _ip_startup (void (*event_cb)(ik_event_t *event, inotify_sub *sub));
-gboolean _ip_start_watching (inotify_sub *sub);
-gboolean _ip_stop_watching (inotify_sub *sub);
-
-#endif
diff --git a/gio/inotify/inotify-sub.c b/gio/inotify/inotify-sub.c
deleted file mode 100644
index 49628655..00000000
--- a/gio/inotify/inotify-sub.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
-
-/* inotify-sub.c - GMonitor based on inotify.
-
- Copyright (C) 2006 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors:
- John McCutchan <john@johnmccutchan.com>
-*/
-
-#include "config.h"
-#include <string.h>
-#include <glib.h>
-
-#include "inotify-sub.h"
-
-static gboolean is_debug_enabled = FALSE;
-#define IS_W if (is_debug_enabled) g_warning
-
-static gchar*
-dup_dirname(const gchar* dirname)
-{
- gchar* d_dirname = g_strdup (dirname);
- size_t len = strlen (d_dirname);
-
- if (d_dirname[len] == '/')
- d_dirname[len] = '\0';
-
- return d_dirname;
-}
-
-inotify_sub*
-_ih_sub_new (const gchar* dirname, const gchar* filename, gpointer user_data)
-{
- inotify_sub* sub = NULL;
-
- sub = g_new0 (inotify_sub, 1);
- sub->dirname = dup_dirname (dirname);
- sub->filename = g_strdup (filename);
- sub->user_data = user_data;
-
- IS_W ("new subscription for %s being setup\n", sub->dirname);
-
- return sub;
-}
-
-void
-_ih_sub_free (inotify_sub* sub)
-{
- if (sub->dirname)
- g_free (sub->dirname);
- if (sub->filename)
- g_free (sub->filename);
- g_free (sub);
-}
diff --git a/gio/inotify/inotify-sub.h b/gio/inotify/inotify-sub.h
deleted file mode 100644
index 36561e74..00000000
--- a/gio/inotify/inotify-sub.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* inotify-sub.h - GVFS Directory Monitor using inotify
-
- Copyright (C) 2006 John McCutchan
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: John McCutchan <john@johnmccutchan.com>
-*/
-
-
-#ifndef __INOTIFY_SUB_H
-#define __INOTIFY_SUB_H
-
-typedef struct
-{
- gchar* dirname;
- gchar* filename;
- gboolean cancelled;
- gpointer user_data;
-} inotify_sub;
-
-inotify_sub* _ih_sub_new (const gchar* dirname, const gchar* filename, gpointer user_data);
-void _ih_sub_free (inotify_sub* sub);
-
-#endif /* __INOTIFY_SUB_H */
diff --git a/gio/inotify/local_inotify.h b/gio/inotify/local_inotify.h
deleted file mode 100644
index 267c88b5..00000000
--- a/gio/inotify/local_inotify.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Inode based directory notification for Linux
- *
- * Copyright (C) 2005 John McCutchan
- */
-
-#ifndef _LINUX_INOTIFY_H
-#define _LINUX_INOTIFY_H
-
-#include <linux/types.h>
-
-/*
- * struct inotify_event - structure read from the inotify device for each event
- *
- * When you are watching a directory, you will receive the filename for events
- * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
- */
-struct inotify_event {
- __s32 wd; /* watch descriptor */
- __u32 mask; /* watch mask */
- __u32 cookie; /* cookie to synchronize two events */
- __u32 len; /* length (including nulls) of name */
- char name[0]; /* stub for possible name */
-};
-
-/* the following are legal, implemented events that user-space can watch for */
-#define IN_ACCESS 0x00000001 /* File was accessed */
-#define IN_MODIFY 0x00000002 /* File was modified */
-#define IN_ATTRIB 0x00000004 /* Metadata changed */
-#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
-#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
-#define IN_OPEN 0x00000020 /* File was opened */
-#define IN_MOVED_FROM 0x00000040 /* File was moved from X */
-#define IN_MOVED_TO 0x00000080 /* File was moved to Y */
-#define IN_CREATE 0x00000100 /* Subfile was created */
-#define IN_DELETE 0x00000200 /* Subfile was deleted */
-#define IN_DELETE_SELF 0x00000400 /* Self was deleted */
-#define IN_MOVE_SELF 0x00000800 /* Self was moved */
-
-/* the following are legal events. they are sent as needed to any watch */
-#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */
-#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
-#define IN_IGNORED 0x00008000 /* File was ignored */
-
-/* helper events */
-#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
-#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
-
-/* special flags */
-#define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */
-#define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */
-#define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */
-#define IN_ISDIR 0x40000000 /* event occurred against dir */
-#define IN_ONESHOT 0x80000000 /* only send event once */
-
-/*
- * All of the events - we build the list by hand so that we can add flags in
- * the future and not break backward compatibility. Apps will get only the
- * events that they originally wanted. Be sure to add new events here!
- */
-#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
- IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
- IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
- IN_MOVE_SELF)
-
-#ifdef __KERNEL__
-
-#include <linux/dcache.h>
-#include <linux/fs.h>
-#include <linux/config.h>
-
-#ifdef CONFIG_INOTIFY
-
-extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
- const char *);
-extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
- const char *);
-extern void inotify_unmount_inodes(struct list_head *);
-extern void inotify_inode_is_dead(struct inode *);
-extern u32 inotify_get_cookie(void);
-
-#else
-
-static inline void inotify_inode_queue_event(struct inode *inode,
- __u32 mask, __u32 cookie,
- const char *filename)
-{
-}
-
-static inline void inotify_dentry_parent_queue_event(struct dentry *dentry,
- __u32 mask, __u32 cookie,
- const char *filename)
-{
-}
-
-static inline void inotify_unmount_inodes(struct list_head *list)
-{
-}
-
-static inline void inotify_inode_is_dead(struct inode *inode)
-{
-}
-
-static inline u32 inotify_get_cookie(void)
-{
- return 0;
-}
-
-#endif /* CONFIG_INOTIFY */
-
-#endif /* __KERNEL __ */
-
-#endif /* _LINUX_INOTIFY_H */
diff --git a/gio/inotify/local_inotify_syscalls.h b/gio/inotify/local_inotify_syscalls.h
deleted file mode 100644
index 1821acce..00000000
--- a/gio/inotify/local_inotify_syscalls.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef _LINUX_INOTIFY_SYSCALLS_H
-#define _LINUX_INOTIFY_SYSCALLS_H
-
-#include <asm/types.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
-#if defined(__i386__)
-# define __NR_inotify_init 291
-# define __NR_inotify_add_watch 292
-# define __NR_inotify_rm_watch 293
-#elif defined(__x86_64__)
-# define __NR_inotify_init 253
-# define __NR_inotify_add_watch 254
-# define __NR_inotify_rm_watch 255
-#elif defined(__alpha__)
-# define __NR_inotify_init 444
-# define __NR_inotify_add_watch 445
-# define __NR_inotify_rm_watch 446
-#elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
-# define __NR_inotify_init 275
-# define __NR_inotify_add_watch 276
-# define __NR_inotify_rm_watch 277
-#elif defined(__sparc__) || defined (__sparc64__)
-# define __NR_inotify_init 151
-# define __NR_inotify_add_watch 152
-# define __NR_inotify_rm_watch 156
-#elif defined (__ia64__)
-# define __NR_inotify_init 1277
-# define __NR_inotify_add_watch 1278
-# define __NR_inotify_rm_watch 1279
-#elif defined (__s390__) || defined (__s390x__)
-# define __NR_inotify_init 284
-# define __NR_inotify_add_watch 285
-# define __NR_inotify_rm_watch 286
-#elif defined (__arm__)
-# define __NR_inotify_init 316
-# define __NR_inotify_add_watch 317
-# define __NR_inotify_rm_watch 318
-#elif defined (__SH4__)
-# define __NR_inotify_init 290
-# define __NR_inotify_add_watch 291
-# define __NR_inotify_rm_watch 292
-#elif defined (__SH5__)
-# define __NR_inotify_init 318
-# define __NR_inotify_add_watch 319
-# define __NR_inotify_rm_watch 320
-#else
-# warning "Unsupported architecture"
-#endif
-
-#if defined(__i386__) || defined(__x86_64) || defined(__alpha__) || defined(__ppc__) || defined(__sparc__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || defined(__s390__)
-static inline int inotify_init (void)
-{
- return syscall (__NR_inotify_init);
-}
-
-static inline int inotify_add_watch (int fd, const char *name, __u32 mask)
-{
- return syscall (__NR_inotify_add_watch, fd, name, mask);
-}
-
-static inline int inotify_rm_watch (int fd, __u32 wd)
-{
- return syscall (__NR_inotify_rm_watch, fd, wd);
-}
-#else
-static inline int inotify_init (void)
-{
- return -1;
-}
-
-static inline int inotify_add_watch (int fd, const char *name, __u32 mask)
-{
- return -1;
-}
-
-static inline int inotify_rm_watch (int fd, __u32 wd)
-{
- return -1;
-}
-
-#endif
-
-#endif /* _LINUX_INOTIFY_SYSCALLS_H */
diff --git a/gio/test-gio.c b/gio/test-gio.c
deleted file mode 100755
index 5d60d719..00000000
--- a/gio/test-gio.c
+++ /dev/null
@@ -1,595 +0,0 @@
-#include <string.h>
-#include <unistd.h>
-#include <locale.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <glib.h>
-#include "gfile.h"
-#include "gvolumemonitor.h"
-#include "gseekable.h"
-#include "glocalfileinputstream.h"
-#include "glocalfileoutputstream.h"
-#include "gsocketinputstream.h"
-#include "gappinfo.h"
-#include "gcontenttype.h"
-
-static gpointer
-cancel_thread (gpointer data)
-{
-#ifdef G_OS_WIN32
- _sleep (1);
-#else
- sleep (1);
-#endif
- g_print ("cancel_thread GO!\n");
- g_cancellable_cancel (G_CANCELLABLE (data));
- return NULL;
-}
-
-static void
-test_out ()
-{
- GOutputStream *out;
- GFile *file;
- char buffer[2345];
- char *ptr;
- char *str = "Test_String ";
- int str_len;
- int left;
- int i;
- gssize res;
- gboolean close_res;
- GError *error;
-
- str_len = strlen (str);
- for (i = 0; i < sizeof(buffer); i++) {
- buffer[i] = str[i%str_len];
- }
-
- g_print ("test_out\n");
-
- unlink ("/tmp/test");
-
- file = g_file_new_for_path ("/tmp/test");
- out = (GOutputStream *)g_file_create (file, NULL, NULL);
-
- left = sizeof(buffer);
- ptr = buffer;
-
- while (left > 0)
- {
- error = NULL;
- res = g_output_stream_write (out, ptr, MIN (left, 128), NULL, &error);
- g_print ("res = %"G_GSSIZE_FORMAT"\n", res);
-
- if (res == -1)
- {
- g_print ("error %d: %s\n", error->code, error->message);
- g_error_free (error);
- }
-
- if (res > 0)
- {
- left -= res;
- ptr += res;
- }
-
- if (res < 0)
- break;
- }
-
- close_res = g_output_stream_close (out, NULL, NULL);
- g_print ("close res: %d\n", close_res);
-}
-
-static void
-test_sync (char *uri, gboolean dump)
-{
- GInputStream *in;
- GFile *file;
- char buffer[1025];
- gssize res;
- gboolean close_res;
- GCancellable *c;
- GError *error;
-
- g_print ("> test_sync %s\n", uri);
-
- c = g_cancellable_new ();
-
- file = g_file_new_for_uri (uri);
- if (0) g_thread_create (cancel_thread, c, FALSE, NULL);
- error = NULL;
- in = (GInputStream *)g_file_read (file, c, &error);
- g_print ("input stream: %p\n", in);
- if (in == NULL)
- {
- g_print ("open error %d: %s\n", error->code, error->message);
- goto out;
- }
-
- while (1)
- {
- res = g_input_stream_read (in, buffer, 1024, c, NULL);
- if (dump)
- {
- if (res > 0)
- {
- buffer[res] = 0;
- g_print ("%s", buffer);
- }
- }
- else
- g_print ("res = %"G_GSSIZE_FORMAT"\n", res);
-
- if (res <= 0)
- break;
- }
-
- close_res = g_input_stream_close (in, c, NULL);
-
- if (!dump)
- g_print ("close res: %d\n", close_res);
-
- out:
- g_print ("< test_sync\n");
-}
-
-typedef struct {
- char *buffer;
- GCancellable *c;
-} AsyncData;
-
-static void
-close_done (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- AsyncData *data = user_data;
- GInputStream *stream = G_INPUT_STREAM (source_object);
- gboolean result;
- GError *error = NULL;
-
- result = g_input_stream_close_finish (stream, res, &error);
-
- g_print ("close result: %d\n", result);
- if (!result)
- {
- g_print ("Close error %d: %s\n", error->code, error->message);
- g_error_free (error);
- }
-
- g_object_unref (data->c);
- g_free (data);
-}
-
-static void
-read_done (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- AsyncData *data = user_data;
- GInputStream *stream = G_INPUT_STREAM (source_object);
- gssize count_read;
- GError *error = NULL;
-
- count_read = g_input_stream_read_finish (stream, res, &error);
-
- g_print ("count_read: %"G_GSSIZE_FORMAT"\n", count_read);
-
- if (count_read == -1)
- {
- g_print ("Error %d: %s\n", error->code, error->message);
- g_error_free (error);
- }
- else if (0)
- {
- data->buffer[count_read] = 0;
- g_print ("data:\n %s\n", data->buffer);
- }
-
- if (count_read > 0)
- {
- g_input_stream_read_async (stream, data->buffer, 1024, 0, data->c, read_done, data);
- //g_cancellable_cancel (data->c);
- }
- else
- g_input_stream_close_async (stream, 0, data->c, close_done, data);
-}
-
-static void
-test_async_open_callback (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GFile *file = G_FILE (source_object);
- GFileInputStream *stream;
- AsyncData *data = user_data;
- GError *error = NULL;
-
- stream = g_file_read_finish (file, res, &error);
- g_print ("test_async_open_callback: %p\n", stream);
-
- if (stream)
- g_input_stream_read_async (G_INPUT_STREAM (stream), data->buffer, 1024, 0, data->c, read_done, data);
- else
- g_print ("%s\n", error->message);
-}
-
-
-static void
-test_async (char *uri, gboolean dump)
-{
- GFile *file;
- AsyncData *data = g_new0 (AsyncData, 1);
-
- data->buffer = g_malloc (1025);
- data->c = g_cancellable_new ();
-
- file = g_file_new_for_uri (uri);
- g_file_read_async (file, 0, data->c, test_async_open_callback, data);
- if (0) g_thread_create (cancel_thread, data->c, FALSE, NULL);
-}
-
-static gboolean
-cancel_cancellable_cb (gpointer data)
-{
- GCancellable *cancellable = G_CANCELLABLE (data);
-
- g_cancellable_cancel (cancellable);
- g_object_unref (cancellable);
-
- return FALSE;
-}
-
-static void
-test_seek (void)
-{
- GInputStream *in;
- char buffer1[1025];
- char buffer2[1025];
- gssize res;
- gboolean close_res;
- GFile *file;
- GSeekable *seekable;
- GError *error;
- GCancellable *c;
-
- file = g_file_new_for_uri ("test:///etc/passwd");
-
- error = NULL;
- in = (GInputStream *)g_file_read (file, NULL, &error);
-
- if (in == NULL)
- {
- g_print ("Can't find test:///etc/passwd: %s\n", error->message);
- g_error_free (error);
- return;
- }
-
- seekable = G_SEEKABLE (in);
-
- g_print ("offset: %d\n", (int)g_seekable_tell (seekable));
-
- res = g_input_stream_read (in, buffer1, 1024, NULL, NULL);
- g_print ("read 1 res = %"G_GSSIZE_FORMAT"\n", res);
-
- g_print ("offset: %d\n", (int)g_seekable_tell (seekable));
-
- res = g_seekable_seek (seekable, 0, G_SEEK_SET, NULL, NULL);
- g_print ("seek res = %"G_GSSIZE_FORMAT"\n", res);
-
- c = g_cancellable_new ();
- if (0) g_thread_create (cancel_thread, c, FALSE, NULL);
- res = g_input_stream_read (in, buffer2, 1024, c, &error);
- g_print ("read 2 res = %"G_GSSIZE_FORMAT"\n", res);
- if (res == -1)
- g_print ("error: %s\n", error->message);
-
- g_object_unref (c);
-
- if (memcmp (buffer1, buffer2, 1024) != 0)
- g_print ("Buffers differ\n");
-
- close_res = g_input_stream_close (in, NULL, NULL);
- g_print ("close res: %d\n", close_res);
-}
-
-static void
-test_content_types (void)
-{
- GList *types, *l;
- char *type;
- char *desc;
- char *mime;
-
-#ifdef G_OS_WIN32
- g_print (".aiff is_a .aiff: %d\n", g_content_type_is_a (".aiff", ".aiff"));
- g_print (".aiff is_a .gif: %d\n", g_content_type_is_a (".aiff", ".gif"));
- g_print (".aiff is_a text: %d\n", g_content_type_is_a (".aiff", "text"));
- g_print (".aiff is_a audio: %d\n", g_content_type_is_a (".aiff", "audio"));
- g_print (".jpg is_a .jpeg: %d\n", g_content_type_is_a (".jpg", ".jpeg"));
-
- g_print (".aiff descr: %s\n", g_content_type_get_description (".aiff"));
- g_print (".gif descr: %s\n", g_content_type_get_description (".gif"));
- g_print (".jpeg descr: %s\n", g_content_type_get_description (".jpeg"));
-
- g_print (".aiff mimetype: %s\n", g_content_type_get_mime_type (".aiff"));
- g_print (".gif mimetype: %s\n", g_content_type_get_mime_type (".gif"));
- g_print (".jpeg mimetype: %s\n", g_content_type_get_mime_type (".jpeg"));
- g_print ("* mimetype: %s\n", g_content_type_get_mime_type ("*"));
- g_print ("image mimetype: %s\n", g_content_type_get_mime_type ("image"));
-#endif
-
- types = g_get_registered_content_types ();
-
- for (l = types; l != NULL; l = l->next)
- {
- type = l->data;
- desc = g_content_type_get_description (type);
- mime = g_content_type_get_mime_type (type);
- g_print ("type %s - %s (%s)\n", type, desc, mime);
- g_free (mime);
- g_free (type);
- g_free (desc);
- }
-
- g_list_free (types);
-}
-
-static gint
-compare_apps (gconstpointer _a,
- gconstpointer _b)
-{
- GAppInfo *a = (GAppInfo *)_a;
- GAppInfo *b = (GAppInfo *)_b;
- char *name_a;
- char *name_b;
- int res;
-
- name_a = g_app_info_get_name (a);
- name_b = g_app_info_get_name (b);
- res = g_utf8_collate (name_a, name_b);
- g_free (name_a);
- g_free (name_b);
- return res;
-}
-
-static void
-test_appinfo (void)
-{
- GAppInfo *info;
- GList *infos, *l;
- const char *test_type;
- GError *error = NULL;
-
-#ifdef G_OS_WIN32
- test_type = ".jpg";
-#else
- test_type = "text/html";
-#endif
-
- if (0)
- {
- info = g_app_info_create_from_commandline ("/usr/bin/ls -l",
- NULL, &error);
- if (info == NULL)
- g_print ("error: %s\n", error->message);
- else
- g_print ("new info - %p: %s\n", info, g_app_info_get_name (info));
-
- g_print ("setting as default for x-test/gio\n");
- if (!g_app_info_set_as_default_for_type (info, "x-test/gio", NULL))
- g_print ("Failed!");
- else
- {
- info = g_get_default_app_info_for_type ("x-test/gio");
- g_print ("default x-test/gio - %p: %s\n", info, g_app_info_get_name (info));
- }
- }
-
- info = g_get_default_app_info_for_type (test_type);
- g_print ("default app for %s: %s\n", test_type,
- info? g_app_info_get_name (info): "None");
-
- infos = g_get_all_app_info_for_type (test_type);
- g_print ("all %s app info: \n", test_type);
- for (l = infos; l != NULL; l = l->next)
- {
- info = l->data;
- g_print ("%p: %s\n", info, g_app_info_get_name (info));
- }
-
- infos = g_get_all_app_info ();
- g_print ("all app info: \n");
- infos = g_list_sort (infos, compare_apps);
-
- for (l = infos; l != NULL; l = l->next)
- {
- info = l->data;
- g_print ("%s%s\n", g_app_info_get_name (info),
- g_app_info_should_show (info, "GNOME")?"":" (hidden)");
- }
-}
-
-static void
-volume_mounted (GVolumeMonitor *volume_monitor,
- GVolume *v)
-{
- g_print ("Volume mounted %p: %s - %p\n", v,
- g_volume_get_name (v), g_volume_get_icon (v));
-}
-
-static void
-volume_pre_unmount (GVolumeMonitor *volume_monitor,
- GVolume *v)
-{
- g_print ("Volume_pre_unmount %p: %s - %p\n", v,
- g_volume_get_name (v), g_volume_get_icon (v));
-}
-
-static void
-volume_unmounted (GVolumeMonitor *volume_monitor,
- GVolume *v)
-{
- g_print ("Volume_unmounted %p: %s - %p\n", v,
- g_volume_get_name (v), g_volume_get_icon (v));
-}
-
-static void
-drive_connected (GVolumeMonitor *volume_monitor,
- GDrive *d)
-{
- g_print ("Drive connected %p: %s - %p\n", d,
- g_drive_get_name (d), g_drive_get_icon (d));
-}
-
-static void
-drive_disconnected (GVolumeMonitor *volume_monitor,
- GDrive *d)
-{
- g_print ("Drive disconnected %p: %s - %p\n", d,
- g_drive_get_name (d), g_drive_get_icon (d));
-}
-
-static void
-test_volumes (void)
-{
- GVolumeMonitor *monitor;
- GList *volumes, *drives, *l;
-
- monitor = g_get_volume_monitor ();
-
- g_print ("Drives: \n");
- drives = g_volume_monitor_get_connected_drives (monitor);
- for (l = drives; l != NULL; l = l->next)
- {
- GDrive *d = l->data;
-
- g_print ("Drive %p: %s - %p\n", d,
- g_drive_get_name (d), g_drive_get_icon (d));
- }
- g_list_foreach (drives, (GFunc)g_object_unref, NULL);
- g_list_free (drives);
-
- g_print ("Volumes: \n");
- volumes = g_volume_monitor_get_mounted_volumes (monitor);
- for (l = volumes; l != NULL; l = l->next)
- {
- GVolume *v = l->data;
-
- g_print ("Volume %p: %s - %p\n", v,
- g_volume_get_name (v), g_volume_get_icon (v));
- }
- g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
- g_list_free (volumes);
-
- g_signal_connect (monitor, "volume_mounted", (GCallback)volume_mounted, NULL);
- g_signal_connect (monitor, "volume_pre_unmount", (GCallback)volume_pre_unmount, NULL);
- g_signal_connect (monitor, "volume_unmounted", (GCallback)volume_unmounted, NULL);
- g_signal_connect (monitor, "drive_connected", (GCallback)drive_connected, NULL);
- g_signal_connect (monitor, "drive_disconnected", (GCallback)drive_disconnected, NULL);
-
- //g_object_unref (monitor);
-
-}
-
-static void
-get_contents_callback (GObject *obj,
- GAsyncResult *res,
- gpointer user_data)
-{
- GFile *file = G_FILE (obj);
- GError *error = NULL;
- gchar *contents;
- gsize length;
-
- if (!g_file_load_contents_finish (file, res, &contents, &length, &error))
- {
- g_print ("Error reading file: %s\n", error->message);
- g_error_free (error);
- return;
- }
-
- g_print ("Read %d bytes of data:\n%s\n", (int)length, contents);
- g_free (contents);
-}
-
-static void
-test_load_content (void)
-{
- GFile *file;
-
- file = g_file_new_for_path ("/etc/passwd");
- g_file_load_contents_async (file,
- NULL,
- get_contents_callback, NULL);
-}
-
-int
-main (int argc, char *argv[])
-{
- GFile *file;
- GMainLoop *loop;
-
- setlocale (LC_ALL, "");
-
- g_thread_init (NULL);
- g_type_init ();
-
- if (0)
- {
- test_content_types ();
- test_appinfo ();
- return 0;
- }
-
- if (0)
- test_seek ();
-
- loop = g_main_loop_new (NULL, FALSE);
-
- if (0)
- test_volumes ();
-
- if (0) {
- GInputStream *s;
- char *buffer;
- gssize res;
- GCancellable *c;
-
- buffer = g_malloc (1025);
-
- s = g_socket_input_stream_new (0, FALSE);
-
- if (1)
- {
- res = g_input_stream_read (s, buffer, 128, NULL, NULL);
- g_print ("res1: %"G_GSSIZE_FORMAT"\n", res);
- res = g_input_stream_read (s, buffer, 128, NULL, NULL);
- g_print ("res2: %"G_GSSIZE_FORMAT"\n", res);
- }
-
- c = g_cancellable_new ();
- g_input_stream_read_async (s, buffer, 128, 0, c, read_done, buffer);
- if (1) g_timeout_add (1000, cancel_cancellable_cb, g_object_ref (c));
- g_print ("main loop run\n");
- g_main_loop_run (loop);
- g_object_unref (c);
- g_print ("main loop quit\n");
- }
-
- file = g_file_new_for_path ("/tmp");
- if (0) test_sync ("test:///etc/passwd", FALSE);
- if (1) test_async ("test:///etc/passwd", TRUE);
- if (0) test_out ();
-
- if (0) test_load_content ();
-
-
- g_print ("Starting mainloop\n");
- g_main_loop_run (loop);
-
- return 0;
-}
diff --git a/gio/test-streams.c b/gio/test-streams.c
deleted file mode 100644
index d00a5ba5..00000000
--- a/gio/test-streams.c
+++ /dev/null
@@ -1,370 +0,0 @@
-#include <glib.h>
-#include <string.h>
-
-#include "gmemoryinputstream.h"
-#include "gmemoryoutputstream.h"
-#include "gbufferedinputstream.h"
-#include "gbufferedoutputstream.h"
-#include "gseekable.h"
-
-#include <stdlib.h>
-
-static const char *gmis_data = "Hab nun ach! Philosophie, Juristerei und Medizin";
-
-#define test_assert(expr) G_STMT_START{ \
- if G_LIKELY(expr) { } else \
- test_assert_warning (__FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #expr); }G_STMT_END
-
-static void
-test_assert_warning (const char *file,
- const int line,
- const char *pretty_function,
- const char *expression)
-{
- g_log ("test",
- G_LOG_LEVEL_ERROR,
- "line %d (%s): assertion failed: (%s)",
- line,
- pretty_function,
- expression);
-}
-
-
-
-static gboolean
-test_memory_input_stream ()
-{
- GInputStream *stream;
- char buf[100];
- goffset n;
- gsize nread;
- gboolean res;
-
- g_print ("Testing GMemoryInputStream...");
-
- stream = g_memory_input_stream_from_data (gmis_data,
- strlen (gmis_data));
-
- test_assert (stream != NULL);
-
- memset (buf, 0, sizeof (buf));
-
- n = g_input_stream_read (stream, buf, 3, NULL, NULL);
-
- test_assert (n == 3);
- test_assert (strcmp (buf, "Hab") == 0);
-
- n = g_input_stream_skip (stream, 4, NULL, NULL);
- test_assert (n == 4);
-
- nread = 0;
- res = g_input_stream_read_all (stream, buf, sizeof (buf), &nread, NULL, NULL);
-
- test_assert (res && nread == strlen (gmis_data) - 7);
- test_assert (strcmp (buf, gmis_data + 7) == 0);
-
- res = g_seekable_can_seek (G_SEEKABLE (stream));
- test_assert (res == TRUE);
-
- n = g_seekable_tell (G_SEEKABLE (stream));
- test_assert (n == strlen (gmis_data));
-
- res = g_seekable_seek (G_SEEKABLE (stream), -n, G_SEEK_CUR, NULL, NULL);
- test_assert (res == TRUE);
-
- n = g_seekable_tell (G_SEEKABLE (stream));
- test_assert (n == 0);
-
- res = g_seekable_seek (G_SEEKABLE (stream), 4, G_SEEK_SET, NULL, NULL);
- test_assert (res == TRUE);
-
- memset (buf, 0, sizeof (buf));
- n = g_input_stream_read (stream, buf, 3, NULL, NULL);
- test_assert (n == 3);
- test_assert (strcmp (buf, "nun") == 0);
-
- res = g_seekable_seek (G_SEEKABLE (stream), -1, G_SEEK_SET, NULL, NULL);
- test_assert (res == FALSE);
-
- res = g_seekable_seek (G_SEEKABLE (stream), 1, G_SEEK_END, NULL, NULL);
- test_assert (res == FALSE);
-
- res = g_seekable_seek (G_SEEKABLE (stream), 99, G_SEEK_CUR, NULL, NULL);
- test_assert (res == FALSE);
-
- res = g_seekable_seek (G_SEEKABLE (stream), -1, G_SEEK_END, NULL, NULL);
- test_assert (res == TRUE);
-
- memset (buf, 0, sizeof (buf));
- n = g_input_stream_read (stream, buf, 10, NULL, NULL);
- test_assert (n == 1);
- test_assert (strcmp (buf, "n") == 0);
-
- n = g_input_stream_read (stream, buf, 10, NULL, NULL);
- test_assert (n == 0);
-
- g_object_unref (stream);
-
- g_print ("DONE [OK]\n");
- return TRUE;
-}
-
-
-
-static gboolean
-test_memory_output_stream (gboolean use_own_array)
-{
- GOutputStream *stream;
- GByteArray *array = NULL;
- GByteArray *data;
- gsize n, len;
- gssize sn;
- goffset pos;
- gboolean res;
- GError *error = NULL;
- gsize gmis_len;
-
- g_print ("Testing GMemoryOutputStream (%s)...",
- use_own_array ? "external array" : "iternal array");
-
- gmis_len = strlen (gmis_data) + 1; //we want the \0
-
- if (use_own_array) {
- array = g_byte_array_new ();
- }
-
- stream = g_memory_output_stream_new (array);
-
- test_assert (stream != NULL);
- g_object_get (stream, "data", &data, NULL);
-
- if (use_own_array) {
- test_assert (data == array);
- } else {
- array = data;
- }
-
- len = 10;
-
- res = g_output_stream_write_all (stream,
- (void *) gmis_data,
- len,
- &n,
- NULL,
- NULL);
-
- test_assert (res == TRUE);
- test_assert (len == n);
- test_assert (memcmp (array->data, data->data, len) == 0);
- test_assert (memcmp (array->data, gmis_data, len) == 0);
-
- len = gmis_len - n;
-
- res = g_output_stream_write_all (stream,
- (void *) (gmis_data + n),
- len,
- &n,
- NULL,
- NULL);
-
- test_assert (res == TRUE);
- test_assert (len == n);
- test_assert (memcmp (array->data, data->data, gmis_len) == 0);
- test_assert (memcmp (array->data, gmis_data, gmis_len) == 0);
-
- //Test limits
- g_object_set (stream, "size-limit", gmis_len, NULL);
-
- n = g_output_stream_write (stream,
- (void *) gmis_data,
- 10,
- NULL,
- NULL);
-
- test_assert (n == -1);
- g_object_set (stream, "size-limit", 0, NULL);
-
-
- //Test seeking
- pos = g_seekable_tell (G_SEEKABLE (stream));
- test_assert (gmis_len == pos);
-
- len = strlen ("Medizin");
- res = g_seekable_seek (G_SEEKABLE (stream), -8, G_SEEK_CUR, NULL, &error);
-
- test_assert (res == TRUE);
- pos = g_seekable_tell (G_SEEKABLE (stream));
- test_assert (pos == gmis_len - (len + 1));
-
-
-
- sn = g_output_stream_write (stream,
- "Medizin",
- len,
- NULL,
- NULL);
-
- test_assert (len == sn);
- test_assert (g_str_equal (array->data, data->data));
- test_assert (g_str_equal (array->data, gmis_data));
-
-
- g_object_unref (stream);
-
- if (use_own_array) {
- g_byte_array_free (array, TRUE);
- }
-
- g_print ("DONE [OK]\n");
- return TRUE;
-}
-
-static gboolean
-test_buffered_input_stream ()
-{
- GInputStream *mem_stream;
- GInputStream *stream;
- gboolean res;
- gssize n;
- gsize nread;
- char buf[100];
-
- g_print ("Testing GBufferedInputStream ...");
-
- mem_stream = g_memory_input_stream_from_data (gmis_data,
- strlen (gmis_data));
-
- test_assert (mem_stream != NULL);
-
- stream = g_buffered_input_stream_new_sized (mem_stream, 5);
- g_object_unref (mem_stream);
-
- memset (buf, 0, sizeof (buf));
- n = g_input_stream_read (stream, buf, 3, NULL, NULL);
-
- test_assert (n == 3);
- test_assert (strcmp (buf, "Hab") == 0);
-
- /* XXX, not sure if the default impl should be doing what it does */
- n = g_input_stream_skip (stream, 4, NULL, NULL);
- test_assert (n == 4);
-
- nread = 0;
- res = g_input_stream_read_all (stream, buf, sizeof (buf), &nread, NULL, NULL);
-
- test_assert (res && nread == strlen (gmis_data) - 7);
- test_assert (strcmp (buf, gmis_data + 7) == 0);
-
- g_object_unref (stream);
-
- g_print ("DONE [OK]\n");
-
- return TRUE;
-}
-
-static gboolean
-test_buffered_output_stream ()
-{
- GOutputStream *mem_stream;
- GOutputStream *stream;
- GByteArray *array = NULL;
- gsize n, len;
- gboolean res;
-
- g_print ("Testing GBufferedOutputStream ...");
-
- mem_stream = g_memory_output_stream_new (array);
-
- test_assert (mem_stream != NULL);
- g_object_get (mem_stream, "data", &array, NULL);
-
- stream = g_buffered_output_stream_new_sized (mem_stream, 10);
- g_object_unref (mem_stream);
-
- /* if we write just 10 bytes everything should be
- * in the buffer and the underlying mem-stream
- * should still be empty */
- len = 10;
- res = g_output_stream_write_all (stream,
- (void *) gmis_data,
- len,
- &n,
- NULL,
- NULL);
-
- test_assert (res == TRUE);
- test_assert (len == n);
- test_assert (array->len == 0);
-
- /* write 5 more bytes */
- len = 5;
- res = g_output_stream_write_all (stream,
- (void *) (gmis_data + n),
- len,
- &n,
- NULL,
- NULL);
-
- test_assert (res == TRUE);
- test_assert (len == n);
- /* we should at least have the first 10 bytes now in the
- * mem-stream */
- test_assert (memcmp (array->data, gmis_data, 10) == 0);
-
- /* now flush the stream and see if we get all bytes written
- * to the mem-stream */
-
- res = g_output_stream_flush (stream,
- NULL,
- NULL);
-
- test_assert (res == TRUE);
- test_assert (memcmp (array->data, gmis_data, 15) == 0);
-
- g_object_unref (stream);
-
- g_print ("DONE [OK]\n");
- return TRUE;
-}
-
-static void
-log_and_stop (const char *domain,
- GLogLevelFlags level,
- const char *message,
- gpointer data)
-{
- g_log_default_handler (domain, level, message, data);
- g_on_error_stack_trace ("test-streams");
- abort ();
-}
-
-int
-main (int argc, char **argv)
-{
- int res;
-
- g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS);
- g_thread_init (NULL);
-
- g_log_set_handler ("GLib",
- (GLogLevelFlags) (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING),
- log_and_stop, NULL);
-
- g_log_set_handler ("GVFS",
- (GLogLevelFlags) (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING),
- log_and_stop, NULL);
-
- res = TRUE;
- res &= test_memory_input_stream ();
- res &= test_memory_output_stream (TRUE);
- res &= test_memory_output_stream (FALSE);
- res &= test_buffered_input_stream ();
- res &= test_buffered_output_stream ();
-
- return res ? 0 : -1;
-}
-
-/* vim: ts=2 sw=2 et */
diff --git a/gio/xdgmime/.gitignore b/gio/xdgmime/.gitignore
deleted file mode 100644
index 56e69459..00000000
--- a/gio/xdgmime/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-test-mime
diff --git a/gio/xdgmime/Makefile.am b/gio/xdgmime/Makefile.am
deleted file mode 100644
index 838420c2..00000000
--- a/gio/xdgmime/Makefile.am
+++ /dev/null
@@ -1,24 +0,0 @@
-INCLUDES = -DXDG_PREFIX=_gio_xdg
-
-noinst_LTLIBRARIES = libxdgmime.la
-
-libxdgmime_la_SOURCES = \
- xdgmime.c \
- xdgmime.h \
- xdgmimealias.c \
- xdgmimealias.h \
- xdgmimecache.c \
- xdgmimecache.h \
- xdgmimeglob.c \
- xdgmimeglob.h \
- xdgmimeint.c \
- xdgmimeint.h \
- xdgmimemagic.c \
- xdgmimemagic.h \
- xdgmimeparent.c \
- xdgmimeparent.h
-
-noinst_PROGRAMS = test-mime
-
-test_mime_LDADD = libxdgmime.la
-test_mime_SOURCES = test-mime.c
diff --git a/gio/xdgmime/test-mime.c b/gio/xdgmime/test-mime.c
deleted file mode 100644
index 7cff59b4..00000000
--- a/gio/xdgmime/test-mime.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2003,2004 Red Hat, Inc.
- * Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#include "xdgmime.h"
-#include "xdgmimeglob.h"
-#include <string.h>
-#include <stdio.h>
-
-
-static void
-test_individual_glob (const char *glob,
- XdgGlobType expected_type)
-{
- XdgGlobType test_type;
-
- test_type = _xdg_glob_determine_type (glob);
- if (test_type != expected_type)
- {
- printf ("Test Failed: %s is of type %s, but %s is expected\n",
- glob,
- ((test_type == XDG_GLOB_LITERAL)?"XDG_GLOB_LITERAL":
- ((test_type == XDG_GLOB_SIMPLE)?"XDG_GLOB_SIMPLE":"XDG_GLOB_FULL")),
- ((expected_type == XDG_GLOB_LITERAL)?"XDG_GLOB_LITERAL":
- ((expected_type == XDG_GLOB_SIMPLE)?"XDG_GLOB_SIMPLE":"XDG_GLOB_COMPLEX")));
- }
-}
-
-static void
-test_glob_type (void)
-{
- test_individual_glob ("*.gif", XDG_GLOB_SIMPLE);
- test_individual_glob ("Foo*.gif", XDG_GLOB_FULL);
- test_individual_glob ("*[4].gif", XDG_GLOB_FULL);
- test_individual_glob ("Makefile", XDG_GLOB_LITERAL);
- test_individual_glob ("sldkfjvlsdf\\\\slkdjf", XDG_GLOB_FULL);
- test_individual_glob ("tree.[ch]", XDG_GLOB_FULL);
-}
-
-static void
-test_alias (const char *mime_a,
- const char *mime_b,
- int expected)
-{
- int actual;
-
- actual = xdg_mime_mime_type_equal (mime_a, mime_b);
-
- if (actual != expected)
- {
- printf ("Test Failed: %s is %s to %s\n",
- mime_a, actual ? "equal" : "not equal", mime_b);
- }
-}
-
-static void
-test_aliasing (void)
-{
- test_alias ("application/wordperfect", "application/vnd.wordperfect", 1);
- test_alias ("application/x-gnome-app-info", "application/x-desktop", 1);
- test_alias ("application/x-wordperfect", "application/vnd.wordperfect", 1);
- test_alias ("application/x-wordperfect", "audio/x-midi", 0);
- test_alias ("/", "vnd/vnd", 0);
- test_alias ("application/octet-stream", "text/plain", 0);
- test_alias ("text/plain", "text/*", 0);
-}
-
-static void
-test_subclass (const char *mime_a,
- const char *mime_b,
- int expected)
-{
- int actual;
-
- actual = xdg_mime_mime_type_subclass (mime_a, mime_b);
-
- if (actual != expected)
- {
- printf ("Test Failed: %s is %s of %s\n",
- mime_a, actual ? "subclass" : "not subclass", mime_b);
- }
-}
-
-static void
-test_subclassing (void)
-{
- test_subclass ("application/rtf", "text/plain", 1);
- test_subclass ("message/news", "text/plain", 1);
- test_subclass ("message/news", "message/*", 1);
- test_subclass ("message/news", "text/*", 1);
- test_subclass ("message/news", "application/octet-stream", 1);
- test_subclass ("application/rtf", "application/octet-stream", 1);
- test_subclass ("application/x-gnome-app-info", "text/plain", 1);
- test_subclass ("image/x-djvu", "image/vnd.djvu", 1);
- test_subclass ("image/vnd.djvu", "image/x-djvu", 1);
- test_subclass ("image/vnd.djvu", "text/plain", 0);
- test_subclass ("image/vnd.djvu", "text/*", 0);
- test_subclass ("text/*", "text/plain", 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- const char *result;
- const char *file_name;
- int i;
-
- test_glob_type ();
- test_aliasing ();
- test_subclassing ();
-
- for (i = 1; i < argc; i++)
- {
- file_name = argv[i];
- result = xdg_mime_get_mime_type_for_file (file_name, NULL);
- printf ("File \"%s\" has a mime-type of %s\n", file_name, result);
- }
-
-#if 0
- xdg_mime_dump ();
-#endif
- return 0;
-}
-
diff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c
deleted file mode 100644
index 0e11b070..00000000
--- a/gio/xdgmime/xdgmime.c
+++ /dev/null
@@ -1,864 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmime.c: XDG Mime Spec mime resolver. Based on version 0.11 of the spec.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003,2004 Red Hat, Inc.
- * Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "xdgmime.h"
-#include "xdgmimeint.h"
-#include "xdgmimeglob.h"
-#include "xdgmimemagic.h"
-#include "xdgmimealias.h"
-#include "xdgmimeparent.h"
-#include "xdgmimecache.h"
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <assert.h>
-
-typedef struct XdgDirTimeList XdgDirTimeList;
-typedef struct XdgCallbackList XdgCallbackList;
-
-static int need_reread = TRUE;
-static time_t last_stat_time = 0;
-
-static XdgGlobHash *global_hash = NULL;
-static XdgMimeMagic *global_magic = NULL;
-static XdgAliasList *alias_list = NULL;
-static XdgParentList *parent_list = NULL;
-static XdgDirTimeList *dir_time_list = NULL;
-static XdgCallbackList *callback_list = NULL;
-
-XdgMimeCache **_caches = NULL;
-static int n_caches = 0;
-
-const char xdg_mime_type_unknown[] = "application/octet-stream";
-
-
-enum
-{
- XDG_CHECKED_UNCHECKED,
- XDG_CHECKED_VALID,
- XDG_CHECKED_INVALID
-};
-
-struct XdgDirTimeList
-{
- time_t mtime;
- char *directory_name;
- int checked;
- XdgDirTimeList *next;
-};
-
-struct XdgCallbackList
-{
- XdgCallbackList *next;
- XdgCallbackList *prev;
- int callback_id;
- XdgMimeCallback callback;
- void *data;
- XdgMimeDestroy destroy;
-};
-
-/* Function called by xdg_run_command_on_dirs. If it returns TRUE, further
- * directories aren't looked at */
-typedef int (*XdgDirectoryFunc) (const char *directory,
- void *user_data);
-
-static XdgDirTimeList *
-xdg_dir_time_list_new (void)
-{
- XdgDirTimeList *retval;
-
- retval = calloc (1, sizeof (XdgDirTimeList));
- retval->checked = XDG_CHECKED_UNCHECKED;
-
- return retval;
-}
-
-static void
-xdg_dir_time_list_free (XdgDirTimeList *list)
-{
- XdgDirTimeList *next;
-
- while (list)
- {
- next = list->next;
- free (list->directory_name);
- free (list);
- list = next;
- }
-}
-
-static int
-xdg_mime_init_from_directory (const char *directory)
-{
- char *file_name;
- struct stat st;
- XdgDirTimeList *list;
-
- assert (directory != NULL);
-
- file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
- if (stat (file_name, &st) == 0)
- {
- XdgMimeCache *cache = _xdg_mime_cache_new_from_file (file_name);
-
- if (cache != NULL)
- {
- list = xdg_dir_time_list_new ();
- list->directory_name = file_name;
- list->mtime = st.st_mtime;
- list->next = dir_time_list;
- dir_time_list = list;
-
- _caches = realloc (_caches, sizeof (XdgMimeCache *) * (n_caches + 2));
- _caches[n_caches] = cache;
- _caches[n_caches + 1] = NULL;
- n_caches++;
-
- return FALSE;
- }
- }
- free (file_name);
-
- file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/globs");
- if (stat (file_name, &st) == 0)
- {
- _xdg_mime_glob_read_from_file (global_hash, file_name);
-
- list = xdg_dir_time_list_new ();
- list->directory_name = file_name;
- list->mtime = st.st_mtime;
- list->next = dir_time_list;
- dir_time_list = list;
- }
- else
- {
- free (file_name);
- }
-
- file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/magic");
- if (stat (file_name, &st) == 0)
- {
- _xdg_mime_magic_read_from_file (global_magic, file_name);
-
- list = xdg_dir_time_list_new ();
- list->directory_name = file_name;
- list->mtime = st.st_mtime;
- list->next = dir_time_list;
- dir_time_list = list;
- }
- else
- {
- free (file_name);
- }
-
- file_name = malloc (strlen (directory) + strlen ("/mime/aliases") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/aliases");
- _xdg_mime_alias_read_from_file (alias_list, file_name);
- free (file_name);
-
- file_name = malloc (strlen (directory) + strlen ("/mime/subclasses") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/subclasses");
- _xdg_mime_parent_read_from_file (parent_list, file_name);
- free (file_name);
-
- return FALSE; /* Keep processing */
-}
-
-/* Runs a command on all the directories in the search path */
-static void
-xdg_run_command_on_dirs (XdgDirectoryFunc func,
- void *user_data)
-{
- const char *xdg_data_home;
- const char *xdg_data_dirs;
- const char *ptr;
-
- xdg_data_home = getenv ("XDG_DATA_HOME");
- if (xdg_data_home)
- {
- if ((func) (xdg_data_home, user_data))
- return;
- }
- else
- {
- const char *home;
-
- home = getenv ("HOME");
- if (home != NULL)
- {
- char *guessed_xdg_home;
- int stop_processing;
-
- guessed_xdg_home = malloc (strlen (home) + strlen ("/.local/share/") + 1);
- strcpy (guessed_xdg_home, home);
- strcat (guessed_xdg_home, "/.local/share/");
- stop_processing = (func) (guessed_xdg_home, user_data);
- free (guessed_xdg_home);
-
- if (stop_processing)
- return;
- }
- }
-
- xdg_data_dirs = getenv ("XDG_DATA_DIRS");
- if (xdg_data_dirs == NULL)
- xdg_data_dirs = "/usr/local/share/:/usr/share/";
-
- ptr = xdg_data_dirs;
-
- while (*ptr != '\000')
- {
- const char *end_ptr;
- char *dir;
- int len;
- int stop_processing;
-
- end_ptr = ptr;
- while (*end_ptr != ':' && *end_ptr != '\000')
- end_ptr ++;
-
- if (end_ptr == ptr)
- {
- ptr++;
- continue;
- }
-
- if (*end_ptr == ':')
- len = end_ptr - ptr;
- else
- len = end_ptr - ptr + 1;
- dir = malloc (len + 1);
- strncpy (dir, ptr, len);
- dir[len] = '\0';
- stop_processing = (func) (dir, user_data);
- free (dir);
-
- if (stop_processing)
- return;
-
- ptr = end_ptr;
- }
-}
-
-/* Checks file_path to make sure it has the same mtime as last time it was
- * checked. If it has a different mtime, or if the file doesn't exist, it
- * returns FALSE.
- *
- * FIXME: This doesn't protect against permission changes.
- */
-static int
-xdg_check_file (const char *file_path,
- int *exists)
-{
- struct stat st;
-
- /* If the file exists */
- if (stat (file_path, &st) == 0)
- {
- XdgDirTimeList *list;
-
- if (exists)
- *exists = TRUE;
-
- for (list = dir_time_list; list; list = list->next)
- {
- if (! strcmp (list->directory_name, file_path) &&
- st.st_mtime == list->mtime)
- {
- if (list->checked == XDG_CHECKED_UNCHECKED)
- list->checked = XDG_CHECKED_VALID;
- else if (list->checked == XDG_CHECKED_VALID)
- list->checked = XDG_CHECKED_INVALID;
-
- return (list->checked != XDG_CHECKED_VALID);
- }
- }
- return TRUE;
- }
-
- if (exists)
- *exists = FALSE;
-
- return FALSE;
-}
-
-static int
-xdg_check_dir (const char *directory,
- int *invalid_dir_list)
-{
- int invalid, exists;
- char *file_name;
-
- assert (directory != NULL);
-
- /* Check the mime.cache file */
- file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
- invalid = xdg_check_file (file_name, &exists);
- free (file_name);
- if (invalid)
- {
- *invalid_dir_list = TRUE;
- return TRUE;
- }
- else if (exists)
- {
- return FALSE;
- }
-
- /* Check the globs file */
- file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/globs");
- invalid = xdg_check_file (file_name, NULL);
- free (file_name);
- if (invalid)
- {
- *invalid_dir_list = TRUE;
- return TRUE;
- }
-
- /* Check the magic file */
- file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
- strcpy (file_name, directory); strcat (file_name, "/mime/magic");
- invalid = xdg_check_file (file_name, NULL);
- free (file_name);
- if (invalid)
- {
- *invalid_dir_list = TRUE;
- return TRUE;
- }
-
- return FALSE; /* Keep processing */
-}
-
-/* Walks through all the mime files stat()ing them to see if they've changed.
- * Returns TRUE if they have. */
-static int
-xdg_check_dirs (void)
-{
- XdgDirTimeList *list;
- int invalid_dir_list = FALSE;
-
- for (list = dir_time_list; list; list = list->next)
- list->checked = XDG_CHECKED_UNCHECKED;
-
- xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_check_dir,
- &invalid_dir_list);
-
- if (invalid_dir_list)
- return TRUE;
-
- for (list = dir_time_list; list; list = list->next)
- {
- if (list->checked != XDG_CHECKED_VALID)
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* We want to avoid stat()ing on every single mime call, so we only look for
- * newer files every 5 seconds. This will return TRUE if we need to reread the
- * mime data from disk.
- */
-static int
-xdg_check_time_and_dirs (void)
-{
- struct timeval tv;
- time_t current_time;
- int retval = FALSE;
-
- gettimeofday (&tv, NULL);
- current_time = tv.tv_sec;
-
- if (current_time >= last_stat_time + 5)
- {
- retval = xdg_check_dirs ();
- last_stat_time = current_time;
- }
-
- return retval;
-}
-
-/* Called in every public function. It reloads the hash function if need be.
- */
-static void
-xdg_mime_init (void)
-{
- if (xdg_check_time_and_dirs ())
- {
- xdg_mime_shutdown ();
- }
-
- if (need_reread)
- {
- global_hash = _xdg_glob_hash_new ();
- global_magic = _xdg_mime_magic_new ();
- alias_list = _xdg_mime_alias_list_new ();
- parent_list = _xdg_mime_parent_list_new ();
-
- xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_mime_init_from_directory,
- NULL);
-
- need_reread = FALSE;
- }
-}
-
-const char *
-xdg_mime_get_mime_type_for_data (const void *data,
- size_t len,
- int *result_prio)
-{
- const char *mime_type;
-
- xdg_mime_init ();
-
- if (_caches)
- return _xdg_mime_cache_get_mime_type_for_data (data, len, result_prio);
-
- mime_type = _xdg_mime_magic_lookup_data (global_magic, data, len, result_prio, NULL, 0);
-
- if (mime_type)
- return mime_type;
-
- return XDG_MIME_TYPE_UNKNOWN;
-}
-
-const char *
-xdg_mime_get_mime_type_for_file (const char *file_name,
- struct stat *statbuf)
-{
- const char *mime_type;
- /* currently, only a few globs occur twice, and none
- * more often, so 5 seems plenty.
- */
- const char *mime_types[5];
- FILE *file;
- unsigned char *data;
- int max_extent;
- int bytes_read;
- struct stat buf;
- const char *base_name;
- int n;
-
- if (file_name == NULL)
- return NULL;
- if (! _xdg_utf8_validate (file_name))
- return NULL;
-
- xdg_mime_init ();
-
- if (_caches)
- return _xdg_mime_cache_get_mime_type_for_file (file_name, statbuf);
-
- base_name = _xdg_get_base_name (file_name);
- n = _xdg_glob_hash_lookup_file_name (global_hash, base_name, mime_types, 5);
-
- if (n == 1)
- return mime_types[0];
-
- if (!statbuf)
- {
- if (stat (file_name, &buf) != 0)
- return XDG_MIME_TYPE_UNKNOWN;
-
- statbuf = &buf;
- }
-
- if (!S_ISREG (statbuf->st_mode))
- return XDG_MIME_TYPE_UNKNOWN;
-
- /* FIXME: Need to make sure that max_extent isn't totally broken. This could
- * be large and need getting from a stream instead of just reading it all
- * in. */
- max_extent = _xdg_mime_magic_get_buffer_extents (global_magic);
- data = malloc (max_extent);
- if (data == NULL)
- return XDG_MIME_TYPE_UNKNOWN;
-
- file = fopen (file_name, "r");
- if (file == NULL)
- {
- free (data);
- return XDG_MIME_TYPE_UNKNOWN;
- }
-
- bytes_read = fread (data, 1, max_extent, file);
- if (ferror (file))
- {
- free (data);
- fclose (file);
- return XDG_MIME_TYPE_UNKNOWN;
- }
-
- mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL,
- mime_types, n);
-
- free (data);
- fclose (file);
-
- if (mime_type)
- return mime_type;
-
- return XDG_MIME_TYPE_UNKNOWN;
-}
-
-const char *
-xdg_mime_get_mime_type_from_file_name (const char *file_name)
-{
- const char *mime_type;
-
- xdg_mime_init ();
-
- if (_caches)
- return _xdg_mime_cache_get_mime_type_from_file_name (file_name);
-
- if (_xdg_glob_hash_lookup_file_name (global_hash, file_name, &mime_type, 1))
- return mime_type;
- else
- return XDG_MIME_TYPE_UNKNOWN;
-}
-
-int
-xdg_mime_get_mime_types_from_file_name (const char *file_name,
- const char *mime_types[],
- int n_mime_types)
-{
- xdg_mime_init ();
-
- if (_caches)
- return _xdg_mime_cache_get_mime_types_from_file_name (file_name, mime_types, n_mime_types);
-
- return _xdg_glob_hash_lookup_file_name (global_hash, file_name, mime_types, n_mime_types);
-}
-
-int
-xdg_mime_is_valid_mime_type (const char *mime_type)
-{
- /* FIXME: We should make this a better test
- */
- return _xdg_utf8_validate (mime_type);
-}
-
-void
-xdg_mime_shutdown (void)
-{
- XdgCallbackList *list;
-
- /* FIXME: Need to make this (and the whole library) thread safe */
- if (dir_time_list)
- {
- xdg_dir_time_list_free (dir_time_list);
- dir_time_list = NULL;
- }
-
- if (global_hash)
- {
- _xdg_glob_hash_free (global_hash);
- global_hash = NULL;
- }
- if (global_magic)
- {
- _xdg_mime_magic_free (global_magic);
- global_magic = NULL;
- }
-
- if (alias_list)
- {
- _xdg_mime_alias_list_free (alias_list);
- alias_list = NULL;
- }
-
- if (parent_list)
- {
- _xdg_mime_parent_list_free (parent_list);
- parent_list = NULL;
- }
-
- if (_caches)
- {
- int i;
-
- for (i = 0; i < n_caches; i++)
- _xdg_mime_cache_unref (_caches[i]);
- free (_caches);
- _caches = NULL;
- n_caches = 0;
- }
-
- for (list = callback_list; list; list = list->next)
- (list->callback) (list->data);
-
- need_reread = TRUE;
-}
-
-int
-xdg_mime_get_max_buffer_extents (void)
-{
- xdg_mime_init ();
-
- if (_caches)
- return _xdg_mime_cache_get_max_buffer_extents ();
-
- return _xdg_mime_magic_get_buffer_extents (global_magic);
-}
-
-const char *
-_xdg_mime_unalias_mime_type (const char *mime_type)
-{
- const char *lookup;
-
- if (_caches)
- return _xdg_mime_cache_unalias_mime_type (mime_type);
-
- if ((lookup = _xdg_mime_alias_list_lookup (alias_list, mime_type)) != NULL)
- return lookup;
-
- return mime_type;
-}
-
-const char *
-xdg_mime_unalias_mime_type (const char *mime_type)
-{
- xdg_mime_init ();
-
- return _xdg_mime_unalias_mime_type (mime_type);
-}
-
-int
-_xdg_mime_mime_type_equal (const char *mime_a,
- const char *mime_b)
-{
- const char *unalias_a, *unalias_b;
-
- unalias_a = _xdg_mime_unalias_mime_type (mime_a);
- unalias_b = _xdg_mime_unalias_mime_type (mime_b);
-
- if (strcmp (unalias_a, unalias_b) == 0)
- return 1;
-
- return 0;
-}
-
-int
-xdg_mime_mime_type_equal (const char *mime_a,
- const char *mime_b)
-{
- xdg_mime_init ();
-
- return _xdg_mime_mime_type_equal (mime_a, mime_b);
-}
-
-int
-xdg_mime_media_type_equal (const char *mime_a,
- const char *mime_b)
-{
- char *sep;
-
- xdg_mime_init ();
-
- sep = strchr (mime_a, '/');
-
- if (sep && strncmp (mime_a, mime_b, sep - mime_a + 1) == 0)
- return 1;
-
- return 0;
-}
-
-#if 1
-static int
-xdg_mime_is_super_type (const char *mime)
-{
- int length;
- const char *type;
-
- length = strlen (mime);
- type = &(mime[length - 2]);
-
- if (strcmp (type, "/*") == 0)
- return 1;
-
- return 0;
-}
-#endif
-
-int
-_xdg_mime_mime_type_subclass (const char *mime,
- const char *base)
-{
- const char *umime, *ubase;
- const char **parents;
-
- if (_caches)
- return _xdg_mime_cache_mime_type_subclass (mime, base);
-
- umime = _xdg_mime_unalias_mime_type (mime);
- ubase = _xdg_mime_unalias_mime_type (base);
-
- if (strcmp (umime, ubase) == 0)
- return 1;
-
-#if 1
- /* Handle supertypes */
- if (xdg_mime_is_super_type (ubase) &&
- xdg_mime_media_type_equal (umime, ubase))
- return 1;
-#endif
-
- /* Handle special cases text/plain and application/octet-stream */
- if (strcmp (ubase, "text/plain") == 0 &&
- strncmp (umime, "text/", 5) == 0)
- return 1;
-
- if (strcmp (ubase, "application/octet-stream") == 0)
- return 1;
-
- parents = _xdg_mime_parent_list_lookup (parent_list, umime);
- for (; parents && *parents; parents++)
- {
- if (_xdg_mime_mime_type_subclass (*parents, ubase))
- return 1;
- }
-
- return 0;
-}
-
-int
-xdg_mime_mime_type_subclass (const char *mime,
- const char *base)
-{
- xdg_mime_init ();
-
- return _xdg_mime_mime_type_subclass (mime, base);
-}
-
-char **
-xdg_mime_list_mime_parents (const char *mime)
-{
- const char **parents;
- char **result;
- int i, n;
-
- if (_caches)
- return _xdg_mime_cache_list_mime_parents (mime);
-
- parents = xdg_mime_get_mime_parents (mime);
-
- if (!parents)
- return NULL;
-
- for (i = 0; parents[i]; i++) ;
-
- n = (i + 1) * sizeof (char *);
- result = (char **) malloc (n);
- memcpy (result, parents, n);
-
- return result;
-}
-
-const char **
-xdg_mime_get_mime_parents (const char *mime)
-{
- const char *umime;
-
- xdg_mime_init ();
-
- umime = _xdg_mime_unalias_mime_type (mime);
-
- return _xdg_mime_parent_list_lookup (parent_list, umime);
-}
-
-void
-xdg_mime_dump (void)
-{
- printf ("*** ALIASES ***\n\n");
- _xdg_mime_alias_list_dump (alias_list);
- printf ("\n*** PARENTS ***\n\n");
- _xdg_mime_parent_list_dump (parent_list);
-}
-
-
-/* Registers a function to be called every time the mime database reloads its files
- */
-int
-xdg_mime_register_reload_callback (XdgMimeCallback callback,
- void *data,
- XdgMimeDestroy destroy)
-{
- XdgCallbackList *list_el;
- static int callback_id = 1;
-
- /* Make a new list element */
- list_el = calloc (1, sizeof (XdgCallbackList));
- list_el->callback_id = callback_id;
- list_el->callback = callback;
- list_el->data = data;
- list_el->destroy = destroy;
- list_el->next = callback_list;
- if (list_el->next)
- list_el->next->prev = list_el;
-
- callback_list = list_el;
- callback_id ++;
-
- return callback_id - 1;
-}
-
-void
-xdg_mime_remove_callback (int callback_id)
-{
- XdgCallbackList *list;
-
- for (list = callback_list; list; list = list->next)
- {
- if (list->callback_id == callback_id)
- {
- if (list->next)
- list->next = list->prev;
-
- if (list->prev)
- list->prev->next = list->next;
- else
- callback_list = list->next;
-
- /* invoke the destroy handler */
- (list->destroy) (list->data);
- free (list);
- return;
- }
- }
-}
diff --git a/gio/xdgmime/xdgmime.h b/gio/xdgmime/xdgmime.h
deleted file mode 100644
index b8fd2d50..00000000
--- a/gio/xdgmime/xdgmime.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmime.h: XDG Mime Spec mime resolver. Based on version 0.11 of the spec.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifndef __XDG_MIME_H__
-#define __XDG_MIME_H__
-
-#include <stdlib.h>
-#include <sys/stat.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifdef XDG_PREFIX
-#define XDG_ENTRY(func) _XDG_ENTRY2(XDG_PREFIX,func)
-#define _XDG_ENTRY2(prefix,func) _XDG_ENTRY3(prefix,func)
-#define _XDG_ENTRY3(prefix,func) prefix##_##func
-#endif
-
-typedef void (*XdgMimeCallback) (void *user_data);
-typedef void (*XdgMimeDestroy) (void *user_data);
-
-
-#ifdef XDG_PREFIX
-#define xdg_mime_get_mime_type_for_data XDG_ENTRY(get_mime_type_for_data)
-#define xdg_mime_get_mime_type_for_file XDG_ENTRY(get_mime_type_for_file)
-#define xdg_mime_get_mime_type_from_file_name XDG_ENTRY(get_mime_type_from_file_name)
-#define xdg_mime_get_mime_types_from_file_name XDG_ENTRY(get_mime_types_from_file_name)
-#define xdg_mime_is_valid_mime_type XDG_ENTRY(is_valid_mime_type)
-#define xdg_mime_mime_type_equal XDG_ENTRY(mime_type_equal)
-#define _xdg_mime_mime_type_equal XDG_ENTRY(mime_type_equal_p)
-#define xdg_mime_media_type_equal XDG_ENTRY(media_type_equal)
-#define xdg_mime_mime_type_subclass XDG_ENTRY(mime_type_subclass)
-#define _xdg_mime_mime_type_subclass XDG_ENTRY(mime_type_subclass_p)
-#define xdg_mime_get_mime_parents XDG_ENTRY(get_mime_parents)
-#define xdg_mime_list_mime_parents XDG_ENTRY(list_mime_parents)
-#define xdg_mime_unalias_mime_type XDG_ENTRY(unalias_mime_type)
-#define _xdg_mime_unalias_mime_type XDG_ENTRY(unalias_mime_type_p)
-#define xdg_mime_get_max_buffer_extents XDG_ENTRY(get_max_buffer_extents)
-#define xdg_mime_shutdown XDG_ENTRY(shutdown)
-#define xdg_mime_dump XDG_ENTRY(dump)
-#define xdg_mime_register_reload_callback XDG_ENTRY(register_reload_callback)
-#define xdg_mime_remove_callback XDG_ENTRY(remove_callback)
-#define xdg_mime_type_unknown XDG_ENTRY(type_unknown)
-#endif
-
-extern const char xdg_mime_type_unknown[];
-#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
-
-const char *xdg_mime_get_mime_type_for_data (const void *data,
- size_t len,
- int *result_prio);
-const char *xdg_mime_get_mime_type_for_file (const char *file_name,
- struct stat *statbuf);
-const char *xdg_mime_get_mime_type_from_file_name (const char *file_name);
-int xdg_mime_get_mime_types_from_file_name(const char *file_name,
- const char *mime_types[],
- int n_mime_types);
-int xdg_mime_is_valid_mime_type (const char *mime_type);
-int xdg_mime_mime_type_equal (const char *mime_a,
- const char *mime_b);
-int xdg_mime_media_type_equal (const char *mime_a,
- const char *mime_b);
-int xdg_mime_mime_type_subclass (const char *mime_a,
- const char *mime_b);
- /* xdg_mime_get_mime_parents() is deprecated since it does
- * not work correctly with caches. Use xdg_mime_list_parents()
- * instead, but notice that that function expects you to free
- * the array it returns.
- */
-const char **xdg_mime_get_mime_parents (const char *mime);
-char ** xdg_mime_list_mime_parents (const char *mime);
-const char *xdg_mime_unalias_mime_type (const char *mime);
-int xdg_mime_get_max_buffer_extents (void);
-void xdg_mime_shutdown (void);
-void xdg_mime_dump (void);
-int xdg_mime_register_reload_callback (XdgMimeCallback callback,
- void *data,
- XdgMimeDestroy destroy);
-void xdg_mime_remove_callback (int callback_id);
-
- /* Private versions of functions that don't call xdg_mime_init () */
-int _xdg_mime_mime_type_equal (const char *mime_a,
- const char *mime_b);
-int _xdg_mime_media_type_equal (const char *mime_a,
- const char *mime_b);
-int _xdg_mime_mime_type_subclass (const char *mime,
- const char *base);
-const char *_xdg_mime_unalias_mime_type (const char *mime);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __XDG_MIME_H__ */
diff --git a/gio/xdgmime/xdgmimealias.c b/gio/xdgmime/xdgmimealias.c
deleted file mode 100644
index 07d89eb3..00000000
--- a/gio/xdgmime/xdgmimealias.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimealias.c: Private file. Datastructure for storing the aliases.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2004 Red Hat, Inc.
- * Copyright (C) 2004 Matthias Clasen <mclasen@redhat.com>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "xdgmimealias.h"
-#include "xdgmimeint.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-#include <fnmatch.h>
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-typedef struct XdgAlias XdgAlias;
-
-struct XdgAlias
-{
- char *alias;
- char *mime_type;
-};
-
-struct XdgAliasList
-{
- struct XdgAlias *aliases;
- int n_aliases;
-};
-
-XdgAliasList *
-_xdg_mime_alias_list_new (void)
-{
- XdgAliasList *list;
-
- list = malloc (sizeof (XdgAliasList));
-
- list->aliases = NULL;
- list->n_aliases = 0;
-
- return list;
-}
-
-void
-_xdg_mime_alias_list_free (XdgAliasList *list)
-{
- int i;
-
- if (list->aliases)
- {
- for (i = 0; i < list->n_aliases; i++)
- {
- free (list->aliases[i].alias);
- free (list->aliases[i].mime_type);
- }
- free (list->aliases);
- }
- free (list);
-}
-
-static int
-alias_entry_cmp (const void *v1, const void *v2)
-{
- return strcmp (((XdgAlias *)v1)->alias, ((XdgAlias *)v2)->alias);
-}
-
-const char *
-_xdg_mime_alias_list_lookup (XdgAliasList *list,
- const char *alias)
-{
- XdgAlias *entry;
- XdgAlias key;
-
- if (list->n_aliases > 0)
- {
- key.alias = (char *)alias;
- key.mime_type = NULL;
-
- entry = bsearch (&key, list->aliases, list->n_aliases,
- sizeof (XdgAlias), alias_entry_cmp);
- if (entry)
- return entry->mime_type;
- }
-
- return NULL;
-}
-
-void
-_xdg_mime_alias_read_from_file (XdgAliasList *list,
- const char *file_name)
-{
- FILE *file;
- char line[255];
- int alloc;
-
- file = fopen (file_name, "r");
-
- if (file == NULL)
- return;
-
- /* FIXME: Not UTF-8 safe. Doesn't work if lines are greater than 255 chars.
- * Blah */
- alloc = list->n_aliases + 16;
- list->aliases = realloc (list->aliases, alloc * sizeof (XdgAlias));
- while (fgets (line, 255, file) != NULL)
- {
- char *sep;
- if (line[0] == '#')
- continue;
-
- sep = strchr (line, ' ');
- if (sep == NULL)
- continue;
- *(sep++) = '\000';
- sep[strlen (sep) -1] = '\000';
- if (list->n_aliases == alloc)
- {
- alloc <<= 1;
- list->aliases = realloc (list->aliases,
- alloc * sizeof (XdgAlias));
- }
- list->aliases[list->n_aliases].alias = strdup (line);
- list->aliases[list->n_aliases].mime_type = strdup (sep);
- list->n_aliases++;
- }
- list->aliases = realloc (list->aliases,
- list->n_aliases * sizeof (XdgAlias));
-
- fclose (file);
-
- if (list->n_aliases > 1)
- qsort (list->aliases, list->n_aliases,
- sizeof (XdgAlias), alias_entry_cmp);
-}
-
-
-void
-_xdg_mime_alias_list_dump (XdgAliasList *list)
-{
- int i;
-
- if (list->aliases)
- {
- for (i = 0; i < list->n_aliases; i++)
- {
- printf ("%s %s\n",
- list->aliases[i].alias,
- list->aliases[i].mime_type);
- }
- }
-}
-
-
diff --git a/gio/xdgmime/xdgmimealias.h b/gio/xdgmime/xdgmimealias.h
deleted file mode 100644
index d0aaed05..00000000
--- a/gio/xdgmime/xdgmimealias.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimealias.h: Private file. Datastructure for storing the aliases.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2004 Red Hat, Inc.
- * Copyright (C) 200 Matthias Clasen <mclasen@redhat.com>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XDG_MIME_ALIAS_H__
-#define __XDG_MIME_ALIAS_H__
-
-#include "xdgmime.h"
-
-typedef struct XdgAliasList XdgAliasList;
-
-#ifdef XDG_PREFIX
-#define _xdg_mime_alias_read_from_file XDG_ENTRY(alias_read_from_file)
-#define _xdg_mime_alias_list_new XDG_ENTRY(alias_list_new)
-#define _xdg_mime_alias_list_free XDG_ENTRY(alias_list_free)
-#define _xdg_mime_alias_list_lookup XDG_ENTRY(alias_list_lookup)
-#define _xdg_mime_alias_list_dump XDG_ENTRY(alias_list_dump)
-#endif
-
-void _xdg_mime_alias_read_from_file (XdgAliasList *list,
- const char *file_name);
-XdgAliasList *_xdg_mime_alias_list_new (void);
-void _xdg_mime_alias_list_free (XdgAliasList *list);
-const char *_xdg_mime_alias_list_lookup (XdgAliasList *list,
- const char *alias);
-void _xdg_mime_alias_list_dump (XdgAliasList *list);
-
-#endif /* __XDG_MIME_ALIAS_H__ */
diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c
deleted file mode 100644
index f17ddf24..00000000
--- a/gio/xdgmime/xdgmimecache.c
+++ /dev/null
@@ -1,909 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimealias.c: Private file. mmappable caches for mime data
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <fnmatch.h>
-#include <assert.h>
-
-#include <netinet/in.h> /* for ntohl/ntohs */
-
-#ifdef HAVE_MMAP
-#include <sys/mman.h>
-#endif
-
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "xdgmimecache.h"
-#include "xdgmimeint.h"
-
-#ifndef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-#ifndef _O_BINARY
-#define _O_BINARY 0
-#endif
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *) -1)
-#endif
-
-#define MAJOR_VERSION 1
-#define MINOR_VERSION 0
-
-struct _XdgMimeCache
-{
- int ref_count;
-
- size_t size;
- char *buffer;
-};
-
-#define GET_UINT16(cache,offset) (ntohs(*(xdg_uint16_t*)((cache) + (offset))))
-#define GET_UINT32(cache,offset) (ntohl(*(xdg_uint32_t*)((cache) + (offset))))
-
-XdgMimeCache *
-_xdg_mime_cache_ref (XdgMimeCache *cache)
-{
- cache->ref_count++;
- return cache;
-}
-
-void
-_xdg_mime_cache_unref (XdgMimeCache *cache)
-{
- cache->ref_count--;
-
- if (cache->ref_count == 0)
- {
-#ifdef HAVE_MMAP
- munmap (cache->buffer, cache->size);
-#endif
- free (cache);
- }
-}
-
-XdgMimeCache *
-_xdg_mime_cache_new_from_file (const char *file_name)
-{
- XdgMimeCache *cache = NULL;
-
-#ifdef HAVE_MMAP
- int fd = -1;
- struct stat st;
- char *buffer = NULL;
-
- /* Open the file and map it into memory */
- fd = open (file_name, O_RDONLY|_O_BINARY, 0);
-
- if (fd < 0)
- return NULL;
-
- if (fstat (fd, &st) < 0 || st.st_size < 4)
- goto done;
-
- buffer = (char *) mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
-
- if (buffer == MAP_FAILED)
- goto done;
-
- /* Verify version */
- if (GET_UINT16 (buffer, 0) != MAJOR_VERSION ||
- GET_UINT16 (buffer, 2) != MINOR_VERSION)
- {
- munmap (buffer, st.st_size);
-
- goto done;
- }
-
- cache = (XdgMimeCache *) malloc (sizeof (XdgMimeCache));
- cache->ref_count = 1;
- cache->buffer = buffer;
- cache->size = st.st_size;
-
- done:
- if (fd != -1)
- close (fd);
-
-#endif /* HAVE_MMAP */
-
- return cache;
-}
-
-static int
-cache_magic_matchlet_compare_to_data (XdgMimeCache *cache,
- xdg_uint32_t offset,
- const void *data,
- size_t len)
-{
- xdg_uint32_t range_start = GET_UINT32 (cache->buffer, offset);
- xdg_uint32_t range_length = GET_UINT32 (cache->buffer, offset + 4);
- xdg_uint32_t data_length = GET_UINT32 (cache->buffer, offset + 12);
- xdg_uint32_t data_offset = GET_UINT32 (cache->buffer, offset + 16);
- xdg_uint32_t mask_offset = GET_UINT32 (cache->buffer, offset + 20);
-
- int i, j;
-
- for (i = range_start; i <= range_start + range_length; i++)
- {
- int valid_matchlet = TRUE;
-
- if (i + data_length > len)
- return FALSE;
-
- if (mask_offset)
- {
- for (j = 0; j < data_length; j++)
- {
- if ((((unsigned char *)cache->buffer)[data_offset + j] & ((unsigned char *)cache->buffer)[mask_offset + j]) !=
- ((((unsigned char *) data)[j + i]) & ((unsigned char *)cache->buffer)[mask_offset + j]))
- {
- valid_matchlet = FALSE;
- break;
- }
- }
- }
- else
- {
- for (j = 0; j < data_length; j++)
- {
- if (((unsigned char *)cache->buffer)[data_offset + j] != ((unsigned char *) data)[j + i])
- {
- valid_matchlet = FALSE;
- break;
- }
- }
- }
-
- if (valid_matchlet)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static int
-cache_magic_matchlet_compare (XdgMimeCache *cache,
- xdg_uint32_t offset,
- const void *data,
- size_t len)
-{
- xdg_uint32_t n_children = GET_UINT32 (cache->buffer, offset + 24);
- xdg_uint32_t child_offset = GET_UINT32 (cache->buffer, offset + 28);
-
- int i;
-
- if (cache_magic_matchlet_compare_to_data (cache, offset, data, len))
- {
- if (n_children == 0)
- return TRUE;
-
- for (i = 0; i < n_children; i++)
- {
- if (cache_magic_matchlet_compare (cache, child_offset + 32 * i,
- data, len))
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static const char *
-cache_magic_compare_to_data (XdgMimeCache *cache,
- xdg_uint32_t offset,
- const void *data,
- size_t len,
- int *prio)
-{
- xdg_uint32_t priority = GET_UINT32 (cache->buffer, offset);
- xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, offset + 4);
- xdg_uint32_t n_matchlets = GET_UINT32 (cache->buffer, offset + 8);
- xdg_uint32_t matchlet_offset = GET_UINT32 (cache->buffer, offset + 12);
-
- int i;
-
- for (i = 0; i < n_matchlets; i++)
- {
- if (cache_magic_matchlet_compare (cache, matchlet_offset + i * 32,
- data, len))
- {
- *prio = priority;
-
- return cache->buffer + mimetype_offset;
- }
- }
-
- return NULL;
-}
-
-static const char *
-cache_magic_lookup_data (XdgMimeCache *cache,
- const void *data,
- size_t len,
- int *prio,
- const char *mime_types[],
- int n_mime_types)
-{
- xdg_uint32_t list_offset;
- xdg_uint32_t n_entries;
- xdg_uint32_t offset;
-
- int j, n;
-
- *prio = 0;
-
- list_offset = GET_UINT32 (cache->buffer, 24);
- n_entries = GET_UINT32 (cache->buffer, list_offset);
- offset = GET_UINT32 (cache->buffer, list_offset + 8);
-
- for (j = 0; j < n_entries; j++)
- {
- const char *match;
-
- match = cache_magic_compare_to_data (cache, offset + 16 * j,
- data, len, prio);
- if (match)
- return match;
- else
- {
- xdg_uint32_t mimetype_offset;
- const char *non_match;
-
- mimetype_offset = GET_UINT32 (cache->buffer, offset + 16 * j + 4);
- non_match = cache->buffer + mimetype_offset;
-
- for (n = 0; n < n_mime_types; n++)
- {
- if (mime_types[n] &&
- xdg_mime_mime_type_equal (mime_types[n], non_match))
- mime_types[n] = NULL;
- }
- }
- }
-
- return NULL;
-}
-
-static const char *
-cache_alias_lookup (const char *alias)
-{
- const char *ptr;
- int i, min, max, mid, cmp;
-
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
- xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 4);
- xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
- xdg_uint32_t offset;
-
- min = 0;
- max = n_entries - 1;
- while (max >= min)
- {
- mid = (min + max) / 2;
-
- offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * mid);
- ptr = cache->buffer + offset;
- cmp = strcmp (ptr, alias);
-
- if (cmp < 0)
- min = mid + 1;
- else if (cmp > 0)
- max = mid - 1;
- else
- {
- offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * mid + 4);
- return cache->buffer + offset;
- }
- }
- }
-
- return NULL;
-}
-
-static int
-cache_glob_lookup_literal (const char *file_name,
- const char *mime_types[],
- int n_mime_types)
-{
- const char *ptr;
- int i, min, max, mid, cmp;
-
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
- xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 12);
- xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
- xdg_uint32_t offset;
-
- min = 0;
- max = n_entries - 1;
- while (max >= min)
- {
- mid = (min + max) / 2;
-
- offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * mid);
- ptr = cache->buffer + offset;
- cmp = strcmp (ptr, file_name);
-
- if (cmp < 0)
- min = mid + 1;
- else if (cmp > 0)
- max = mid - 1;
- else
- {
- offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * mid + 4);
- mime_types[0] = (const char *)(cache->buffer + offset);
-
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-static int
-cache_glob_lookup_fnmatch (const char *file_name,
- const char *mime_types[],
- int n_mime_types)
-{
- const char *mime_type;
- const char *ptr;
-
- int i, j, n;
-
- n = 0;
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
-
- xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 20);
- xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
-
- for (j = 0; j < n_entries && n < n_mime_types; j++)
- {
- xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j);
- xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j + 4);
- ptr = cache->buffer + offset;
- mime_type = cache->buffer + mimetype_offset;
-
- /* FIXME: Not UTF-8 safe */
- if (fnmatch (ptr, file_name, 0) == 0)
- mime_types[n++] = mime_type;
- }
-
- if (n > 0)
- return n;
- }
-
- return 0;
-}
-
-static int
-cache_glob_node_lookup_suffix (XdgMimeCache *cache,
- xdg_uint32_t n_entries,
- xdg_uint32_t offset,
- const char *suffix,
- int ignore_case,
- const char *mime_types[],
- int n_mime_types)
-{
- xdg_unichar_t character;
- xdg_unichar_t match_char;
- xdg_uint32_t mimetype_offset;
- xdg_uint32_t n_children;
- xdg_uint32_t child_offset;
-
- int min, max, mid, n, i;
-
- character = _xdg_utf8_to_ucs4 (suffix);
- if (ignore_case)
- character = _xdg_ucs4_to_lower (character);
-
- min = 0;
- max = n_entries - 1;
- while (max >= min)
- {
- mid = (min + max) / 2;
-
- match_char = GET_UINT32 (cache->buffer, offset + 16 * mid);
-
- if (match_char < character)
- min = mid + 1;
- else if (match_char > character)
- max = mid - 1;
- else
- {
- suffix = _xdg_utf8_next_char (suffix);
- if (*suffix == '\0')
- {
- mimetype_offset = GET_UINT32 (cache->buffer, offset + 16 * mid + 4);
- n = 0;
- if (mimetype_offset)
- mime_types[n++] = cache->buffer + mimetype_offset;
-
- n_children = GET_UINT32 (cache->buffer, offset + 16 * mid + 8);
- child_offset = GET_UINT32 (cache->buffer, offset + 16 * mid + 12);
- i = 0;
- while (n < n_mime_types && i < n_children)
- {
- match_char = GET_UINT32 (cache->buffer, child_offset + 16 * i);
- mimetype_offset = GET_UINT32 (cache->buffer, offset + 16 * i + 4);
- if (match_char != 0)
- break;
-
- mime_types[n++] = cache->buffer + mimetype_offset;
- i++;
- }
-
- return n;
- }
- else
- {
- n_children = GET_UINT32 (cache->buffer, offset + 16 * mid + 8);
- child_offset = GET_UINT32 (cache->buffer, offset + 16 * mid + 12);
-
- return cache_glob_node_lookup_suffix (cache,
- n_children, child_offset,
- suffix, ignore_case,
- mime_types,
- n_mime_types);
- }
- }
- }
-
- return 0;
-}
-
-static int
-cache_glob_lookup_suffix (const char *suffix,
- int ignore_case,
- const char *mime_types[],
- int n_mime_types)
-{
- int i, n;
-
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
-
- xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 16);
- xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
- xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4);
-
- n = cache_glob_node_lookup_suffix (cache,
- n_entries, offset,
- suffix, ignore_case,
- mime_types,
- n_mime_types);
- if (n > 0)
- return n;
- }
-
- return 0;
-}
-
-static void
-find_stopchars (char *stopchars)
-{
- int i, j, k, l;
-
- k = 0;
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
-
- xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 16);
- xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
- xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4);
-
- for (j = 0; j < n_entries; j++)
- {
- xdg_uint32_t match_char = GET_UINT32 (cache->buffer, offset);
-
- if (match_char < 128)
- {
- for (l = 0; l < k; l++)
- if (stopchars[l] == match_char)
- break;
- if (l == k)
- {
- stopchars[k] = (char) match_char;
- k++;
- }
- }
-
- offset += 16;
- }
- }
-
- stopchars[k] = '\0';
-}
-
-static int
-cache_glob_lookup_file_name (const char *file_name,
- const char *mime_types[],
- int n_mime_types)
-{
- const char *ptr;
- char stopchars[128];
- int n;
-
- assert (file_name != NULL);
-
- /* First, check the literals */
- n = cache_glob_lookup_literal (file_name, mime_types, n_mime_types);
- if (n > 0)
- return n;
-
- find_stopchars (stopchars);
-
- /* Next, check suffixes */
- ptr = strpbrk (file_name, stopchars);
- while (ptr)
- {
- n = cache_glob_lookup_suffix (ptr, FALSE, mime_types, n_mime_types);
- if (n > 0)
- return n;
-
- n = cache_glob_lookup_suffix (ptr, TRUE, mime_types, n_mime_types);
- if (n > 0)
- return n;
-
- ptr = strpbrk (ptr + 1, stopchars);
- }
-
- /* Last, try fnmatch */
- return cache_glob_lookup_fnmatch (file_name, mime_types, n_mime_types);
-}
-
-int
-_xdg_mime_cache_get_max_buffer_extents (void)
-{
- xdg_uint32_t offset;
- xdg_uint32_t max_extent;
- int i;
-
- max_extent = 0;
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
-
- offset = GET_UINT32 (cache->buffer, 24);
- max_extent = MAX (max_extent, GET_UINT32 (cache->buffer, offset + 4));
- }
-
- return max_extent;
-}
-
-static const char *
-cache_get_mime_type_for_data (const void *data,
- size_t len,
- int *result_prio,
- const char *mime_types[],
- int n_mime_types)
-{
- const char *mime_type;
- int i, n, priority;
-
- priority = 0;
- mime_type = NULL;
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
-
- int prio;
- const char *match;
-
- match = cache_magic_lookup_data (cache, data, len, &prio,
- mime_types, n_mime_types);
- if (prio > priority)
- {
- priority = prio;
- mime_type = match;
- }
- }
-
- if (result_prio)
- *result_prio = priority;
-
- if (priority > 0)
- return mime_type;
-
- for (n = 0; n < n_mime_types; n++)
- {
-
- if (mime_types[n])
- return mime_types[n];
- }
-
- return XDG_MIME_TYPE_UNKNOWN;
-}
-
-const char *
-_xdg_mime_cache_get_mime_type_for_data (const void *data,
- size_t len,
- int *result_prio)
-{
- return cache_get_mime_type_for_data (data, len, result_prio, NULL, 0);
-}
-
-const char *
-_xdg_mime_cache_get_mime_type_for_file (const char *file_name,
- struct stat *statbuf)
-{
- const char *mime_type;
- const char *mime_types[2];
- FILE *file;
- unsigned char *data;
- int max_extent;
- int bytes_read;
- struct stat buf;
- const char *base_name;
- int n;
-
- if (file_name == NULL)
- return NULL;
-
- if (! _xdg_utf8_validate (file_name))
- return NULL;
-
- base_name = _xdg_get_base_name (file_name);
- n = cache_glob_lookup_file_name (base_name, mime_types, 2);
-
- if (n == 1)
- return mime_types[0];
-
- if (!statbuf)
- {
- if (stat (file_name, &buf) != 0)
- return XDG_MIME_TYPE_UNKNOWN;
-
- statbuf = &buf;
- }
-
- if (!S_ISREG (statbuf->st_mode))
- return XDG_MIME_TYPE_UNKNOWN;
-
- /* FIXME: Need to make sure that max_extent isn't totally broken. This could
- * be large and need getting from a stream instead of just reading it all
- * in. */
- max_extent = _xdg_mime_cache_get_max_buffer_extents ();
- data = malloc (max_extent);
- if (data == NULL)
- return XDG_MIME_TYPE_UNKNOWN;
-
- file = fopen (file_name, "r");
- if (file == NULL)
- {
- free (data);
- return XDG_MIME_TYPE_UNKNOWN;
- }
-
- bytes_read = fread (data, 1, max_extent, file);
- if (ferror (file))
- {
- free (data);
- fclose (file);
- return XDG_MIME_TYPE_UNKNOWN;
- }
-
- mime_type = cache_get_mime_type_for_data (data, bytes_read, NULL,
- mime_types, n);
-
- free (data);
- fclose (file);
-
- return mime_type;
-}
-
-const char *
-_xdg_mime_cache_get_mime_type_from_file_name (const char *file_name)
-{
- const char *mime_type;
-
- if (cache_glob_lookup_file_name (file_name, &mime_type, 1))
- return mime_type;
- else
- return XDG_MIME_TYPE_UNKNOWN;
-}
-
-int
-_xdg_mime_cache_get_mime_types_from_file_name (const char *file_name,
- const char *mime_types[],
- int n_mime_types)
-{
- return cache_glob_lookup_file_name (file_name, mime_types, n_mime_types);
-}
-
-#if 1
-static int
-is_super_type (const char *mime)
-{
- int length;
- const char *type;
-
- length = strlen (mime);
- type = &(mime[length - 2]);
-
- if (strcmp (type, "/*") == 0)
- return 1;
-
- return 0;
-}
-#endif
-
-int
-_xdg_mime_cache_mime_type_subclass (const char *mime,
- const char *base)
-{
- const char *umime, *ubase;
-
- int i, j, min, max, med, cmp;
-
- umime = _xdg_mime_cache_unalias_mime_type (mime);
- ubase = _xdg_mime_cache_unalias_mime_type (base);
-
- if (strcmp (umime, ubase) == 0)
- return 1;
-
- /* We really want to handle text/ * in GtkFileFilter, so we just
- * turn on the supertype matching
- */
-#if 1
- /* Handle supertypes */
- if (is_super_type (ubase) &&
- xdg_mime_media_type_equal (umime, ubase))
- return 1;
-#endif
-
- /* Handle special cases text/plain and application/octet-stream */
- if (strcmp (ubase, "text/plain") == 0 &&
- strncmp (umime, "text/", 5) == 0)
- return 1;
-
- if (strcmp (ubase, "application/octet-stream") == 0)
- return 1;
-
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
-
- xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 8);
- xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
- xdg_uint32_t offset, n_parents, parent_offset;
-
- min = 0;
- max = n_entries - 1;
- while (max >= min)
- {
- med = (min + max)/2;
-
- offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * med);
- cmp = strcmp (cache->buffer + offset, umime);
- if (cmp < 0)
- min = med + 1;
- else if (cmp > 0)
- max = med - 1;
- else
- {
- offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * med + 4);
- n_parents = GET_UINT32 (cache->buffer, offset);
-
- for (j = 0; j < n_parents; j++)
- {
- parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j);
- if (_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
- return 1;
- }
-
- break;
- }
- }
- }
-
- return 0;
-}
-
-const char *
-_xdg_mime_cache_unalias_mime_type (const char *mime)
-{
- const char *lookup;
-
- lookup = cache_alias_lookup (mime);
-
- if (lookup)
- return lookup;
-
- return mime;
-}
-
-char **
-_xdg_mime_cache_list_mime_parents (const char *mime)
-{
- int i, j, k, p;
- char *all_parents[128]; /* we'll stop at 128 */
- char **result;
-
- mime = xdg_mime_unalias_mime_type (mime);
-
- p = 0;
- for (i = 0; _caches[i]; i++)
- {
- XdgMimeCache *cache = _caches[i];
-
- xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 8);
- xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
-
- for (j = 0; j < n_entries; j++)
- {
- xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j);
- xdg_uint32_t parents_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 8 * j + 4);
-
- if (strcmp (cache->buffer + mimetype_offset, mime) == 0)
- {
- xdg_uint32_t parent_mime_offset;
- xdg_uint32_t n_parents = GET_UINT32 (cache->buffer, parents_offset);
-
- for (k = 0; k < n_parents && p < 127; k++)
- {
- parent_mime_offset = GET_UINT32 (cache->buffer, parents_offset + 4 + 4 * k);
- all_parents[p++] = cache->buffer + parent_mime_offset;
- }
-
- break;
- }
- }
- }
- all_parents[p++] = 0;
-
- result = (char **) malloc (p * sizeof (char *));
- memcpy (result, all_parents, p * sizeof (char *));
-
- return result;
-}
-
diff --git a/gio/xdgmime/xdgmimecache.h b/gio/xdgmime/xdgmimecache.h
deleted file mode 100644
index 1cd978fa..00000000
--- a/gio/xdgmime/xdgmimecache.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimecache.h: Private file. Datastructure for mmapped caches.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XDG_MIME_CACHE_H__
-#define __XDG_MIME_CACHE_H__
-
-#include "xdgmime.h"
-
-typedef struct _XdgMimeCache XdgMimeCache;
-
-#ifdef XDG_PREFIX
-#define _xdg_mime_cache_new_from_file XDG_ENTRY(cache_new_from_file)
-#define _xdg_mime_cache_ref XDG_ENTRY(cache_ref)
-#define _xdg_mime_cache_unref XDG_ENTRY(cache_unref)
-#define _xdg_mime_cache_get_max_buffer_extents XDG_ENTRY(cache_get_max_buffer_extents)
-#define _xdg_mime_cache_get_mime_type_for_data XDG_ENTRY(cache_get_mime_type_for_data)
-#define _xdg_mime_cache_get_mime_type_for_file XDG_ENTRY(cache_get_mime_type_for_file)
-#define _xdg_mime_cache_get_mime_type_from_file_name XDG_ENTRY(cache_get_mime_type_from_file_name)
-#define _xdg_mime_cache_get_mime_types_from_file_name XDG_ENTRY(cache_get_mime_types_from_file_name)
-#define _xdg_mime_cache_list_mime_parents XDG_ENTRY(cache_list_mime_parents)
-#define _xdg_mime_cache_mime_type_subclass XDG_ENTRY(cache_mime_type_subclass)
-#define _xdg_mime_cache_unalias_mime_type XDG_ENTRY(cache_unalias_mime_type)
-
-#endif
-
-extern XdgMimeCache **_caches;
-
-XdgMimeCache *_xdg_mime_cache_new_from_file (const char *file_name);
-XdgMimeCache *_xdg_mime_cache_ref (XdgMimeCache *cache);
-void _xdg_mime_cache_unref (XdgMimeCache *cache);
-
-
-const char *_xdg_mime_cache_get_mime_type_for_data (const void *data,
- size_t len,
- int *result_prio);
-const char *_xdg_mime_cache_get_mime_type_for_file (const char *file_name,
- struct stat *statbuf);
-int _xdg_mime_cache_get_mime_types_from_file_name (const char *file_name,
- const char *mime_types[],
- int n_mime_types);
-const char *_xdg_mime_cache_get_mime_type_from_file_name (const char *file_name);
-int _xdg_mime_cache_is_valid_mime_type (const char *mime_type);
-int _xdg_mime_cache_mime_type_equal (const char *mime_a,
- const char *mime_b);
-int _xdg_mime_cache_media_type_equal (const char *mime_a,
- const char *mime_b);
-int _xdg_mime_cache_mime_type_subclass (const char *mime_a,
- const char *mime_b);
-char **_xdg_mime_cache_list_mime_parents (const char *mime);
-const char *_xdg_mime_cache_unalias_mime_type (const char *mime);
-int _xdg_mime_cache_get_max_buffer_extents (void);
-
-#endif /* __XDG_MIME_CACHE_H__ */
diff --git a/gio/xdgmime/xdgmimeglob.c b/gio/xdgmime/xdgmimeglob.c
deleted file mode 100644
index 3aad6113..00000000
--- a/gio/xdgmime/xdgmimeglob.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimeglob.c: Private file. Datastructure for storing the globs.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "xdgmimeglob.h"
-#include "xdgmimeint.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-#include <fnmatch.h>
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-typedef struct XdgGlobHashNode XdgGlobHashNode;
-typedef struct XdgGlobList XdgGlobList;
-
-struct XdgGlobHashNode
-{
- xdg_unichar_t character;
- const char *mime_type;
- XdgGlobHashNode *next;
- XdgGlobHashNode *child;
-};
-struct XdgGlobList
-{
- const char *data;
- const char *mime_type;
- XdgGlobList *next;
-};
-
-struct XdgGlobHash
-{
- XdgGlobList *literal_list;
- XdgGlobHashNode *simple_node;
- XdgGlobList *full_list;
-};
-
-
-/* XdgGlobList
- */
-static XdgGlobList *
-_xdg_glob_list_new (void)
-{
- XdgGlobList *new_element;
-
- new_element = calloc (1, sizeof (XdgGlobList));
-
- return new_element;
-}
-
-/* Frees glob_list and all of it's children */
-static void
-_xdg_glob_list_free (XdgGlobList *glob_list)
-{
- XdgGlobList *ptr, *next;
-
- ptr = glob_list;
-
- while (ptr != NULL)
- {
- next = ptr->next;
-
- if (ptr->data)
- free ((void *) ptr->data);
- if (ptr->mime_type)
- free ((void *) ptr->mime_type);
- free (ptr);
-
- ptr = next;
- }
-}
-
-static XdgGlobList *
-_xdg_glob_list_append (XdgGlobList *glob_list,
- void *data,
- const char *mime_type)
-{
- XdgGlobList *new_element;
- XdgGlobList *tmp_element;
-
- new_element = _xdg_glob_list_new ();
- new_element->data = data;
- new_element->mime_type = mime_type;
- if (glob_list == NULL)
- return new_element;
-
- tmp_element = glob_list;
- while (tmp_element->next != NULL)
- tmp_element = tmp_element->next;
-
- tmp_element->next = new_element;
-
- return glob_list;
-}
-
-#if 0
-static XdgGlobList *
-_xdg_glob_list_prepend (XdgGlobList *glob_list,
- void *data,
- const char *mime_type)
-{
- XdgGlobList *new_element;
-
- new_element = _xdg_glob_list_new ();
- new_element->data = data;
- new_element->next = glob_list;
- new_element->mime_type = mime_type;
-
- return new_element;
-}
-#endif
-
-/* XdgGlobHashNode
- */
-
-static XdgGlobHashNode *
-_xdg_glob_hash_node_new (void)
-{
- XdgGlobHashNode *glob_hash_node;
-
- glob_hash_node = calloc (1, sizeof (XdgGlobHashNode));
-
- return glob_hash_node;
-}
-
-static void
-_xdg_glob_hash_node_dump (XdgGlobHashNode *glob_hash_node,
- int depth)
-{
- int i;
- for (i = 0; i < depth; i++)
- printf (" ");
-
- printf ("%c", (char)glob_hash_node->character);
- if (glob_hash_node->mime_type)
- printf (" - %s\n", glob_hash_node->mime_type);
- else
- printf ("\n");
- if (glob_hash_node->child)
- _xdg_glob_hash_node_dump (glob_hash_node->child, depth + 1);
- if (glob_hash_node->next)
- _xdg_glob_hash_node_dump (glob_hash_node->next, depth);
-}
-
-static XdgGlobHashNode *
-_xdg_glob_hash_insert_text (XdgGlobHashNode *glob_hash_node,
- const char *text,
- const char *mime_type)
-{
- XdgGlobHashNode *node;
- xdg_unichar_t character;
-
- character = _xdg_utf8_to_ucs4 (text);
-
- if ((glob_hash_node == NULL) ||
- (character < glob_hash_node->character))
- {
- node = _xdg_glob_hash_node_new ();
- node->character = character;
- node->next = glob_hash_node;
- glob_hash_node = node;
- }
- else if (character == glob_hash_node->character)
- {
- node = glob_hash_node;
- }
- else
- {
- XdgGlobHashNode *prev_node;
- int found_node = FALSE;
-
- /* Look for the first character of text in glob_hash_node, and insert it if we
- * have to.*/
- prev_node = glob_hash_node;
- node = prev_node->next;
-
- while (node != NULL)
- {
- if (character < node->character)
- {
- node = _xdg_glob_hash_node_new ();
- node->character = character;
- node->next = prev_node->next;
- prev_node->next = node;
-
- found_node = TRUE;
- break;
- }
- else if (character == node->character)
- {
- found_node = TRUE;
- break;
- }
- prev_node = node;
- node = node->next;
- }
-
- if (! found_node)
- {
- node = _xdg_glob_hash_node_new ();
- node->character = character;
- node->next = prev_node->next;
- prev_node->next = node;
- }
- }
-
- text = _xdg_utf8_next_char (text);
- if (*text == '\000')
- {
- if (node->mime_type)
- {
- if (strcmp (node->mime_type, mime_type))
- {
- XdgGlobHashNode *child;
- int found_node = FALSE;
-
- child = node->child;
- while (child && child->character == '\0')
- {
- if (strcmp (child->mime_type, mime_type) == 0)
- {
- found_node = TRUE;
- break;
- }
- child = child->next;
- }
-
- if (!found_node)
- {
- child = _xdg_glob_hash_node_new ();
- child->character = '\000';
- child->mime_type = strdup (mime_type);
- child->child = NULL;
- child->next = node->child;
- node->child = child;
- }
- }
- }
- else
- {
- node->mime_type = strdup (mime_type);
- }
- }
- else
- {
- node->child = _xdg_glob_hash_insert_text (node->child, text, mime_type);
- }
- return glob_hash_node;
-}
-
-static int
-_xdg_glob_hash_node_lookup_file_name (XdgGlobHashNode *glob_hash_node,
- const char *file_name,
- int ignore_case,
- const char *mime_types[],
- int n_mime_types)
-{
- int n;
- XdgGlobHashNode *node;
- xdg_unichar_t character;
-
- if (glob_hash_node == NULL)
- return 0;
-
- character = _xdg_utf8_to_ucs4 (file_name);
- if (ignore_case)
- character = _xdg_ucs4_to_lower(character);
-
- for (node = glob_hash_node; node && character >= node->character; node = node->next)
- {
- if (character == node->character)
- {
- file_name = _xdg_utf8_next_char (file_name);
- if (*file_name == '\000')
- {
- n = 0;
- if (node->mime_type)
- mime_types[n++] = node->mime_type;
- node = node->child;
- while (n < n_mime_types && node && node->character == 0)
- {
- if (node->mime_type)
- mime_types[n++] = node->mime_type;
- node = node->next;
- }
- }
- else
- {
- n = _xdg_glob_hash_node_lookup_file_name (node->child,
- file_name,
- ignore_case,
- mime_types,
- n_mime_types);
- }
- return n;
- }
- }
-
- return 0;
-}
-
-int
-_xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash,
- const char *file_name,
- const char *mime_types[],
- int n_mime_types)
-{
- XdgGlobList *list;
- const char *ptr;
- char stopchars[128];
- int i, n;
- XdgGlobHashNode *node;
-
- /* First, check the literals */
-
- assert (file_name != NULL && n_mime_types > 0);
-
- for (list = glob_hash->literal_list; list; list = list->next)
- {
- if (strcmp ((const char *)list->data, file_name) == 0)
- {
- mime_types[0] = list->mime_type;
- return 1;
- }
- }
-
- i = 0;
- for (node = glob_hash->simple_node; node; node = node->next)
- {
- if (node->character < 128)
- stopchars[i++] = (char)node->character;
- }
- stopchars[i] = '\0';
-
- ptr = strpbrk (file_name, stopchars);
- while (ptr)
- {
- n = _xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, ptr, FALSE,
- mime_types, n_mime_types);
- if (n > 0)
- return n;
-
- n = _xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, ptr, TRUE,
- mime_types, n_mime_types);
- if (n > 0)
- return n;
-
- ptr = strpbrk (ptr + 1, stopchars);
- }
-
- /* FIXME: Not UTF-8 safe */
- n = 0;
- for (list = glob_hash->full_list; list && n < n_mime_types; list = list->next)
- {
- if (fnmatch ((const char *)list->data, file_name, 0) == 0)
- mime_types[n++] = list->mime_type;
- }
-
- return n;
-}
-
-
-
-/* XdgGlobHash
- */
-
-XdgGlobHash *
-_xdg_glob_hash_new (void)
-{
- XdgGlobHash *glob_hash;
-
- glob_hash = calloc (1, sizeof (XdgGlobHash));
-
- return glob_hash;
-}
-
-
-static void
-_xdg_glob_hash_free_nodes (XdgGlobHashNode *node)
-{
- if (node)
- {
- if (node->child)
- _xdg_glob_hash_free_nodes (node->child);
- if (node->next)
- _xdg_glob_hash_free_nodes (node->next);
- if (node->mime_type)
- free ((void *) node->mime_type);
- free (node);
- }
-}
-
-void
-_xdg_glob_hash_free (XdgGlobHash *glob_hash)
-{
- _xdg_glob_list_free (glob_hash->literal_list);
- _xdg_glob_list_free (glob_hash->full_list);
- _xdg_glob_hash_free_nodes (glob_hash->simple_node);
- free (glob_hash);
-}
-
-XdgGlobType
-_xdg_glob_determine_type (const char *glob)
-{
- const char *ptr;
- int maybe_in_simple_glob = FALSE;
- int first_char = TRUE;
-
- ptr = glob;
-
- while (*ptr != '\000')
- {
- if (*ptr == '*' && first_char)
- maybe_in_simple_glob = TRUE;
- else if (*ptr == '\\' || *ptr == '[' || *ptr == '?' || *ptr == '*')
- return XDG_GLOB_FULL;
-
- first_char = FALSE;
- ptr = _xdg_utf8_next_char (ptr);
- }
- if (maybe_in_simple_glob)
- return XDG_GLOB_SIMPLE;
- else
- return XDG_GLOB_LITERAL;
-}
-
-/* glob must be valid UTF-8 */
-void
-_xdg_glob_hash_append_glob (XdgGlobHash *glob_hash,
- const char *glob,
- const char *mime_type)
-{
- XdgGlobType type;
-
- assert (glob_hash != NULL);
- assert (glob != NULL);
-
- type = _xdg_glob_determine_type (glob);
-
- switch (type)
- {
- case XDG_GLOB_LITERAL:
- glob_hash->literal_list = _xdg_glob_list_append (glob_hash->literal_list, strdup (glob), strdup (mime_type));
- break;
- case XDG_GLOB_SIMPLE:
- glob_hash->simple_node = _xdg_glob_hash_insert_text (glob_hash->simple_node, glob + 1, mime_type);
- break;
- case XDG_GLOB_FULL:
- glob_hash->full_list = _xdg_glob_list_append (glob_hash->full_list, strdup (glob), strdup (mime_type));
- break;
- }
-}
-
-void
-_xdg_glob_hash_dump (XdgGlobHash *glob_hash)
-{
- XdgGlobList *list;
- printf ("LITERAL STRINGS\n");
- if (glob_hash->literal_list == NULL)
- {
- printf (" None\n");
- }
- else
- {
- for (list = glob_hash->literal_list; list; list = list->next)
- printf (" %s - %s\n", (char *)list->data, list->mime_type);
- }
- printf ("\nSIMPLE GLOBS\n");
- _xdg_glob_hash_node_dump (glob_hash->simple_node, 4);
-
- printf ("\nFULL GLOBS\n");
- if (glob_hash->full_list == NULL)
- {
- printf (" None\n");
- }
- else
- {
- for (list = glob_hash->full_list; list; list = list->next)
- printf (" %s - %s\n", (char *)list->data, list->mime_type);
- }
-}
-
-
-void
-_xdg_mime_glob_read_from_file (XdgGlobHash *glob_hash,
- const char *file_name)
-{
- FILE *glob_file;
- char line[255];
-
- glob_file = fopen (file_name, "r");
-
- if (glob_file == NULL)
- return;
-
- /* FIXME: Not UTF-8 safe. Doesn't work if lines are greater than 255 chars.
- * Blah */
- while (fgets (line, 255, glob_file) != NULL)
- {
- char *colon;
- if (line[0] == '#')
- continue;
-
- colon = strchr (line, ':');
- if (colon == NULL)
- continue;
- *(colon++) = '\000';
- colon[strlen (colon) -1] = '\000';
- _xdg_glob_hash_append_glob (glob_hash, colon, line);
- }
-
- fclose (glob_file);
-}
diff --git a/gio/xdgmime/xdgmimeglob.h b/gio/xdgmime/xdgmimeglob.h
deleted file mode 100644
index 25a1f20e..00000000
--- a/gio/xdgmime/xdgmimeglob.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimeglob.h: Private file. Datastructure for storing the globs.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XDG_MIME_GLOB_H__
-#define __XDG_MIME_GLOB_H__
-
-#include "xdgmime.h"
-
-typedef struct XdgGlobHash XdgGlobHash;
-
-typedef enum
-{
- XDG_GLOB_LITERAL, /* Makefile */
- XDG_GLOB_SIMPLE, /* *.gif */
- XDG_GLOB_FULL /* x*.[ch] */
-} XdgGlobType;
-
-
-#ifdef XDG_PREFIX
-#define _xdg_mime_glob_read_from_file XDG_ENTRY(glob_read_from_file)
-#define _xdg_glob_hash_new XDG_ENTRY(hash_new)
-#define _xdg_glob_hash_free XDG_ENTRY(hash_free)
-#define _xdg_glob_hash_lookup_file_name XDG_ENTRY(hash_lookup_file_name)
-#define _xdg_glob_hash_append_glob XDG_ENTRY(hash_append_glob)
-#define _xdg_glob_determine_type XDG_ENTRY(determine_type)
-#define _xdg_glob_hash_dump XDG_ENTRY(hash_dump)
-#endif
-
-void _xdg_mime_glob_read_from_file (XdgGlobHash *glob_hash,
- const char *file_name);
-XdgGlobHash *_xdg_glob_hash_new (void);
-void _xdg_glob_hash_free (XdgGlobHash *glob_hash);
-int _xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash,
- const char *text,
- const char *mime_types[],
- int n_mime_types);
-void _xdg_glob_hash_append_glob (XdgGlobHash *glob_hash,
- const char *glob,
- const char *mime_type);
-XdgGlobType _xdg_glob_determine_type (const char *glob);
-void _xdg_glob_hash_dump (XdgGlobHash *glob_hash);
-
-#endif /* __XDG_MIME_GLOB_H__ */
diff --git a/gio/xdgmime/xdgmimeint.c b/gio/xdgmime/xdgmimeint.c
deleted file mode 100644
index 4a0ac4cc..00000000
--- a/gio/xdgmime/xdgmimeint.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimeint.c: Internal defines and functions.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "xdgmimeint.h"
-#include <ctype.h>
-#include <string.h>
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-static const char _xdg_utf8_skip_data[256] = {
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
-};
-
-const char * const _xdg_utf8_skip = _xdg_utf8_skip_data;
-
-
-
-/* Returns the number of unprocessed characters. */
-xdg_unichar_t
-_xdg_utf8_to_ucs4(const char *source)
-{
- xdg_unichar_t ucs32;
- if( ! ( *source & 0x80 ) )
- {
- ucs32 = *source;
- }
- else
- {
- int bytelength = 0;
- xdg_unichar_t result;
- if ( ! (*source & 0x40) )
- {
- ucs32 = *source;
- }
- else
- {
- if ( ! (*source & 0x20) )
- {
- result = *source++ & 0x1F;
- bytelength = 2;
- }
- else if ( ! (*source & 0x10) )
- {
- result = *source++ & 0x0F;
- bytelength = 3;
- }
- else if ( ! (*source & 0x08) )
- {
- result = *source++ & 0x07;
- bytelength = 4;
- }
- else if ( ! (*source & 0x04) )
- {
- result = *source++ & 0x03;
- bytelength = 5;
- }
- else if ( ! (*source & 0x02) )
- {
- result = *source++ & 0x01;
- bytelength = 6;
- }
- else
- {
- result = *source++;
- bytelength = 1;
- }
-
- for ( bytelength --; bytelength > 0; bytelength -- )
- {
- result <<= 6;
- result |= *source++ & 0x3F;
- }
- ucs32 = result;
- }
- }
- return ucs32;
-}
-
-
-/* hullo. this is great code. don't rewrite it */
-
-xdg_unichar_t
-_xdg_ucs4_to_lower (xdg_unichar_t source)
-{
- /* FIXME: Do a real to_upper sometime */
- /* CaseFolding-3.2.0.txt has a table of rules. */
- if ((source & 0xFF) == source)
- return (xdg_unichar_t) tolower ((unsigned char) source);
- return source;
-}
-
-int
-_xdg_utf8_validate (const char *source)
-{
- /* FIXME: actually write */
- return TRUE;
-}
-
-const char *
-_xdg_get_base_name (const char *file_name)
-{
- const char *base_name;
-
- if (file_name == NULL)
- return NULL;
-
- base_name = strrchr (file_name, '/');
-
- if (base_name == NULL)
- return file_name;
- else
- return base_name + 1;
-}
diff --git a/gio/xdgmime/xdgmimeint.h b/gio/xdgmime/xdgmimeint.h
deleted file mode 100644
index 28814871..00000000
--- a/gio/xdgmime/xdgmimeint.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimeint.h: Internal defines and functions.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XDG_MIME_INT_H__
-#define __XDG_MIME_INT_H__
-
-#include "xdgmime.h"
-
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-/* FIXME: Needs to be configure check */
-typedef unsigned int xdg_unichar_t;
-typedef unsigned char xdg_uchar8_t;
-typedef unsigned short xdg_uint16_t;
-typedef unsigned int xdg_uint32_t;
-
-#ifdef XDG_PREFIX
-#define _xdg_utf8_skip XDG_ENTRY(utf8_skip)
-#define _xdg_utf8_to_ucs4 XDG_ENTRY(utf8_to_ucs4)
-#define _xdg_ucs4_to_lower XDG_ENTRY(ucs4_to_lower)
-#define _xdg_utf8_validate XDG_ENTRY(utf8_validate)
-#define _xdg_get_base_name XDG_ENTRY(get_ase_name)
-#endif
-
-#define SWAP_BE16_TO_LE16(val) (xdg_uint16_t)(((xdg_uint16_t)(val) << 8)|((xdg_uint16_t)(val) >> 8))
-
-#define SWAP_BE32_TO_LE32(val) (xdg_uint32_t)((((xdg_uint32_t)(val) & 0xFF000000U) >> 24) | \
- (((xdg_uint32_t)(val) & 0x00FF0000U) >> 8) | \
- (((xdg_uint32_t)(val) & 0x0000FF00U) << 8) | \
- (((xdg_uint32_t)(val) & 0x000000FFU) << 24))
-/* UTF-8 utils
- */
-extern const char *const _xdg_utf8_skip;
-#define _xdg_utf8_next_char(p) (char *)((p) + _xdg_utf8_skip[*(unsigned char *)(p)])
-#define _xdg_utf8_char_size(p) (int) (_xdg_utf8_skip[*(unsigned char *)(p)])
-
-xdg_unichar_t _xdg_utf8_to_ucs4 (const char *source);
-xdg_unichar_t _xdg_ucs4_to_lower (xdg_unichar_t source);
-int _xdg_utf8_validate (const char *source);
-const char *_xdg_get_base_name (const char *file_name);
-
-#endif /* __XDG_MIME_INT_H__ */
diff --git a/gio/xdgmime/xdgmimemagic.c b/gio/xdgmime/xdgmimemagic.c
deleted file mode 100644
index a2320f58..00000000
--- a/gio/xdgmime/xdgmimemagic.c
+++ /dev/null
@@ -1,813 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimemagic.: Private file. Datastructure for storing magic files.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <assert.h>
-#include "xdgmimemagic.h"
-#include "xdgmimeint.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-#if !defined getc_unlocked && !defined HAVE_GETC_UNLOCKED
-# define getc_unlocked(fp) getc (fp)
-#endif
-
-typedef struct XdgMimeMagicMatch XdgMimeMagicMatch;
-typedef struct XdgMimeMagicMatchlet XdgMimeMagicMatchlet;
-
-typedef enum
-{
- XDG_MIME_MAGIC_SECTION,
- XDG_MIME_MAGIC_MAGIC,
- XDG_MIME_MAGIC_ERROR,
- XDG_MIME_MAGIC_EOF
-} XdgMimeMagicState;
-
-struct XdgMimeMagicMatch
-{
- const char *mime_type;
- int priority;
- XdgMimeMagicMatchlet *matchlet;
- XdgMimeMagicMatch *next;
-};
-
-
-struct XdgMimeMagicMatchlet
-{
- int indent;
- int offset;
- unsigned int value_length;
- unsigned char *value;
- unsigned char *mask;
- unsigned int range_length;
- unsigned int word_size;
- XdgMimeMagicMatchlet *next;
-};
-
-
-struct XdgMimeMagic
-{
- XdgMimeMagicMatch *match_list;
- int max_extent;
-};
-
-static XdgMimeMagicMatch *
-_xdg_mime_magic_match_new (void)
-{
- return calloc (1, sizeof (XdgMimeMagicMatch));
-}
-
-
-static XdgMimeMagicMatchlet *
-_xdg_mime_magic_matchlet_new (void)
-{
- XdgMimeMagicMatchlet *matchlet;
-
- matchlet = malloc (sizeof (XdgMimeMagicMatchlet));
-
- matchlet->indent = 0;
- matchlet->offset = 0;
- matchlet->value_length = 0;
- matchlet->value = NULL;
- matchlet->mask = NULL;
- matchlet->range_length = 1;
- matchlet->word_size = 1;
- matchlet->next = NULL;
-
- return matchlet;
-}
-
-
-static void
-_xdg_mime_magic_matchlet_free (XdgMimeMagicMatchlet *mime_magic_matchlet)
-{
- if (mime_magic_matchlet)
- {
- if (mime_magic_matchlet->next)
- _xdg_mime_magic_matchlet_free (mime_magic_matchlet->next);
- if (mime_magic_matchlet->value)
- free (mime_magic_matchlet->value);
- if (mime_magic_matchlet->mask)
- free (mime_magic_matchlet->mask);
- free (mime_magic_matchlet);
- }
-}
-
-
-/* Frees mime_magic_match and the remainder of its list
- */
-static void
-_xdg_mime_magic_match_free (XdgMimeMagicMatch *mime_magic_match)
-{
- XdgMimeMagicMatch *ptr, *next;
-
- ptr = mime_magic_match;
- while (ptr)
- {
- next = ptr->next;
-
- if (ptr->mime_type)
- free ((void *) ptr->mime_type);
- if (ptr->matchlet)
- _xdg_mime_magic_matchlet_free (ptr->matchlet);
- free (ptr);
-
- ptr = next;
- }
-}
-
-/* Reads in a hunk of data until a newline character or a '\000' is hit. The
- * returned string is null terminated, and doesn't include the newline.
- */
-static unsigned char *
-_xdg_mime_magic_read_to_newline (FILE *magic_file,
- int *end_of_file)
-{
- unsigned char *retval;
- int c;
- int len, pos;
-
- len = 128;
- pos = 0;
- retval = malloc (len);
- *end_of_file = FALSE;
-
- while (TRUE)
- {
- c = getc_unlocked (magic_file);
- if (c == EOF)
- {
- *end_of_file = TRUE;
- break;
- }
- if (c == '\n' || c == '\000')
- break;
- retval[pos++] = (unsigned char) c;
- if (pos % 128 == 127)
- {
- len = len + 128;
- retval = realloc (retval, len);
- }
- }
-
- retval[pos] = '\000';
- return retval;
-}
-
-/* Returns the number read from the file, or -1 if no number could be read.
- */
-static int
-_xdg_mime_magic_read_a_number (FILE *magic_file,
- int *end_of_file)
-{
- /* LONG_MAX is about 20 characters on my system */
-#define MAX_NUMBER_SIZE 30
- char number_string[MAX_NUMBER_SIZE + 1];
- int pos = 0;
- int c;
- long retval = -1;
-
- while (TRUE)
- {
- c = getc_unlocked (magic_file);
-
- if (c == EOF)
- {
- *end_of_file = TRUE;
- break;
- }
- if (! isdigit (c))
- {
- ungetc (c, magic_file);
- break;
- }
- number_string[pos] = (char) c;
- pos++;
- if (pos == MAX_NUMBER_SIZE)
- break;
- }
- if (pos > 0)
- {
- number_string[pos] = '\000';
- errno = 0;
- retval = strtol (number_string, NULL, 10);
-
- if ((retval < INT_MIN) || (retval > INT_MAX) || (errno != 0))
- return -1;
- }
-
- return retval;
-}
-
-/* Headers are of the format:
- * [<priority>:<mime-type>]
- */
-static XdgMimeMagicState
-_xdg_mime_magic_parse_header (FILE *magic_file, XdgMimeMagicMatch *match)
-{
- int c;
- char *buffer;
- char *end_ptr;
- int end_of_file = 0;
-
- assert (magic_file != NULL);
- assert (match != NULL);
-
- c = getc_unlocked (magic_file);
- if (c == EOF)
- return XDG_MIME_MAGIC_EOF;
- if (c != '[')
- return XDG_MIME_MAGIC_ERROR;
-
- match->priority = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
- if (end_of_file)
- return XDG_MIME_MAGIC_EOF;
- if (match->priority == -1)
- return XDG_MIME_MAGIC_ERROR;
-
- c = getc_unlocked (magic_file);
- if (c == EOF)
- return XDG_MIME_MAGIC_EOF;
- if (c != ':')
- return XDG_MIME_MAGIC_ERROR;
-
- buffer = (char *)_xdg_mime_magic_read_to_newline (magic_file, &end_of_file);
- if (end_of_file)
- return XDG_MIME_MAGIC_EOF;
-
- end_ptr = buffer;
- while (*end_ptr != ']' && *end_ptr != '\000' && *end_ptr != '\n')
- end_ptr++;
- if (*end_ptr != ']')
- {
- free (buffer);
- return XDG_MIME_MAGIC_ERROR;
- }
- *end_ptr = '\000';
-
- match->mime_type = strdup (buffer);
- free (buffer);
-
- return XDG_MIME_MAGIC_MAGIC;
-}
-
-static XdgMimeMagicState
-_xdg_mime_magic_parse_error (FILE *magic_file)
-{
- int c;
-
- while (1)
- {
- c = getc_unlocked (magic_file);
- if (c == EOF)
- return XDG_MIME_MAGIC_EOF;
- if (c == '\n')
- return XDG_MIME_MAGIC_SECTION;
- }
-}
-
-/* Headers are of the format:
- * [ indent ] ">" start-offset "=" value
- * [ "&" mask ] [ "~" word-size ] [ "+" range-length ] "\n"
- */
-static XdgMimeMagicState
-_xdg_mime_magic_parse_magic_line (FILE *magic_file,
- XdgMimeMagicMatch *match)
-{
- XdgMimeMagicMatchlet *matchlet;
- int c;
- int end_of_file;
- int indent = 0;
- int bytes_read;
-
- assert (magic_file != NULL);
-
- /* Sniff the buffer to make sure it's a valid line */
- c = getc_unlocked (magic_file);
- if (c == EOF)
- return XDG_MIME_MAGIC_EOF;
- else if (c == '[')
- {
- ungetc (c, magic_file);
- return XDG_MIME_MAGIC_SECTION;
- }
- else if (c == '\n')
- return XDG_MIME_MAGIC_MAGIC;
-
- /* At this point, it must be a digit or a '>' */
- end_of_file = FALSE;
- if (isdigit (c))
- {
- ungetc (c, magic_file);
- indent = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
- if (end_of_file)
- return XDG_MIME_MAGIC_EOF;
- if (indent == -1)
- return XDG_MIME_MAGIC_ERROR;
- c = getc_unlocked (magic_file);
- if (c == EOF)
- return XDG_MIME_MAGIC_EOF;
- }
-
- if (c != '>')
- return XDG_MIME_MAGIC_ERROR;
-
- matchlet = _xdg_mime_magic_matchlet_new ();
- matchlet->indent = indent;
- matchlet->offset = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
- if (end_of_file)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_EOF;
- }
- if (matchlet->offset == -1)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_ERROR;
- }
- c = getc_unlocked (magic_file);
- if (c == EOF)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_EOF;
- }
- else if (c != '=')
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_ERROR;
- }
-
- /* Next two bytes determine how long the value is */
- matchlet->value_length = 0;
- c = getc_unlocked (magic_file);
- if (c == EOF)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_EOF;
- }
- matchlet->value_length = c & 0xFF;
- matchlet->value_length = matchlet->value_length << 8;
-
- c = getc_unlocked (magic_file);
- if (c == EOF)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_EOF;
- }
- matchlet->value_length = matchlet->value_length + (c & 0xFF);
-
- matchlet->value = malloc (matchlet->value_length);
-
- /* OOM */
- if (matchlet->value == NULL)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_ERROR;
- }
- bytes_read = fread (matchlet->value, 1, matchlet->value_length, magic_file);
- if (bytes_read != matchlet->value_length)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- if (feof (magic_file))
- return XDG_MIME_MAGIC_EOF;
- else
- return XDG_MIME_MAGIC_ERROR;
- }
-
- c = getc_unlocked (magic_file);
- if (c == '&')
- {
- matchlet->mask = malloc (matchlet->value_length);
- /* OOM */
- if (matchlet->mask == NULL)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_ERROR;
- }
- bytes_read = fread (matchlet->mask, 1, matchlet->value_length, magic_file);
- if (bytes_read != matchlet->value_length)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- if (feof (magic_file))
- return XDG_MIME_MAGIC_EOF;
- else
- return XDG_MIME_MAGIC_ERROR;
- }
- c = getc_unlocked (magic_file);
- }
-
- if (c == '~')
- {
- matchlet->word_size = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
- if (end_of_file)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_EOF;
- }
- if (matchlet->word_size != 0 &&
- matchlet->word_size != 1 &&
- matchlet->word_size != 2 &&
- matchlet->word_size != 4)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_ERROR;
- }
- c = getc_unlocked (magic_file);
- }
-
- if (c == '+')
- {
- matchlet->range_length = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
- if (end_of_file)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_EOF;
- }
- if (matchlet->range_length == -1)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_ERROR;
- }
- c = getc_unlocked (magic_file);
- }
-
-
- if (c == '\n')
- {
- /* We clean up the matchlet, byte swapping if needed */
- if (matchlet->word_size > 1)
- {
- int i;
- if (matchlet->value_length % matchlet->word_size != 0)
- {
- _xdg_mime_magic_matchlet_free (matchlet);
- return XDG_MIME_MAGIC_ERROR;
- }
- /* FIXME: need to get this defined in a <config.h> style file */
-#if LITTLE_ENDIAN
- for (i = 0; i < matchlet->value_length; i = i + matchlet->word_size)
- {
- if (matchlet->word_size == 2)
- *((xdg_uint16_t *) matchlet->value + i) = SWAP_BE16_TO_LE16 (*((xdg_uint16_t *) (matchlet->value + i)));
- else if (matchlet->word_size == 4)
- *((xdg_uint32_t *) matchlet->value + i) = SWAP_BE32_TO_LE32 (*((xdg_uint32_t *) (matchlet->value + i)));
- if (matchlet->mask)
- {
- if (matchlet->word_size == 2)
- *((xdg_uint16_t *) matchlet->mask + i) = SWAP_BE16_TO_LE16 (*((xdg_uint16_t *) (matchlet->mask + i)));
- else if (matchlet->word_size == 4)
- *((xdg_uint32_t *) matchlet->mask + i) = SWAP_BE32_TO_LE32 (*((xdg_uint32_t *) (matchlet->mask + i)));
-
- }
- }
-#endif
- }
-
- matchlet->next = match->matchlet;
- match->matchlet = matchlet;
-
-
- return XDG_MIME_MAGIC_MAGIC;
- }
-
- _xdg_mime_magic_matchlet_free (matchlet);
- if (c == EOF)
- return XDG_MIME_MAGIC_EOF;
-
- return XDG_MIME_MAGIC_ERROR;
-}
-
-static int
-_xdg_mime_magic_matchlet_compare_to_data (XdgMimeMagicMatchlet *matchlet,
- const void *data,
- size_t len)
-{
- int i, j;
- for (i = matchlet->offset; i < matchlet->offset + matchlet->range_length; i++)
- {
- int valid_matchlet = TRUE;
-
- if (i + matchlet->value_length > len)
- return FALSE;
-
- if (matchlet->mask)
- {
- for (j = 0; j < matchlet->value_length; j++)
- {
- if ((matchlet->value[j] & matchlet->mask[j]) !=
- ((((unsigned char *) data)[j + i]) & matchlet->mask[j]))
- {
- valid_matchlet = FALSE;
- break;
- }
- }
- }
- else
- {
- for (j = 0; j < matchlet->value_length; j++)
- {
- if (matchlet->value[j] != ((unsigned char *) data)[j + i])
- {
- valid_matchlet = FALSE;
- break;
- }
- }
- }
- if (valid_matchlet)
- return TRUE;
- }
- return FALSE;
-}
-
-static int
-_xdg_mime_magic_matchlet_compare_level (XdgMimeMagicMatchlet *matchlet,
- const void *data,
- size_t len,
- int indent)
-{
- while ((matchlet != NULL) && (matchlet->indent == indent))
- {
- if (_xdg_mime_magic_matchlet_compare_to_data (matchlet, data, len))
- {
- if ((matchlet->next == NULL) ||
- (matchlet->next->indent <= indent))
- return TRUE;
-
- if (_xdg_mime_magic_matchlet_compare_level (matchlet->next,
- data,
- len,
- indent + 1))
- return TRUE;
- }
-
- do
- {
- matchlet = matchlet->next;
- }
- while (matchlet && matchlet->indent > indent);
- }
-
- return FALSE;
-}
-
-static int
-_xdg_mime_magic_match_compare_to_data (XdgMimeMagicMatch *match,
- const void *data,
- size_t len)
-{
- return _xdg_mime_magic_matchlet_compare_level (match->matchlet, data, len, 0);
-}
-
-static void
-_xdg_mime_magic_insert_match (XdgMimeMagic *mime_magic,
- XdgMimeMagicMatch *match)
-{
- XdgMimeMagicMatch *list;
-
- if (mime_magic->match_list == NULL)
- {
- mime_magic->match_list = match;
- return;
- }
-
- if (match->priority > mime_magic->match_list->priority)
- {
- match->next = mime_magic->match_list;
- mime_magic->match_list = match;
- return;
- }
-
- list = mime_magic->match_list;
- while (list->next != NULL)
- {
- if (list->next->priority < match->priority)
- {
- match->next = list->next;
- list->next = match;
- return;
- }
- list = list->next;
- }
- list->next = match;
- match->next = NULL;
-}
-
-XdgMimeMagic *
-_xdg_mime_magic_new (void)
-{
- return calloc (1, sizeof (XdgMimeMagic));
-}
-
-void
-_xdg_mime_magic_free (XdgMimeMagic *mime_magic)
-{
- if (mime_magic) {
- _xdg_mime_magic_match_free (mime_magic->match_list);
- free (mime_magic);
- }
-}
-
-int
-_xdg_mime_magic_get_buffer_extents (XdgMimeMagic *mime_magic)
-{
- return mime_magic->max_extent;
-}
-
-const char *
-_xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
- const void *data,
- size_t len,
- int *result_prio,
- const char *mime_types[],
- int n_mime_types)
-{
- XdgMimeMagicMatch *match;
- const char *mime_type;
- int n;
- int prio;
-
- prio = 0;
- mime_type = NULL;
- for (match = mime_magic->match_list; match; match = match->next)
- {
- if (_xdg_mime_magic_match_compare_to_data (match, data, len))
- {
- prio = match->priority;
- mime_type = match->mime_type;
- break;
- }
- else
- {
- for (n = 0; n < n_mime_types; n++)
- {
- if (mime_types[n] &&
- _xdg_mime_mime_type_equal (mime_types[n], match->mime_type))
- mime_types[n] = NULL;
- }
- }
- }
-
- if (mime_type == NULL)
- {
- for (n = 0; n < n_mime_types; n++)
- {
- if (mime_types[n])
- mime_type = mime_types[n];
- }
- }
-
- if (result_prio)
- *result_prio = prio;
-
- return mime_type;
-}
-
-static void
-_xdg_mime_update_mime_magic_extents (XdgMimeMagic *mime_magic)
-{
- XdgMimeMagicMatch *match;
- int max_extent = 0;
-
- for (match = mime_magic->match_list; match; match = match->next)
- {
- XdgMimeMagicMatchlet *matchlet;
-
- for (matchlet = match->matchlet; matchlet; matchlet = matchlet->next)
- {
- int extent;
-
- extent = matchlet->value_length + matchlet->offset + matchlet->range_length;
- if (max_extent < extent)
- max_extent = extent;
- }
- }
-
- mime_magic->max_extent = max_extent;
-}
-
-static XdgMimeMagicMatchlet *
-_xdg_mime_magic_matchlet_mirror (XdgMimeMagicMatchlet *matchlets)
-{
- XdgMimeMagicMatchlet *new_list;
- XdgMimeMagicMatchlet *tmp;
-
- if ((matchlets == NULL) || (matchlets->next == NULL))
- return matchlets;
-
- new_list = NULL;
- tmp = matchlets;
- while (tmp != NULL)
- {
- XdgMimeMagicMatchlet *matchlet;
-
- matchlet = tmp;
- tmp = tmp->next;
- matchlet->next = new_list;
- new_list = matchlet;
- }
-
- return new_list;
-
-}
-
-static void
-_xdg_mime_magic_read_magic_file (XdgMimeMagic *mime_magic,
- FILE *magic_file)
-{
- XdgMimeMagicState state;
- XdgMimeMagicMatch *match = NULL; /* Quiet compiler */
-
- state = XDG_MIME_MAGIC_SECTION;
-
- while (state != XDG_MIME_MAGIC_EOF)
- {
- switch (state)
- {
- case XDG_MIME_MAGIC_SECTION:
- match = _xdg_mime_magic_match_new ();
- state = _xdg_mime_magic_parse_header (magic_file, match);
- if (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_ERROR)
- _xdg_mime_magic_match_free (match);
- break;
- case XDG_MIME_MAGIC_MAGIC:
- state = _xdg_mime_magic_parse_magic_line (magic_file, match);
- if (state == XDG_MIME_MAGIC_SECTION ||
- (state == XDG_MIME_MAGIC_EOF && match->mime_type))
- {
- match->matchlet = _xdg_mime_magic_matchlet_mirror (match->matchlet);
- _xdg_mime_magic_insert_match (mime_magic, match);
- }
- else if (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_ERROR)
- _xdg_mime_magic_match_free (match);
- break;
- case XDG_MIME_MAGIC_ERROR:
- state = _xdg_mime_magic_parse_error (magic_file);
- break;
- case XDG_MIME_MAGIC_EOF:
- default:
- /* Make the compiler happy */
- assert (0);
- }
- }
- _xdg_mime_update_mime_magic_extents (mime_magic);
-}
-
-void
-_xdg_mime_magic_read_from_file (XdgMimeMagic *mime_magic,
- const char *file_name)
-{
- FILE *magic_file;
- char header[12];
-
- magic_file = fopen (file_name, "r");
-
- if (magic_file == NULL)
- return;
-
- if (fread (header, 1, 12, magic_file) == 12)
- {
- if (memcmp ("MIME-Magic\0\n", header, 12) == 0)
- _xdg_mime_magic_read_magic_file (mime_magic, magic_file);
- }
-
- fclose (magic_file);
-}
diff --git a/gio/xdgmime/xdgmimemagic.h b/gio/xdgmime/xdgmimemagic.h
deleted file mode 100644
index 8f113051..00000000
--- a/gio/xdgmime/xdgmimemagic.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimemagic.h: Private file. Datastructure for storing the magic files.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XDG_MIME_MAGIC_H__
-#define __XDG_MIME_MAGIC_H__
-
-#include <unistd.h>
-#include "xdgmime.h"
-typedef struct XdgMimeMagic XdgMimeMagic;
-
-#ifdef XDG_PREFIX
-#define _xdg_mime_glob_read_from_file XDG_ENTRY(glob_read_from_file)
-#define _xdg_mime_magic_new XDG_ENTRY(magic_new)
-#define _xdg_mime_magic_read_from_file XDG_ENTRY(magic_read_from_file)
-#define _xdg_mime_magic_free XDG_ENTRY(magic_free)
-#define _xdg_mime_magic_get_buffer_extents XDG_ENTRY(magic_get_buffer_extents)
-#define _xdg_mime_magic_lookup_data XDG_ENTRY(magic_lookup_data)
-#endif
-
-
-XdgMimeMagic *_xdg_mime_magic_new (void);
-void _xdg_mime_magic_read_from_file (XdgMimeMagic *mime_magic,
- const char *file_name);
-void _xdg_mime_magic_free (XdgMimeMagic *mime_magic);
-int _xdg_mime_magic_get_buffer_extents (XdgMimeMagic *mime_magic);
-const char *_xdg_mime_magic_lookup_data (XdgMimeMagic *mime_magic,
- const void *data,
- size_t len,
- int *result_prio,
- const char *mime_types[],
- int n_mime_types);
-
-#endif /* __XDG_MIME_MAGIC_H__ */
diff --git a/gio/xdgmime/xdgmimeparent.c b/gio/xdgmime/xdgmimeparent.c
deleted file mode 100644
index 511bbacb..00000000
--- a/gio/xdgmime/xdgmimeparent.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimealias.c: Private file. Datastructure for storing the hierarchy.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2004 Red Hat, Inc.
- * Copyright (C) 2004 Matthias Clasen <mclasen@redhat.com>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "xdgmimeparent.h"
-#include "xdgmimeint.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-#include <fnmatch.h>
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-typedef struct XdgMimeParents XdgMimeParents;
-
-struct XdgMimeParents
-{
- char *mime;
- char **parents;
- int n_parents;
-};
-
-struct XdgParentList
-{
- struct XdgMimeParents *parents;
- int n_mimes;
-};
-
-XdgParentList *
-_xdg_mime_parent_list_new (void)
-{
- XdgParentList *list;
-
- list = malloc (sizeof (XdgParentList));
-
- list->parents = NULL;
- list->n_mimes = 0;
-
- return list;
-}
-
-void
-_xdg_mime_parent_list_free (XdgParentList *list)
-{
- int i;
- char **p;
-
- if (list->parents)
- {
- for (i = 0; i < list->n_mimes; i++)
- {
- for (p = list->parents[i].parents; *p; p++)
- free (*p);
-
- free (list->parents[i].parents);
- free (list->parents[i].mime);
- }
- free (list->parents);
- }
- free (list);
-}
-
-static int
-parent_entry_cmp (const void *v1, const void *v2)
-{
- return strcmp (((XdgMimeParents *)v1)->mime, ((XdgMimeParents *)v2)->mime);
-}
-
-const char **
-_xdg_mime_parent_list_lookup (XdgParentList *list,
- const char *mime)
-{
- XdgMimeParents *entry;
- XdgMimeParents key;
-
- if (list->n_mimes > 0)
- {
- key.mime = (char *)mime;
- key.parents = NULL;
-
- entry = bsearch (&key, list->parents, list->n_mimes,
- sizeof (XdgMimeParents), &parent_entry_cmp);
- if (entry)
- return (const char **)entry->parents;
- }
-
- return NULL;
-}
-
-void
-_xdg_mime_parent_read_from_file (XdgParentList *list,
- const char *file_name)
-{
- FILE *file;
- char line[255];
- int i, alloc;
- XdgMimeParents *entry;
-
- file = fopen (file_name, "r");
-
- if (file == NULL)
- return;
-
- /* FIXME: Not UTF-8 safe. Doesn't work if lines are greater than 255 chars.
- * Blah */
- alloc = list->n_mimes + 16;
- list->parents = realloc (list->parents, alloc * sizeof (XdgMimeParents));
- while (fgets (line, 255, file) != NULL)
- {
- char *sep;
- if (line[0] == '#')
- continue;
-
- sep = strchr (line, ' ');
- if (sep == NULL)
- continue;
- *(sep++) = '\000';
- sep[strlen (sep) -1] = '\000';
- entry = NULL;
- for (i = 0; i < list->n_mimes; i++)
- {
- if (strcmp (list->parents[i].mime, line) == 0)
- {
- entry = &(list->parents[i]);
- break;
- }
- }
-
- if (!entry)
- {
- if (list->n_mimes == alloc)
- {
- alloc <<= 1;
- list->parents = realloc (list->parents,
- alloc * sizeof (XdgMimeParents));
- }
- list->parents[list->n_mimes].mime = strdup (line);
- list->parents[list->n_mimes].parents = NULL;
- entry = &(list->parents[list->n_mimes]);
- list->n_mimes++;
- }
-
- if (!entry->parents)
- {
- entry->n_parents = 1;
- entry->parents = malloc ((entry->n_parents + 1) * sizeof (char *));
- }
- else
- {
- entry->n_parents += 1;
- entry->parents = realloc (entry->parents,
- (entry->n_parents + 2) * sizeof (char *));
- }
- entry->parents[entry->n_parents - 1] = strdup (sep);
- entry->parents[entry->n_parents] = NULL;
- }
-
- list->parents = realloc (list->parents,
- list->n_mimes * sizeof (XdgMimeParents));
-
- fclose (file);
-
- if (list->n_mimes > 1)
- qsort (list->parents, list->n_mimes,
- sizeof (XdgMimeParents), &parent_entry_cmp);
-}
-
-
-void
-_xdg_mime_parent_list_dump (XdgParentList *list)
-{
- int i;
- char **p;
-
- if (list->parents)
- {
- for (i = 0; i < list->n_mimes; i++)
- {
- for (p = list->parents[i].parents; *p; p++)
- printf ("%s %s\n", list->parents[i].mime, *p);
- }
- }
-}
-
-
diff --git a/gio/xdgmime/xdgmimeparent.h b/gio/xdgmime/xdgmimeparent.h
deleted file mode 100644
index 257ea049..00000000
--- a/gio/xdgmime/xdgmimeparent.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* xdgmimeparent.h: Private file. Datastructure for storing the hierarchy.
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2004 Red Hat, Inc.
- * Copyright (C) 200 Matthias Clasen <mclasen@redhat.com>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __XDG_MIME_PARENT_H__
-#define __XDG_MIME_PARENT_H__
-
-#include "xdgmime.h"
-
-typedef struct XdgParentList XdgParentList;
-
-#ifdef XDG_PREFIX
-#define _xdg_mime_parent_read_from_file XDG_ENTRY(parent_read_from_file)
-#define _xdg_mime_parent_list_new XDG_ENTRY(parent_list_new)
-#define _xdg_mime_parent_list_free XDG_ENTRY(parent_list_free)
-#define _xdg_mime_parent_list_lookup XDG_ENTRY(parent_list_lookup)
-#define _xdg_mime_parent_list_dump XDG_ENTRY(parent_list_dump)
-#endif
-
-void _xdg_mime_parent_read_from_file (XdgParentList *list,
- const char *file_name);
-XdgParentList *_xdg_mime_parent_list_new (void);
-void _xdg_mime_parent_list_free (XdgParentList *list);
-const char **_xdg_mime_parent_list_lookup (XdgParentList *list,
- const char *mime);
-void _xdg_mime_parent_list_dump (XdgParentList *list);
-
-#endif /* __XDG_MIME_PARENT_H__ */
diff --git a/programs/.gitignore b/programs/.gitignore
deleted file mode 100644
index 8d28fddf..00000000
--- a/programs/.gitignore
+++ /dev/null
@@ -1,16 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-gvfs-ls
-gvfs-cat
-gvfs-info
-gvfs-mount
-gvfs-create
-gvfs-copy
-gvfs-move
-gvfs-monitor-file
-gvfs-monitor-dir
-gvfs-trash
-gvfs-rm
-gvfs-save
diff --git a/programs/Makefile.am b/programs/Makefile.am
deleted file mode 100644
index 4da2eeb7..00000000
--- a/programs/Makefile.am
+++ /dev/null
@@ -1,58 +0,0 @@
-NULL =
-
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- $(GLIB_CFLAGS) \
- -DG_DISABLE_DEPRECATED
-
-libraries = \
- $(top_builddir)/gio/libgio.la \
- $(GLIB_LIBS)
-
-bin_PROGRAMS = \
- gvfs-mount \
- gvfs-cat \
- gvfs-save \
- gvfs-ls \
- gvfs-info \
- gvfs-trash \
- gvfs-rm \
- gvfs-copy \
- gvfs-move \
- gvfs-monitor-file \
- gvfs-monitor-dir \
- $(NULL)
-
-gvfs_cat_SOURCES = gvfs-cat.c
-gvfs_cat_LDADD = $(libraries)
-
-gvfs_copy_SOURCES = gvfs-copy.c
-gvfs_copy_LDADD = $(libraries)
-
-gvfs_save_SOURCES = gvfs-save.c
-gvfs_save_LDADD = $(libraries)
-
-gvfs_info_SOURCES = gvfs-info.c
-gvfs_info_LDADD = $(libraries)
-
-gvfs_trash_SOURCES = gvfs-trash.c
-gvfs_trash_LDADD = $(libraries)
-
-gvfs_rm_SOURCES = gvfs-rm.c
-gvfs_rm_LDADD = $(libraries)
-
-gvfs_ls_SOURCES = gvfs-ls.c
-gvfs_ls_LDADD = $(libraries)
-
-gvfs_move_SOURCES = gvfs-move.c
-gvfs_move_LDADD = $(libraries)
-
-gvfs_mount_SOURCES = gvfs-mount.c
-gvfs_mount_LDADD = $(libraries)
-
-gvfs_monitor_dir_SOURCES = gvfs-monitor-dir.c
-gvfs_monitor_dir_LDADD = $(libraries)
-
-gvfs_monitor_file_SOURCES = gvfs-monitor-file.c
-gvfs_monitor_file_LDADD = $(libraries)
diff --git a/programs/gvfs-cat.c b/programs/gvfs-cat.c
deleted file mode 100644
index 2f0925b1..00000000
--- a/programs/gvfs-cat.c
+++ /dev/null
@@ -1,105 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <locale.h>
-#include <errno.h>
-
-#include <glib.h>
-#include <gio/gfile.h>
-
-static GOptionEntry entries[] =
-{
- { NULL }
-};
-
-static void
-cat (GFile *file)
-{
- GInputStream *in;
- char buffer[1025];
- char *p;
- gssize res;
- gboolean close_res;
- GError *error;
-
- error = NULL;
- in = (GInputStream *)g_file_read (file, NULL, &error);
- if (in == NULL)
- {
- g_printerr ("Error opening file: %s\n", error->message);
- g_error_free (error);
- return;
- }
-
- while (1)
- {
- res = g_input_stream_read (in, buffer, 1024, NULL, &error);
- if (res > 0)
- {
- ssize_t written;
-
- p = buffer;
- while (res > 0)
- {
- written = write (STDOUT_FILENO, p, res);
-
- if (written == -1 && errno != EINTR)
- {
- perror ("Error writing to stdout");
- goto out;
- }
- res -= written;
- p += written;
- }
- }
- else if (res < 0)
- {
- g_printerr ("Error reading: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- break;
- }
- else if (res == 0)
- break;
- }
-
- out:
-
- close_res = g_input_stream_close (in, NULL, &error);
- if (!close_res)
- {
- g_printerr ("Error closing: %s\n", error->message);
- g_error_free (error);
- }
-}
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- output files at <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc > 1)
- {
- int i;
-
- for (i = 1; i < argc; i++) {
- file = g_file_new_for_commandline_arg (argv[i]);
- cat (file);
- g_object_unref (file);
- }
- }
-
- return 0;
-}
diff --git a/programs/gvfs-copy.c b/programs/gvfs-copy.c
deleted file mode 100644
index 127b5f17..00000000
--- a/programs/gvfs-copy.c
+++ /dev/null
@@ -1,158 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <locale.h>
-#include <errno.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gfile.h>
-
-static gboolean progress = FALSE;
-static gboolean interactive = FALSE;
-static gboolean no_dereference = FALSE;
-static gboolean backup = FALSE;
-static gboolean preserve = FALSE;
-static gboolean no_target_directory = FALSE;
-
-static GOptionEntry entries[] =
-{
- { "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, "no target directory", NULL },
- { "progress", 'p', 0, G_OPTION_ARG_NONE, &progress, "show progress", NULL },
- { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive, "prompt before overwrite", NULL },
- { "preserve", 'p', 0, G_OPTION_ARG_NONE, &preserve, "preserve all attributes", NULL },
- { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, "backup existing destination files", NULL },
- { "no-dereference", 'P', 0, G_OPTION_ARG_NONE, &no_dereference, "never follow symbolic links", NULL },
- { NULL }
-};
-
-static gboolean
-is_dir (GFile *file)
-{
- GFileInfo *info;
- gboolean res;
-
- info = g_file_get_info (file, G_FILE_ATTRIBUTE_STD_TYPE, 0, NULL, NULL);
- res = info && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY;
- if (info)
- g_object_unref (info);
- return res;
-}
-
-static void
-show_progress (goffset current_num_bytes,
- goffset total_num_bytes,
- gpointer user_data)
-{
- g_print ("progress %"G_GUINT64_FORMAT"/%"G_GUINT64_FORMAT"\n",
- current_num_bytes, total_num_bytes);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *source, *dest, *target;
- gboolean dest_is_dir;
- char *basename;
- int i;
- GFileCopyFlags flags;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- output files at <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc <= 2)
- {
- g_printerr ("Missing operand\n");
- return 1;
- }
-
- dest = g_file_new_for_commandline_arg (argv[argc-1]);
-
- if (no_target_directory && argc > 3)
- {
- g_printerr ("Too many arguments\n");
- g_object_unref (dest);
- return 1;
- }
-
- dest_is_dir = is_dir (dest);
-
- if (!dest_is_dir && argc > 3)
- {
- g_printerr ("Target %s is not a directory\n", argv[argc-1]);
- g_object_unref (dest);
- return 1;
- }
-
- for (i = 1; i < argc - 1; i++)
- {
- source = g_file_new_for_commandline_arg (argv[i]);
-
- if (dest_is_dir && !no_target_directory)
- {
- basename = g_file_get_basename (source);
- target = g_file_get_child (dest, basename);
- g_free (basename);
- }
- else
- target = g_object_ref (dest);
-
- flags = 0;
- if (backup)
- flags |= G_FILE_COPY_BACKUP;
- if (!interactive)
- flags |= G_FILE_COPY_OVERWRITE;
- if (no_dereference)
- flags |= G_FILE_COPY_NOFOLLOW_SYMLINKS;
- if (preserve)
- flags |= G_FILE_COPY_ALL_METADATA;
-
-
- error = NULL;
- if (!g_file_copy (source, target, flags, NULL, progress?show_progress:NULL, NULL, &error))
- {
- if (interactive && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
- {
- char line[16];
-
- g_error_free (error);
- error = NULL;
-
- basename = g_file_get_basename (target);
- g_print ("overwrite %s?", basename);
- g_free (basename);
-
- if (fgets(line, sizeof (line), stdin) &&
- line[0] == 'y')
- {
- flags |= G_FILE_COPY_OVERWRITE;
- if (!g_file_copy (source, target, flags, NULL, NULL, NULL, &error))
- goto copy_failed;
- }
- }
- else
- {
- copy_failed:
- g_printerr ("Error copying file %s: %s\n", argv[i], error->message);
- g_error_free (error);
- }
- }
-
- g_object_unref (source);
- g_object_unref (target);
- }
-
- g_object_unref (dest);
-
- return 0;
-}
diff --git a/programs/gvfs-info.c b/programs/gvfs-info.c
deleted file mode 100644
index 4ed45972..00000000
--- a/programs/gvfs-info.c
+++ /dev/null
@@ -1,326 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <locale.h>
-#include <gio/gfile.h>
-
-static char *attributes = NULL;
-static gboolean nofollow_symlinks = FALSE;
-static gboolean filesystem = FALSE;
-static gboolean writable = FALSE;
-
-static GOptionEntry entries[] =
-{
- { "query-writable", 'w', 0, G_OPTION_ARG_NONE, &writable, "List writable attributes", NULL },
- { "filesystem", 'f', 0, G_OPTION_ARG_NONE, &filesystem, "Get filesystem info", NULL },
- { "attributes", 'a', 0, G_OPTION_ARG_STRING, &attributes, "The attributes to get", NULL },
- { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, "Don't follow symlinks", NULL },
- { NULL }
-};
-
-static const char *
-type_to_string (GFileType type)
-{
- switch (type)
- {
- default:
- return "invalid type";
-
- case G_FILE_TYPE_UNKNOWN:
- return "unknown";
-
- case G_FILE_TYPE_REGULAR:
- return "regular";
-
- case G_FILE_TYPE_DIRECTORY:
- return "directory";
-
- case G_FILE_TYPE_SYMBOLIC_LINK:
- return "symlink";
-
- case G_FILE_TYPE_SPECIAL:
- return "special";
-
- case G_FILE_TYPE_SHORTCUT:
- return "shortcut";
-
- case G_FILE_TYPE_MOUNTABLE:
- return "mountable";
- }
-}
-
-static char *
-escape_string (const char *in)
-{
- GString *str;
- static char *hex_digits = "0123456789abcdef";
- char c;
-
-
- str = g_string_new ("");
-
- while ((c = *in++) != 0)
- {
- if (c >= 32 && c <= 126 && c != '\\')
- g_string_append_c (str, c);
- else
- {
- g_string_append (str, "\\x");
- g_string_append_c (str, hex_digits[(c >> 8) & 0xf]);
- g_string_append_c (str, hex_digits[c & 0xf]);
- }
- }
-
- return g_string_free (str, FALSE);
-}
-
-static void
-show_attributes (GFileInfo *info)
-{
- char **attributes;
- const GFileAttributeValue *value;
- char *s;
- int i;
-
- attributes = g_file_info_list_attributes (info, NULL);
-
- g_print ("attributes:\n");
- for (i = 0; attributes[i] != NULL; i++)
- {
- value = g_file_info_get_attribute (info, attributes[i]);
- s = g_file_attribute_value_as_string (value);
- g_print (" %s: %s\n", attributes[i], s);
- g_free (s);
- }
- g_strfreev (attributes);
-}
-
-static void
-show_info (GFileInfo *info)
-{
- const char *name, *type;
- char *escaped;
- goffset size;
-
- name = g_file_info_get_display_name (info);
- if (name)
- g_print ("display name: %s\n", name);
-
- name = g_file_info_get_edit_name (info);
- if (name)
- g_print ("edit name: %s\n", name);
-
- name = g_file_info_get_name (info);
- if (name)
- {
- escaped = escape_string (name);
- g_print ("name: %s\n", escaped);
- g_free (escaped);
- }
-
- type = type_to_string (g_file_info_get_file_type (info));
- g_print ("type: %s\n", type);
-
- size = g_file_info_get_size (info);
- g_print ("size: %"G_GUINT64_FORMAT"\n", (guint64)size);
-
- if (g_file_info_get_is_hidden (info))
- g_print ("hidden\n");
-
- show_attributes (info);
-}
-
-static void
-get_info (GFile *file)
-{
- GFileGetInfoFlags flags;
- GFileInfo *info;
- GError *error;
-
- if (file == NULL)
- return;
-
- if (attributes == NULL)
- attributes = "*";
-
- flags = 0;
- if (nofollow_symlinks)
- flags |= G_FILE_GET_INFO_NOFOLLOW_SYMLINKS;
-
- error = NULL;
- if (filesystem)
- info = g_file_get_filesystem_info (file, attributes, NULL, &error);
- else
- info = g_file_get_info (file, attributes, flags, NULL, &error);
-
- if (info == NULL)
- {
- g_printerr ("Error getting info: %s\n", error->message);
- g_error_free (error);
- return;
- }
-
- if (filesystem)
- show_attributes (info);
- else
- show_info (info);
-
- g_object_unref (info);
-}
-
-static char *
-attribute_type_to_string (GFileAttributeType type)
-{
- switch (type)
- {
- case G_FILE_ATTRIBUTE_TYPE_INVALID:
- return "invalid";
- case G_FILE_ATTRIBUTE_TYPE_STRING:
- return "string";
- case G_FILE_ATTRIBUTE_TYPE_BYTE_STRING:
- return "bytestring";
- case G_FILE_ATTRIBUTE_TYPE_BOOLEAN:
- return "boolean";
- case G_FILE_ATTRIBUTE_TYPE_UINT32:
- return "uint32";
- case G_FILE_ATTRIBUTE_TYPE_INT32:
- return "int32";
- case G_FILE_ATTRIBUTE_TYPE_UINT64:
- return "uint64";
- case G_FILE_ATTRIBUTE_TYPE_INT64:
- return "int64";
- case G_FILE_ATTRIBUTE_TYPE_OBJECT:
- return "object";
- default:
- return "uknown type";
- }
-}
-
-static char *
-attribute_flags_to_string (GFileAttributeFlags flags)
-{
- GString *s;
- int i;
- gboolean first;
- struct {
- guint32 mask;
- char *descr;
- } flag_descr[] = {
- {
- G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE,
- "Copy with file"
- },
- {
- G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED,
- "Keep with file when moved"
- },
- };
-
- first = TRUE;
-
- s = g_string_new ("");
- for (i = 0; i < G_N_ELEMENTS (flag_descr); i++)
- {
- if (flags & flag_descr[i].mask)
- {
- if (!first)
- g_string_append (s, ", ");
- g_string_append (s, flag_descr[i].descr);
- first = FALSE;
- }
- }
-
- return g_string_free (s, FALSE);
-}
-
-static void
-get_writable_info (GFile *file)
-{
- GFileAttributeInfoList *list;
- GError *error;
- int i;
- char *flags;
-
- if (file == NULL)
- return;
-
- error = NULL;
-
- list = g_file_query_settable_attributes (file, NULL, &error);
- if (list == NULL)
- {
- g_printerr ("Error getting writable attributes: %s\n", error->message);
- g_error_free (error);
- return;
- }
-
- g_print ("Settable attributes:\n");
- for (i = 0; i < list->n_infos; i++)
- {
- flags = attribute_flags_to_string (list->infos[i].flags);
- g_print (" %s (%s%s%s)\n",
- list->infos[i].name,
- attribute_type_to_string (list->infos[i].type),
- (*flags != 0)?", ":"", flags);
- g_free (flags);
- }
-
- g_file_attribute_info_list_unref (list);
-
- list = g_file_query_writable_namespaces (file, NULL, &error);
- if (list == NULL)
- {
- g_printerr ("Error getting writable namespaces: %s\n", error->message);
- g_error_free (error);
- return;
- }
-
- if (list->n_infos > 0)
- {
- g_print ("Writable attribute namespaces:\n");
- for (i = 0; i < list->n_infos; i++)
- {
- flags = attribute_flags_to_string (list->infos[i].flags);
- g_print (" %s (%s%s%s)\n",
- list->infos[i].name,
- attribute_type_to_string (list->infos[i].type),
- (*flags != 0)?", ":"", flags);
- }
- }
-
- g_file_attribute_info_list_unref (list);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- show info for <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc > 1)
- {
- int i;
-
- for (i = 1; i < argc; i++) {
- file = g_file_new_for_commandline_arg (argv[i]);
- if (writable)
- get_writable_info (file);
- else
- get_info (file);
- g_object_unref (file);
- }
- }
-
- return 0;
-}
diff --git a/programs/gvfs-ls.c b/programs/gvfs-ls.c
deleted file mode 100644
index 9faa8b0c..00000000
--- a/programs/gvfs-ls.c
+++ /dev/null
@@ -1,185 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <locale.h>
-#include <gio/gfile.h>
-
-static char *attributes = NULL;
-static gboolean show_hidden = FALSE;
-
-static GOptionEntry entries[] =
-{
- { "attributes", 'a', 0, G_OPTION_ARG_STRING, &attributes, "The attributes to get", NULL },
- { "hidden", 'h', 0, G_OPTION_ARG_NONE, &show_hidden, "Show hidden files", NULL },
- { NULL }
-};
-
-static const char *
-type_to_string (GFileType type)
-{
- switch (type)
- {
- default:
- return "invalid type";
-
- case G_FILE_TYPE_UNKNOWN:
- return "unknown";
-
- case G_FILE_TYPE_REGULAR:
- return "regular";
-
- case G_FILE_TYPE_DIRECTORY:
- return "directory";
-
- case G_FILE_TYPE_SYMBOLIC_LINK:
- return "symlink";
-
- case G_FILE_TYPE_SPECIAL:
- return "special";
-
- case G_FILE_TYPE_SHORTCUT:
- return "shortcut";
-
- case G_FILE_TYPE_MOUNTABLE:
- return "mountable";
- }
-}
-
-static void
-show_info (GFileInfo *info)
-{
- const char *name, *type;
- goffset size;
- char **attributes;
- int i;
- gboolean first_attr;
-
- if ((g_file_info_get_is_hidden (info)) && !show_hidden)
- return;
-
- name = g_file_info_get_name (info);
- if (name == NULL)
- name = "";
-
- size = g_file_info_get_size (info);
- type = type_to_string (g_file_info_get_file_type (info));
- g_print ("%s\t%"G_GUINT64_FORMAT"\t(%s)", name, (guint64)size, type);
-
- first_attr = TRUE;
- attributes = g_file_info_list_attributes (info, NULL);
- for (i = 0 ; attributes[i] != NULL; i++)
- {
- GFileAttributeValue *val;
- char *val_as_string;
-
- if (strcmp (attributes[i], G_FILE_ATTRIBUTE_STD_NAME) == 0 ||
- strcmp (attributes[i], G_FILE_ATTRIBUTE_STD_SIZE) == 0 ||
- strcmp (attributes[i], G_FILE_ATTRIBUTE_STD_TYPE) == 0)
- continue;
-
- if (first_attr)
- {
- g_print ("\t");
- first_attr = FALSE;
- }
- else
- g_print (" ");
- val = g_file_info_get_attribute (info, attributes[i]);
- val_as_string = g_file_attribute_value_as_string (val);
- g_print ("%s=%s", attributes[i], val_as_string);
- g_free (val_as_string);
- }
-
- g_strfreev (attributes);
-
- g_print ("\n");
-}
-
-static void
-list (GFile *file)
-{
- GFileEnumerator *enumerator;
- GFileInfo *info;
- GError *error;
-
- if (file == NULL)
- return;
-
- error = NULL;
- enumerator = g_file_enumerate_children (file, attributes, 0, NULL, &error);
- if (enumerator == NULL)
- {
- g_print ("Error: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- return;
- }
-
- while ((info = g_file_enumerator_next_file (enumerator, NULL, &error)) != NULL)
- {
- show_info (info);
-
- g_object_unref (info);
- }
-
- if (error)
- {
- g_print ("Error: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- }
-
- if (!g_file_enumerator_stop (enumerator, NULL, &error))
- {
- g_print ("Error stopping enumerator: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- }
-}
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- list files at <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- attributes = g_strconcat (G_FILE_ATTRIBUTE_STD_NAME "," G_FILE_ATTRIBUTE_STD_TYPE "," G_FILE_ATTRIBUTE_STD_SIZE,
- attributes != NULL ? "," : "",
- attributes,
- NULL);
-
- if (argc > 1)
- {
- int i;
-
- for (i = 1; i < argc; i++) {
- file = g_file_new_for_commandline_arg (argv[i]);
- list (file);
- g_object_unref (file);
- }
- }
- else
- {
- char *cwd;
-
- cwd = g_get_current_dir ();
- file = g_file_new_for_path (cwd);
- g_free (cwd);
- list (file);
- g_object_unref (file);
- }
-
- g_free (attributes);
-
- return 0;
-}
diff --git a/programs/gvfs-monitor-dir.c b/programs/gvfs-monitor-dir.c
deleted file mode 100644
index 1b2a661d..00000000
--- a/programs/gvfs-monitor-dir.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <config.h>
-#include <config.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <locale.h>
-#include <errno.h>
-
-#include <glib.h>
-#include <gio/gfile.h>
-#include <gio/gdirectorymonitor.h>
-
-static GMainLoop *main_loop;
-
-static GOptionEntry entries[] = {
- { NULL }
-};
-
-static gboolean
-dir_monitor_callback (GDirectoryMonitor* monitor,
- GFile* child,
- GFile* other_file,
- GFileMonitorEvent eflags)
-{
- g_print ("Directory Monitor Event:\n");
- g_print ("Child = %s\n", g_file_get_parse_name (child));
- switch (eflags)
- {
- case G_FILE_MONITOR_EVENT_CHANGED:
- g_print ("Event = CHANGED\n");
- break;
- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
- g_print ("Event = CHANGES_DONE_HINT\n");
- break;
- case G_FILE_MONITOR_EVENT_DELETED:
- g_print ("Event = DELETED\n");
- break;
- case G_FILE_MONITOR_EVENT_CREATED:
- g_print ("Event = CREATED\n");
- break;
- case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
- g_print ("Event = PRE_UNMOUNT\n");
- break;
- case G_FILE_MONITOR_EVENT_UNMOUNTED:
- g_print ("Event = UNMOUNTED\n");
- break;
- case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
- g_print ("Event = ATTRIB CHANGED\n");
- break;
- }
-
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- GDirectoryMonitor* dmonitor;
- GError *error;
- GOptionContext *context;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- monitor directory <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc > 1)
- {
- file = g_file_new_for_commandline_arg (argv[1]);
- dmonitor = g_file_monitor_directory (file, G_FILE_MONITOR_FLAGS_MONITOR_MOUNTS);
- g_signal_connect (dmonitor, "changed", (GCallback)dir_monitor_callback, NULL);
- }
-
- main_loop = g_main_loop_new (NULL, FALSE);
-
- g_main_loop_run (main_loop);
-
- return 0;
-}
diff --git a/programs/gvfs-monitor-file.c b/programs/gvfs-monitor-file.c
deleted file mode 100644
index 887ab68d..00000000
--- a/programs/gvfs-monitor-file.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <config.h>
-#include <config.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <locale.h>
-#include <errno.h>
-
-#include <glib.h>
-#include <gio/gfile.h>
-#include <gio/gfilemonitor.h>
-
-static GMainLoop *main_loop;
-
-static GOptionEntry entries[] = {
- { NULL }
-};
-
-static gboolean
-file_monitor_callback (GFileMonitor* monitor,
- GFile* child,
- GFile* other_file,
- GFileMonitorEvent eflags)
-{
- g_print ("File Monitor Event:\n");
- g_print ("File = %s\n", g_file_get_parse_name (child));
- switch (eflags)
- {
- case G_FILE_MONITOR_EVENT_CHANGED:
- g_print ("Event = CHANGED\n");
- break;
- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
- g_print ("Event = CHANGES_DONE_HINT\n");
- break;
- case G_FILE_MONITOR_EVENT_DELETED:
- g_print ("Event = DELETED\n");
- break;
- case G_FILE_MONITOR_EVENT_CREATED:
- g_print ("Event = CREATED\n");
- break;
- case G_FILE_MONITOR_EVENT_UNMOUNTED:
- g_print ("Event = UNMOUNTED\n");
- break;
- case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
- g_print ("Event = PRE_UNMOUNT\n");
- break;
- case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
- g_print ("Event = ATTRIB CHANGED\n");
- break;
- }
-
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- GFileMonitor* fmonitor;
- GError *error;
- GOptionContext *context;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- monitor file <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc > 1)
- {
- file = g_file_new_for_commandline_arg (argv[1]);
- fmonitor = g_file_monitor_file (file, G_FILE_MONITOR_FLAGS_MONITOR_MOUNTS);
- g_signal_connect (fmonitor, "changed", (GCallback)file_monitor_callback, NULL);
- }
-
- main_loop = g_main_loop_new (NULL, FALSE);
-
- g_main_loop_run (main_loop);
-
- return 0;
-}
diff --git a/programs/gvfs-mount.c b/programs/gvfs-mount.c
deleted file mode 100644
index d3ab6164..00000000
--- a/programs/gvfs-mount.c
+++ /dev/null
@@ -1,184 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <string.h>
-
-#include <glib.h>
-#include <locale.h>
-#include <gio/gfile.h>
-
-static int outstanding_mounts = 0;
-static GMainLoop *main_loop;
-
-
-static gboolean mount_mountable = FALSE;
-
-static GOptionEntry entries[] =
-{
- { "mountable", 'm', 0, G_OPTION_ARG_NONE, &mount_mountable, "Mount as mountable", NULL },
- { NULL }
-};
-
-static char *
-prompt_for (const char *prompt, const char *default_value)
-{
- char data[256];
- int len;
-
- if (default_value && *default_value != 0)
- g_print ("%s [%s]: ", prompt, default_value);
- else
- g_print ("%s: ", prompt);
-
- data[0] = 0;
- fgets(data, sizeof (data), stdin);
- len = strlen (data);
- if (len > 0 && data[len-1] == '\n')
- data[len-1] = 0;
-
- if (*data == 0 && default_value)
- return g_strdup (default_value);
- return g_strdup (data);
-}
-
-static gboolean
-ask_password_cb (GMountOperation *op,
- const char *message,
- const char *default_user,
- const char *default_domain,
- GPasswordFlags flags)
-{
- char *s;
- g_print ("%s\n", message);
-
- if (flags & G_PASSWORD_FLAGS_NEED_USERNAME)
- {
- s = prompt_for ("User", default_user);
- g_mount_operation_set_username (op, s);
- g_free (s);
- }
-
- if (flags & G_PASSWORD_FLAGS_NEED_DOMAIN)
- {
- s = prompt_for ("Domain", default_domain);
- g_mount_operation_set_domain (op, s);
- g_free (s);
- }
-
- if (flags & G_PASSWORD_FLAGS_NEED_PASSWORD)
- {
- s = prompt_for ("Password", NULL);
- g_mount_operation_set_password (op, s);
- g_free (s);
- }
-
- g_mount_operation_reply (op, FALSE);
-
- return TRUE;
-}
-
-static void
-mount_mountable_done_cb (GObject *object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GFile *target;
- GError *error = NULL;
-
- target = g_file_mount_mountable_finish (G_FILE (object), res, &error);
-
- if (target == NULL)
- g_print ("Error mounting location: %s\n", error->message);
- else
- g_object_unref (target);
-
- outstanding_mounts--;
-
- if (outstanding_mounts == 0)
- g_main_loop_quit (main_loop);
-}
-
-static void
-mount_done_cb (GObject *object,
- GAsyncResult *res,
- gpointer user_data)
-{
- gboolean succeeded;
- GError *error = NULL;
-
- succeeded = g_mount_for_location_finish (G_FILE (object), res, &error);
-
- if (!succeeded)
- g_print ("Error mounting location: %s\n", error->message);
-
- outstanding_mounts--;
-
- if (outstanding_mounts == 0)
- g_main_loop_quit (main_loop);
-}
-
-static GMountOperation *
-new_mount_op (void)
-{
- GMountOperation *op;
-
- op = g_mount_operation_new ();
-
- g_signal_connect (op, "ask_password", (GCallback)ask_password_cb, NULL);
-
- return op;
-}
-
-
-static void
-mount (GFile *file)
-{
- GMountOperation *op;
-
- if (file == NULL)
- return;
-
- op = new_mount_op ();
-
- if (mount_mountable)
- g_file_mount_mountable (file, op, NULL, mount_mountable_done_cb, op);
- else
- g_mount_for_location (file, op, NULL, mount_done_cb, op);
-
- outstanding_mounts++;
-}
-
-int
-main (int argc, char *argv[])
-{
- GOptionContext *context;
- GError *error;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- mount <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc > 1)
- {
- int i;
-
- for (i = 1; i < argc; i++) {
- file = g_file_new_for_commandline_arg (argv[i]);
- mount (file);
- g_object_unref (file);
- }
- }
-
- main_loop = g_main_loop_new (NULL, FALSE);
-
- if (outstanding_mounts > 0)
- g_main_loop_run (main_loop);
-
- return 0;
-}
diff --git a/programs/gvfs-move.c b/programs/gvfs-move.c
deleted file mode 100644
index 8bced962..00000000
--- a/programs/gvfs-move.c
+++ /dev/null
@@ -1,149 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <locale.h>
-#include <errno.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gio/gfile.h>
-
-static gboolean progress = FALSE;
-static gboolean interactive = FALSE;
-static gboolean backup = FALSE;
-static gboolean no_target_directory = FALSE;
-
-static GOptionEntry entries[] =
-{
- { "no-target-directory", 'T', 0, G_OPTION_ARG_NONE, &no_target_directory, "no target directory", NULL },
- { "progress", 'p', 0, G_OPTION_ARG_NONE, &progress, "show progress", NULL },
- { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive, "prompt before overwrite", NULL },
- { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, "backup existing destination files", NULL },
- { NULL }
-};
-
-static gboolean
-is_dir (GFile *file)
-{
- GFileInfo *info;
- gboolean res;
-
- info = g_file_get_info (file, G_FILE_ATTRIBUTE_STD_TYPE, 0, NULL, NULL);
- res = info && g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY;
- if (info)
- g_object_unref (info);
- return res;
-}
-
-static void
-show_progress (goffset current_num_bytes,
- goffset total_num_bytes,
- gpointer user_data)
-{
- g_print ("progress %"G_GUINT64_FORMAT"/%"G_GUINT64_FORMAT"\n",
- current_num_bytes, total_num_bytes);
-}
-
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *source, *dest, *target;
- gboolean dest_is_dir;
- char *basename;
- int i;
- GFileCopyFlags flags;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- output files at <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc <= 2)
- {
- g_printerr ("Missing operand\n");
- return 1;
- }
-
- dest = g_file_new_for_commandline_arg (argv[argc-1]);
-
- if (no_target_directory && argc > 3)
- {
- g_printerr ("Too many arguments\n");
- g_object_unref (dest);
- return 1;
- }
-
- dest_is_dir = is_dir (dest);
-
- if (!dest_is_dir && argc > 3)
- {
- g_printerr ("Target %s is not a directory\n", argv[argc-1]);
- g_object_unref (dest);
- return 1;
- }
-
- for (i = 1; i < argc - 1; i++)
- {
- source = g_file_new_for_commandline_arg (argv[i]);
-
- if (dest_is_dir && !no_target_directory)
- {
- basename = g_file_get_basename (source);
- target = g_file_get_child (dest, basename);
- g_free (basename);
- }
- else
- target = g_object_ref (dest);
-
- flags = 0;
- if (backup)
- flags |= G_FILE_COPY_BACKUP;
- if (!interactive)
- flags |= G_FILE_COPY_OVERWRITE;
-
- error = NULL;
- if (!g_file_move (source, target, flags, NULL, progress?show_progress:NULL, NULL, &error))
- {
- if (interactive && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
- {
- char line[16];
-
- g_error_free (error);
- error = NULL;
-
- basename = g_file_get_basename (target);
- g_print ("overwrite %s?", basename);
- g_free (basename);
-
- if (fgets(line, sizeof (line), stdin) &&
- line[0] == 'y')
- {
- flags |= G_FILE_COPY_OVERWRITE;
- if (!g_file_move (source, target, flags, NULL, NULL, NULL, &error))
- goto move_failed;
- }
- }
- else
- {
- move_failed:
- g_printerr ("Error moving file %s: %s\n", argv[i], error->message);
- g_error_free (error);
- }
- }
-
- g_object_unref (source);
- g_object_unref (target);
- }
-
- g_object_unref (dest);
-
- return 0;
-}
diff --git a/programs/gvfs-rm.c b/programs/gvfs-rm.c
deleted file mode 100644
index 1fb7c14e..00000000
--- a/programs/gvfs-rm.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <locale.h>
-#include <gio/gfile.h>
-
-
-static GOptionEntry entries[] =
-{
- { NULL }
-};
-
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- delete files");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc > 1)
- {
- int i;
-
- for (i = 1; i < argc; i++) {
- file = g_file_new_for_commandline_arg (argv[i]);
- error = NULL;
- if (!g_file_delete (file, NULL, &error))
- {
- g_print ("Error deleting file: %s\n", error->message);
- g_error_free (error);
- }
- g_object_unref (file);
- }
- }
-
- return 0;
-}
diff --git a/programs/gvfs-save.c b/programs/gvfs-save.c
deleted file mode 100644
index 1e9f36b0..00000000
--- a/programs/gvfs-save.c
+++ /dev/null
@@ -1,147 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <locale.h>
-#include <errno.h>
-
-#include <glib.h>
-#include <gio/gfile.h>
-
-static char *etag = NULL;
-static gboolean backup = FALSE;
-static gboolean create = FALSE;
-static gboolean append = FALSE;
-static gboolean print_etag = FALSE;
-
-static GOptionEntry entries[] =
-{
- { "backup", 'b', 0, G_OPTION_ARG_NONE, &backup, "Create backup", NULL },
- { "create", 'c', 0, G_OPTION_ARG_NONE, &create, "Only create if not existing", NULL },
- { "append", 'a', 0, G_OPTION_ARG_NONE, &append, "Append to end of file", NULL },
- { "print_etag", 'p', 0, G_OPTION_ARG_NONE, &print_etag, "Print new etag at end", NULL },
- { "etag", 'e', 0, G_OPTION_ARG_STRING, &etag, "The etag of the file being overwritten", NULL },
- { NULL }
-};
-
-static gboolean
-save (GFile *file)
-{
- GOutputStream *out;
- char buffer[1025];
- char *p;
- gssize res;
- gboolean close_res;
- GError *error;
- gboolean save_res;
-
- error = NULL;
- if (create)
- out = (GOutputStream *)g_file_create (file, NULL, &error);
- else if (append)
- out = (GOutputStream *)g_file_append_to (file, NULL, &error);
- else
- out = (GOutputStream *)g_file_replace (file, etag, backup, NULL, &error);
- if (out == NULL)
- {
- g_printerr ("Error opening file: %s\n", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- save_res = TRUE;
-
- while (1)
- {
- res = read (STDIN_FILENO, buffer, 1024);
- if (res > 0)
- {
- ssize_t written;
-
- p = buffer;
- while (res > 0)
- {
- error = NULL;
- written = g_output_stream_write (out, p, res, NULL, &error);
- if (written == -1)
- {
- save_res = FALSE;
- g_printerr ("Error writing to stream: %s", error->message);
- g_error_free (error);
- goto out;
- }
- res -= written;
- p += written;
- }
- }
- else if (res < 0)
- {
- save_res = FALSE;
- perror ("Error reading stdin");
- break;
- }
- else if (res == 0)
- break;
- }
-
- out:
-
- close_res = g_output_stream_close (out, NULL, &error);
- if (!close_res)
- {
- save_res = FALSE;
- g_printerr ("Error closing: %s\n", error->message);
- g_error_free (error);
- }
-
- if (close_res && print_etag)
- {
- char *etag;
- etag = g_file_output_stream_get_etag (G_FILE_OUTPUT_STREAM (out), NULL, &error);
-
- if (etag)
- g_print ("Etag: %s\n", etag);
- else
- {
- g_printerr ("Error getting etag: %s\n", error->message);
- g_error_free (error);
- }
-
- g_free (etag);
- }
-
- g_object_unref (out);
-
- return save_res;
-}
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *file;
- gboolean res;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- output files at <location>");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- res = FALSE;
-
- if (argc > 1)
- {
- file = g_file_new_for_commandline_arg (argv[1]);
- res = save (file);
- g_object_unref (file);
- }
-
- if (res)
- return 0;
- return 1;
-}
diff --git a/programs/gvfs-trash.c b/programs/gvfs-trash.c
deleted file mode 100644
index 60ee2f7c..00000000
--- a/programs/gvfs-trash.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <config.h>
-
-#include <glib.h>
-#include <locale.h>
-#include <gio/gfile.h>
-
-
-static GOptionEntry entries[] =
-{
- { NULL }
-};
-
-
-int
-main (int argc, char *argv[])
-{
- GError *error;
- GOptionContext *context;
- GFile *file;
-
- setlocale (LC_ALL, "");
-
- g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- move files to trash");
- g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
- g_option_context_parse (context, &argc, &argv, &error);
-
- if (argc > 1)
- {
- int i;
-
- for (i = 1; i < argc; i++) {
- file = g_file_new_for_commandline_arg (argv[i]);
- error = NULL;
- if (!g_file_trash (file, NULL, &error))
- {
- g_print ("Error trashing file: %s\n", error->message);
- g_error_free (error);
- }
- g_object_unref (file);
- }
- }
-
- return 0;
-}
diff --git a/test/Makefile.am b/test/Makefile.am
index 143d50ee..f763314a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -7,7 +7,6 @@ AM_CFLAGS = \
-DG_DISABLE_DEPRECATED
AM_LDFLAGS = \
- $(top_builddir)/gio/libgio.la \
$(GLIB_LIBS)
noinst_PROGRAMS = \