diff options
-rwxr-xr-x[-rw-r--r--] | .gitignore | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | Makefile.am | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | configure.ac | 44 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/Makefile.am | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/gcancellable.c | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/gcontenttype.c | 116 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/gfile.c | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/glocalfile.c | 20 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/glocalfileinfo.c | 33 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/glocalfileinputstream.c | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/glocalfileoutputstream.c | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/gsocketinputstream.c | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/gvfs.c | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | gio/test.c | 9 |
14 files changed, 257 insertions, 49 deletions
diff --git a/.gitignore b/.gitignore index 33e9270e..4299b0d3 100644..100755 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ Makefile.in *.o *.la *.lo +*.exe .deps .libs test diff --git a/Makefile.am b/Makefile.am index 64a63b54..47b0a5af 100644..100755 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,19 @@ -SUBDIRS = \ - gio \ +NULL = + +if OS_UNIX +unix_dirs = \ common \ client \ daemon \ + $(NULL) + +endif + +SUBDIRS = \ + gio \ + $(unix_dirs) \ po \ - programs + programs \ + $(NULL) DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc diff --git a/configure.ac b/configure.ac index c52766bf..8aba1d43 100644..100755 --- a/configure.ac +++ b/configure.ac @@ -30,10 +30,28 @@ 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_FUNCS(getc_unlocked) +AC_CHECK_HEADERS([pwd.h]) + +AC_CHECK_FUNCS(getc_unlocked readlink symlink chown lchown fchmod fchown link) + +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"]) + GTK_DOC_CHECK DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc" AC_SUBST(DISTCHECK_CONFIGURE_FLAGS) @@ -42,13 +60,14 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 gthread-2.0 gobject-2.0 gmodule-no-export-2.0) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) -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) - +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 GETTEXT_PACKAGE=gvfs AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [The gettext domain name]) @@ -103,14 +122,6 @@ dnl failure. try libattr XATTR_LIBS="-lattr" msg_xattr=yes]) ]) - -dnl bail if none of them was available - if test "x$msg_xattr" != "xyes"; then - echo "ERROR: Neither found glibc with extended attribute support and a <sys/xattr.h> header," - echo " nor a usable \"libattr\" extended attribute support library and a <attr/xattr.h> header." - echo " Either install the required libraries/headers, or pass \"--disable-xattr\"." - exit 1; - fi fi fi AC_SUBST(XATTR_LIBS) @@ -253,6 +264,7 @@ po/Makefile.in echo echo "gvfs configuration summary:" echo " + Win32 build: $glib_native_win32 SELinux support: $msg_selinux xattr support: $msg_xattr Samba support: $msg_samba diff --git a/gio/Makefile.am b/gio/Makefile.am index a6ced0ce..ee53d707 100644..100755 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -2,8 +2,9 @@ NULL = SUBDIRS= -# TODO: Only on unix +if OS_UNIX SUBDIRS += xdgmime +endif INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gvfs \ -I$(top_srcdir)/daemon \ @@ -44,10 +45,16 @@ local_sources = \ platform_libadd = appinfo_sources = -#if OS_UNIX +if OS_UNIX appinfo_sources = gdesktopappinfo.c gdesktopappinfo.h platform_libadd += xdgmime/libxdgmime.la -#endif +socket_sources = \ + gsocketinputstream.c \ + gsocketinputstream.h \ + gsocketoutputstream.c \ + gsocketoutputstream.h \ + $(NULL) +endif libgio_la_SOURCES = \ @@ -69,12 +76,9 @@ libgio_la_SOURCES = \ gmountoperation.h \ goutputstream.c \ gseekable.c \ - gsocketinputstream.c \ - gsocketinputstream.h \ - gsocketoutputstream.c \ - gsocketoutputstream.h \ gvfs.c \ $(appinfo_sources) \ + $(socket_sources) \ $(local_sources) \ $(daemon_sources) \ $(marshal_sources) \ @@ -89,6 +93,12 @@ libgio_la_LIBADD = \ $(XATTR_LIBS) \ $(NULL) +if OS_WIN32 +no_undefined = -no-undefined +endif + +libgio_la_LDFLAGS= -export-dynamic $(no_undefined) + gvfsincludedir=$(includedir)/gio/ gvfsinclude_HEADERS = \ gappinfo.h \ diff --git a/gio/gcancellable.c b/gio/gcancellable.c index 941ccd98..be7c3ed2 100644..100755 --- a/gio/gcancellable.c +++ b/gio/gcancellable.c @@ -64,8 +64,8 @@ g_cancellable_class_init (GCancellableClass *klass) static void set_fd_nonblocking (int fd) { +#ifdef F_GETFL glong fcntl_flags; - fcntl_flags = fcntl (fd, F_GETFL); #ifdef O_NONBLOCK @@ -75,6 +75,7 @@ set_fd_nonblocking (int fd) #endif fcntl (fd, F_SETFL, fcntl_flags); +#endif } static void diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c index 082907ba..6b6f59d2 100644..100755 --- a/gio/gcontenttype.c +++ b/gio/gcontenttype.c @@ -17,9 +17,117 @@ can be looked up in the registry at HKEY_CLASSES_ROOT. */ +#ifdef G_OS_WIN32 +gboolean +g_content_type_equals (const char *type1, + const char *type2) +{ + g_return_val_if_fail (type1 != NULL, FALSE); + g_return_val_if_fail (type2 != NULL, FALSE); + + /* TODO */ + return FALSE; +} + +gboolean +g_content_type_is_a (const char *type, + const char *supertype) +{ + g_return_val_if_fail (type != NULL, FALSE); + g_return_val_if_fail (supertype != NULL, FALSE); + + /* TODO */ + + return FALSE; +} + +gboolean +g_content_type_is_unknown (const char *type) +{ + return strcmp ("*", type) == 0; +} + +char * +g_content_type_get_description (const char *type) +{ + /* TODO */ + return NULL; +} + +char * +g_content_type_get_mime_type (const char *type) +{ + /* TODO */ + return NULL; +} + +char * +g_content_type_get_icon (const char *type) +{ + /* TODO: How do we represent icons??? */ + 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) +{ + 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 ("*"); +} -/* Unix specific version */ + +GList * +g_get_registered_content_types (void) +{ + return NULL; +} + +#else /* !G_OS_WIN32 - Unix specific version */ /* We lock this mutex whenever we modify global state in this module. */ G_LOCK_DEFINE_STATIC (gio_xdgmime); @@ -74,8 +182,6 @@ _g_unix_content_type_get_parents (const char *type) return (char **)g_ptr_array_free (array, FALSE); } - - gboolean g_content_type_equals (const char *type1, const char *type2) @@ -276,8 +382,6 @@ g_content_type_get_description (const char *type) static GHashTable *type_comment_cache = NULL; char *comment; - /* TODO: Implement reading the xml file */ - 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); @@ -492,3 +596,5 @@ g_get_registered_content_types (void) return l; } + +#endif /* Unix version */ diff --git a/gio/gfile.c b/gio/gfile.c index 021557b3..9faad32a 100644..100755 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -1,7 +1,9 @@ #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" diff --git a/gio/glocalfile.c b/gio/glocalfile.c index a5d02185..0c35e857 100644..100755 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -438,6 +438,7 @@ get_uint32 (GFileAttributeType type, return TRUE; } +#if defined(HAVE_SYMLINK) static gboolean get_byte_string (GFileAttributeType type, gconstpointer value, @@ -455,7 +456,7 @@ get_byte_string (GFileAttributeType type, return TRUE; } - +#endif static gboolean g_local_file_set_attribute (GFile *file, @@ -467,7 +468,6 @@ g_local_file_set_attribute (GFile *file, GError **error) { GLocalFile *local = G_LOCAL_FILE (file); - int res; if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_MODE) == 0) { @@ -486,8 +486,10 @@ g_local_file_set_attribute (GFile *file, } return TRUE; } +#ifdef HAVE_CHOWN else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_UID) == 0) { + int res; guint32 val; if (!get_uint32 (type, value, &val, error)) @@ -508,8 +510,11 @@ g_local_file_set_attribute (GFile *file, } return TRUE; } +#endif +#ifdef HAVE_CHOWN else if (strcmp (attribute, G_FILE_ATTRIBUTE_UNIX_GID) == 0) { + int res; guint32 val; if (!get_uint32 (type, value, &val, error)) @@ -530,6 +535,8 @@ g_local_file_set_attribute (GFile *file, } return TRUE; } +#endif +#ifdef HAVE_SYMLINK else if (strcmp (attribute, G_FILE_ATTRIBUTE_STD_SYMLINK_TARGET) == 0) { const char *val; @@ -583,6 +590,7 @@ g_local_file_set_attribute (GFile *file, return TRUE; } + #endif g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Copy not supported"); return FALSE; @@ -684,6 +692,7 @@ g_local_file_make_symbolic_link (GFile *file, GCancellable *cancellable, GError **error) { +#ifdef HAVE_SYMLINK GLocalFile *local = G_LOCAL_FILE (file); if (symlink (local->filename, symlink_value) == -1) @@ -694,8 +703,11 @@ g_local_file_make_symbolic_link (GFile *file, g_strerror (errno)); return FALSE; } - return TRUE; +#else + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symlinks not supported"); + return FALSE; +#endif } @@ -785,7 +797,9 @@ g_local_file_move (GFile *source, /* Try to inherit source permissions, etc */ if (g_stat (local_source->filename, &statbuf) != -1) { +#ifdef HAVE_CHOWN chown (local_destination->filename, statbuf.st_uid, statbuf.st_gid); +#endif chmod (local_destination->filename, statbuf.st_mode); } diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index a448bc83..e8a76e09 100644..100755 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -34,6 +34,7 @@ static gchar * read_link (const gchar *full_name) { +#ifdef HAVE_READLINK gchar *buffer; guint size; @@ -58,6 +59,9 @@ read_link (const gchar *full_name) size *= 2; buffer = g_realloc (buffer, size); } +#else + return NULL; +#endif } /* Get the SELinux security context */ @@ -449,8 +453,10 @@ set_info_from_stat (GFileInfo *info, struct stat *statbuf) #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); @@ -472,8 +478,12 @@ set_info_from_stat (GFileInfo *info, struct stat *statbuf) 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_UNIX_ATIME, statbuf->st_atime); #if defined (HAVE_STRUCT_STAT_ST_ATIMENSEC) g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_ATIME_USEC, statbuf->st_atimensec / 1000); @@ -523,7 +533,11 @@ g_local_file_info_get (const char *basename, return NULL; } +#ifdef S_ISLNK is_symlink = S_ISLNK (statbuf.st_mode); +#else + is_symlink = FALSE; +#endif symlink_broken = FALSE; if (is_symlink) @@ -617,14 +631,15 @@ g_local_file_info_get (const char *basename, #endif else { - char *mimetype; - gsize sniff_length; + char *content_type; - mimetype = g_content_type_guess (basename, NULL, 0); + content_type = g_content_type_guess (basename, NULL, 0); +#ifndef G_OS_WIN32 if (g_content_type_is_unknown (mimetype) && path != NULL) { guchar sniff_buffer[4096]; + gsize sniff_length; int fd; sniff_length = _g_unix_content_type_get_sniff_len (); @@ -636,18 +651,20 @@ g_local_file_info_get (const char *basename, { ssize_t res; - res = read(fd, sniff_buffer, sniff_length); + res = read (fd, sniff_buffer, sniff_length); close (fd); if (res != -1) { - g_free (mimetype); - mimetype = g_content_type_guess (basename, sniff_buffer, 0); + g_free (content_type); + content_type = g_content_type_guess (basename, sniff_buffer, sniff_length); } } } - g_file_info_set_content_type (info, mimetype); - g_free (mimetype); +#endif + + g_file_info_set_content_type (info, content_type); + g_free (content_type); } } diff --git a/gio/glocalfileinputstream.c b/gio/glocalfileinputstream.c index e83bc894..3c06317b 100644..100755 --- a/gio/glocalfileinputstream.c +++ b/gio/glocalfileinputstream.c @@ -96,6 +96,7 @@ g_local_file_input_stream_read (GInputStream *stream, file = G_LOCAL_FILE_INPUT_STREAM (stream); + res = -1; while (1) { if (g_cancellable_is_cancelled (cancellable)) diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index fba70a3a..6ff2852f 100644..100755 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c @@ -150,6 +150,7 @@ g_local_file_output_stream_close (GOutputStream *stream, goto err_out; } +#ifdef HAVE_LINK /* create original -> backup link, the original is then renamed over */ if (link (file->priv->original_filename, file->priv->backup_filename) != 0) { @@ -159,6 +160,17 @@ g_local_file_output_stream_close (GOutputStream *stream, 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_from_errno (errno), + _("Error creating backup copy: %s"), + g_strerror (errno)); + goto err_out; + } +#endif } @@ -502,8 +514,16 @@ handle_overwrite_open (const char *filename, } /* try to keep permissions */ - if (fchown (tmpfd, original_stat.st_uid, original_stat.st_gid) == -1 || - fchmod (tmpfd, original_stat.st_mode) == -1) + + 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 + ) { close (tmpfd); unlink (tmp_filename); @@ -553,6 +573,7 @@ handle_overwrite_open (const char *filename, * original file. If this fails, set the protection * bits for the group same as the protection bits for * others. */ +#ifdef HAVE_FCHOWN if (fchown (bfd, (uid_t) -1, original_stat.st_gid) != 0) { if (fchmod (bfd, @@ -569,6 +590,7 @@ handle_overwrite_open (const char *filename, goto err_out; } } +#endif if (!copy_file_data (fd, bfd, NULL)) { diff --git a/gio/gsocketinputstream.c b/gio/gsocketinputstream.c index 094299a2..68d8f8c0 100644..100755 --- a/gio/gsocketinputstream.c +++ b/gio/gsocketinputstream.c @@ -120,9 +120,9 @@ g_socket_input_stream_read (GInputStream *stream, { do { - poll_fds[0].events = POLLIN; + poll_fds[0].events = GLIB_SYSDEF_POLLIN; poll_fds[0].fd = socket_stream->priv->fd; - poll_fds[1].events = POLLIN; + poll_fds[1].events = GLIB_SYSDEF_POLLIN; poll_fds[1].fd = cancel_fd; poll_ret = poll (poll_fds, 2, -1); } @@ -283,7 +283,7 @@ g_socket_input_stream_read_async (GInputStream *stream, data->stream = socket_stream; source = _g_fd_source_new (socket_stream->priv->fd, - POLLIN, + GLIB_SYSDEF_POLLIN, cancellable); g_source_set_callback (source, (GSourceFunc)read_async_cb, data, read_async_data_free); diff --git a/gio/gvfs.c b/gio/gvfs.c index b48ff6d1..4d9d405c 100644..100755 --- a/gio/gvfs.c +++ b/gio/gvfs.c @@ -77,11 +77,12 @@ g_vfs_parse_name (GVfs *vfs, static gpointer get_default_vfs (gpointer arg) { +#ifdef G_OS_UNIX GModule *module; char *path; GVfs *vfs; GVfs *(*create_vfs) (void); - + if (g_getenv ("VFS_USE_LOCAL") != NULL) return g_local_vfs_new (); @@ -101,6 +102,8 @@ get_default_vfs (gpointer arg) return vfs; } } +#endif + return g_local_vfs_new (); } diff --git a/gio/test.c b/gio/test.c index ec54340d..015c3620 100644..100755 --- a/gio/test.c +++ b/gio/test.c @@ -1,6 +1,7 @@ #include <string.h> #include <unistd.h> #include <locale.h> +#include <stdlib.h> #include <glib.h> #include "gfile.h" @@ -13,7 +14,11 @@ 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; @@ -266,6 +271,7 @@ test_seek (void) } +#if 0 static gint compare_apps (gconstpointer _a, gconstpointer _b) @@ -283,10 +289,12 @@ compare_apps (gconstpointer _a, g_free (name_b); return res; } +#endif static void test_appinfo (void) { +#if 0 GList *infos, *l; GAppInfo *info; GError *error = NULL; @@ -330,6 +338,7 @@ test_appinfo (void) g_print ("%s%s\n", g_app_info_get_name (info), g_app_info_should_show (info, "GNOME")?"":" (hidden)"); } +#endif } int |