/**
 * gnome_vfs_async_set_file_info:
 * @handle_return: when the function returns, will point to a handle for
 * the async operation.
 * @uri: uri to set the file info of.
 * @info: the struct containing new information about the file.
 * @mask: control which fields of @info are to be changed about the file at @uri.
 * @options: packed boolean type providing control over various details
 * of the set_file_info operation.
 * @priority: a value from %GNOME_VFS_PRIORITY_MIN to %GNOME_VFS_PRIORITY_MAX (normally
 * should be %GNOME_VFS_PRIORITY_DEFAULT) indicating the priority to assign this job
 * in allocating threads from the thread pool.
 * @callback: function to be called when the operation is complete.
 * @callback_data: data to pass to @callback.
 * 
 * Set file info details about the file at @uri, such as permissions, name,
 * owner, and modification time.
 */
void
gnome_vfs_async_set_file_info (GnomeVFSAsyncHandle **handle_return,
			       GnomeVFSURI *uri,
			       GnomeVFSFileInfo *info,
			       GnomeVFSSetFileInfoMask mask,
			       GnomeVFSFileInfoOptions options,
			       int priority,
			       GnomeVFSAsyncSetFileInfoCallback callback,
			       gpointer callback_data)
{
	GnomeVFSJob *job;
	GnomeVFSSetFileInfoOp *op;

	g_return_if_fail (handle_return != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (info != NULL);
	g_return_if_fail (callback != NULL);
	g_return_if_fail (priority >= GNOME_VFS_PRIORITY_MIN);
	g_return_if_fail (priority <= GNOME_VFS_PRIORITY_MAX);

	job = _gnome_vfs_job_new (GNOME_VFS_OP_SET_FILE_INFO, priority, (GFunc) callback, callback_data);

	op = &job->op->specifics.set_file_info;

	op->uri = gnome_vfs_uri_ref (uri);
	op->info = gnome_vfs_file_info_new ();
	gnome_vfs_file_info_copy (op->info, info);
	op->mask = mask;
	op->options = options;

	*handle_return = job->job_handle;
	_gnome_vfs_job_go (job);
}
Example #2
0
GnomeVFSFileInfo *la_track_get_vfs_info(LaTrack * self)
{
    if (!self->vfs_info) {
	self->vfs_info = gnome_vfs_file_info_new();
	gnome_vfs_get_file_info(self->uri, self->vfs_info,
				GNOME_VFS_FILE_INFO_GET_MIME_TYPE
				| GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
    }
    gnome_vfs_file_info_ref(self->vfs_info);
    return self->vfs_info;
}
const char *
gnome_vfs_get_special_mime_type (GnomeVFSURI *uri)
{
	GnomeVFSResult error;
	GnomeVFSFileInfo *info;
	const char *type;
	
	info = gnome_vfs_file_info_new ();
	type = NULL;
	
	/* Get file info and examine the type field to see if file is 
	 * one of the special kinds. 
	 */
	error = gnome_vfs_get_file_info_uri (uri, info, GNOME_VFS_FILE_INFO_DEFAULT);

	if (error == GNOME_VFS_OK && 
	    info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) {
		
		switch (info->type) {

			case GNOME_VFS_FILE_TYPE_DIRECTORY:
				type = "x-directory/normal";
				break;
				
			case GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE:
				type = "x-special/device-char";
				break;
				
			case GNOME_VFS_FILE_TYPE_BLOCK_DEVICE:
				type = "x-special/device-block";
				break;
				
			case GNOME_VFS_FILE_TYPE_FIFO:
				type = "x-special/fifo";
				break;
				
			case GNOME_VFS_FILE_TYPE_SOCKET:
				type = "x-special/socket";
				break;

			default:
				break;
		}

	}
	
	gnome_vfs_file_info_unref (info);
	return type;	
}
Example #4
0
void populate_tree_model (GtkListStore *model)
{
	GnomeVFSDirectoryHandle *handle;
	GnomeVFSFileInfo *info;
	GnomeVFSResult res;
	GtkTreeIter iter;
//	GValue *value;
	
#define URI "/"

	gnome_vfs_init();
	res = gnome_vfs_directory_open (&handle, URI, GNOME_VFS_FILE_INFO_DEFAULT);
	if (res) goto error;

	for (;;) {
		info = gnome_vfs_file_info_new ();
		res = gnome_vfs_directory_read_next (handle, info);
		
		if (res == GNOME_VFS_ERROR_EOF) break;
		
		if (res && res != GNOME_VFS_ERROR_EOF) {
			gnome_vfs_file_info_unref (info);
			goto error;
		}

	
puts(info->name);
//		value = g_new0 (GValue, 1); 
//		g_value_init (value, G_TYPE_POINTER);
//		g_value_set_pointer (value, info);
		gtk_list_store_append (GTK_LIST_STORE(model), &iter); /** ?? **/	
//		gtk_list_store_set_value (GTK_LIST_STORE(model), &iter, COLUMN_ONE, value);
//		gtk_list_store_set (model, &iter, COLUMN_ONE, info->name, -1);
		gtk_list_store_set (model, &iter, COLUMN_ONE, info, COLUMN_TWO, 0, -1);
	} 

	
	goto done;	

error:
	puts(gnome_vfs_result_to_string (res));

done:
	gnome_vfs_directory_close (handle);
}
Example #5
0
static int
pygvfinfo_init(PyGnomeVFSFileInfo *self, PyObject *args, PyObject *kwargs)
{
    if (kwargs != NULL) {
	PyErr_SetString(PyExc_TypeError,
		"gnomevfs.FileInfo.__init__ takes no keyword arguments");
	return -1;
    }
    if (!PyArg_ParseTuple(args, ":gnomevfs.FileInfo.__init__"))
	return -1;

    self->finfo = gnome_vfs_file_info_new();
    if (!self->finfo) {
	PyErr_SetString(PyExc_TypeError, "could not create FileInfo object");
	return -1;
    }

    return 0;
}
Example #6
0
void
file_data_update (FileData *fd)
{
	GnomeVFSFileInfo *info;
	GnomeVFSResult    result;

	g_return_if_fail (fd != NULL);

	fd->error = FALSE;
	fd->thumb_loaded = FALSE;
	fd->thumb_created = FALSE;

	info = gnome_vfs_file_info_new ();
	result = gnome_vfs_get_file_info (fd->path,
					  info,
					  (GNOME_VFS_FILE_INFO_FOLLOW_LINKS 
					   | GNOME_VFS_FILE_INFO_GET_MIME_TYPE 
					   | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE));

	if (result != GNOME_VFS_OK) {
		fd->error = TRUE;
		fd->size = 0L;
		fd->mtime = 0;
		fd->ctime = 0;
		fd->exif_data_loaded = FALSE;
		fd->mime_type = NULL;
		return;
	}

	fd->name = file_name_from_path (fd->path);

	g_free (fd->display_name);
	fd->display_name = gnome_vfs_unescape_string_for_display (fd->name);

	fd->mime_type = get_static_string (info->mime_type);
	fd->size = info->size;
	fd->mtime = info->mtime;
	fd->ctime = info->ctime;
	fd->exif_data_loaded = FALSE;

	gnome_vfs_file_info_unref (info);
}
Example #7
0
gboolean magick_make_webimage(struct data *data, 
                              struct image *image,
                              const gchar *uri,
                              gint image_h)
{
    MagickWand *wand;
    struct image_size *img_size = NULL;
    GnomeVFSResult result;
    GnomeVFSFileInfo *info;

    g_debug("in magick_make_webimage");

    wand = _generate_webimage(data, image, image_h, &img_size);
    if (wand == NULL) 
        return FALSE;

    /* save the image to a file */
    if (!_save(data, wand, uri)) {
        DestroyMagickWand(wand);
        g_free(img_size);
        return FALSE;
    }
    
    DestroyMagickWand(wand);

    /* get file size */
    info = gnome_vfs_file_info_new();
    result = gnome_vfs_get_file_info(uri, info,
                                     GNOME_VFS_FILE_INFO_DEFAULT | 
                                     GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
    if (result == GNOME_VFS_OK) {
        img_size->size = info->size / 1024;
    } else {
        img_size->size = 0;
    }
    
    image->sizes = g_slist_append(image->sizes, img_size);
    gnome_vfs_file_info_unref(info);

    return TRUE;
}
Example #8
0
static gboolean
gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size)
{
  GstGnomeVFSSrc *src;
  GnomeVFSFileInfo *info;
  GnomeVFSFileInfoOptions options;
  GnomeVFSResult res;

  src = GST_GNOME_VFS_SRC (basesrc);

  *size = -1;
  info = gnome_vfs_file_info_new ();
  options = GNOME_VFS_FILE_INFO_DEFAULT | GNOME_VFS_FILE_INFO_FOLLOW_LINKS;
  res = gnome_vfs_get_file_info_from_handle (src->handle, info, options);
  if (res == GNOME_VFS_OK) {
    if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
      *size = info->size;
      GST_DEBUG_OBJECT (src, "from handle: %" G_GUINT64_FORMAT " bytes", *size);
    } else if (src->own_handle && gnome_vfs_uri_is_local (src->uri)) {
      GST_DEBUG_OBJECT (src,
          "file size not known, file local, trying fallback");
      res = gnome_vfs_get_file_info_uri (src->uri, info, options);
      if (res == GNOME_VFS_OK &&
          (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
        *size = info->size;
        GST_DEBUG_OBJECT (src, "from uri: %" G_GUINT64_FORMAT " bytes", *size);
      }
    }
  } else {
    GST_WARNING_OBJECT (src, "getting info failed: %s",
        gnome_vfs_result_to_string (res));
  }
  gnome_vfs_file_info_unref (info);

  if (*size == (GnomeVFSFileSize) - 1)
    return FALSE;

  GST_DEBUG_OBJECT (src, "return size %" G_GUINT64_FORMAT, *size);

  return TRUE;
}
Example #9
0
gboolean
mn_vfs_test (GnomeVFSURI *uri, GFileTest test)
{
  GnomeVFSFileInfoOptions options;
  GnomeVFSFileInfo *file_info;
  gboolean status = FALSE;

  g_return_val_if_fail(uri != NULL, FALSE);

  options = GNOME_VFS_FILE_INFO_DEFAULT;
  if (! (test & G_FILE_TEST_IS_SYMLINK))
    options |= GNOME_VFS_FILE_INFO_FOLLOW_LINKS;
  if (test & G_FILE_TEST_IS_EXECUTABLE)
    options |= GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS;

  file_info = gnome_vfs_file_info_new();
  if (gnome_vfs_get_file_info_uri(uri, file_info, options) == GNOME_VFS_OK)
    {
      if (file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE)
	{
	  if (test & G_FILE_TEST_IS_REGULAR)
	    status = file_info->type == GNOME_VFS_FILE_TYPE_REGULAR;
	  if (! status && test & G_FILE_TEST_IS_SYMLINK)
	    status = file_info->type == GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK;
	  if (! status && test & G_FILE_TEST_IS_DIR)
	    status = file_info->type == GNOME_VFS_FILE_TYPE_DIRECTORY;
	}
      if (file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS)
	{
	  if (! status && test & G_FILE_TEST_IS_EXECUTABLE)
	    status = file_info->permissions & GNOME_VFS_PERM_ACCESS_EXECUTABLE;
	}
      if (! status && test & G_FILE_TEST_EXISTS)
	status = TRUE; /* gnome_vfs_get_file_info() succeeded, so the file exists */
    }
  gnome_vfs_file_info_unref(file_info);

  return status;
}
Example #10
0
static int
tcp_transfer_dir(tcp_con_t *con,const char *path){
  int rc;
  char *basename;
  GnomeVFSFileInfo *info;
  GnomeVFSResult res;
  gchar *dir_uri;

  if ( (!con) || (!path) )
    return -EINVAL;
  info=gnome_vfs_file_info_new();
  dir_uri=gnome_vfs_get_uri_from_local_path(path);

  rc=-ENOMEM;
  if (!dir_uri) 
    goto free_info_out;

  res=gnome_vfs_get_file_info(dir_uri,info,GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
  if (res != GNOME_VFS_OK) {
    rc=-res;
    goto free_info_out;
  }
  basename=g_path_get_basename(path);
    rc=-ENOMEM;
  if (!basename)
    goto free_info_out;

  rc=send_directory(con,path,basename,info);
  g_free(basename);
  if (!rc)
    rc=finalize_send_directory(con,path,info);
  else
    err_out("Send directory fail %s (%d)\n",
	    strerror(-rc),rc);
 free_info_out:
  gnome_vfs_file_info_unref(info);
  return rc;
}
Example #11
0
static gboolean
copy_uri (const gchar  *src_uri,
          const gchar  *dest_uri,
          const gchar  *copying_format_str,
          const gchar  *copied_format_str,
          GError      **error)
{
  GnomeVFSHandle   *read_handle;
  GnomeVFSHandle   *write_handle;
  GnomeVFSFileInfo *src_info;
  GnomeVFSFileSize  file_size  = 0;
  GnomeVFSFileSize  bytes_read = 0;
  guchar            buffer[BUFSIZE];
  GnomeVFSResult    result;
  gchar            *memsize;
  GTimeVal          last_time = { 0, 0 };

  gimp_progress_init (_("Connecting to server"));

  src_info = gnome_vfs_file_info_new ();
  result = gnome_vfs_get_file_info (src_uri, src_info, 0);

  /*  ignore errors here, they will be noticed below  */
  if (result == GNOME_VFS_OK &&
      (src_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE))
    {
      file_size = src_info->size;
    }

  gnome_vfs_file_info_unref (src_info);

  result = gnome_vfs_open (&read_handle, src_uri, GNOME_VFS_OPEN_READ);

  if (result != GNOME_VFS_OK)
    {
      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                   _("Could not open '%s' for reading: %s"),
                   src_uri, gnome_vfs_result_to_string (result));
      return FALSE;
    }

  result = gnome_vfs_create (&write_handle, dest_uri,
                             GNOME_VFS_OPEN_WRITE, FALSE, 0644);

  if (result != GNOME_VFS_OK)
    {
      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                   _("Could not open '%s' for writing: %s"),
                   dest_uri, gnome_vfs_result_to_string (result));
      gnome_vfs_close (read_handle);
      return FALSE;
    }

  memsize = g_format_size_for_display (file_size);

  gimp_progress_init_printf (file_size > 0 ?
                             copying_format_str : copied_format_str,
                             memsize);

  g_free (memsize);

  while (TRUE)
    {
      GnomeVFSFileSize  chunk_read;
      GnomeVFSFileSize  chunk_written;
      GTimeVal          now;

      result = gnome_vfs_read (read_handle, buffer, sizeof (buffer),
                               &chunk_read);

      if (chunk_read == 0)
        {
          if (result != GNOME_VFS_ERROR_EOF)
            {
              memsize = g_format_size_for_display (sizeof (buffer));
              g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                           _("Failed to read %s from '%s': %s"),
                           memsize, src_uri,
                           gnome_vfs_result_to_string (result));
              g_free (memsize);

              gnome_vfs_close (read_handle);
              gnome_vfs_close (write_handle);
              return FALSE;
            }
          else
            {
              gimp_progress_update (1.0);
              break;
            }
        }

      bytes_read += chunk_read;

      /*  update the progress only up to 10 times a second  */

      g_get_current_time (&now);

      if (((now.tv_sec - last_time.tv_sec) * 1000 +
           (now.tv_usec - last_time.tv_usec) / 1000) > 100)
        {
          if (file_size > 0)
            {
              gimp_progress_update ((gdouble) bytes_read / (gdouble) file_size);
            }
          else
            {
              memsize = g_format_size_for_display (bytes_read);

              gimp_progress_set_text_printf (copied_format_str, memsize);
              gimp_progress_pulse ();

              g_free (memsize);
            }

          last_time = now;
        }

      result = gnome_vfs_write (write_handle, buffer, chunk_read,
                                &chunk_written);

      if (chunk_written < chunk_read)
        {
          memsize = g_format_size_for_display (chunk_read);
          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                       _("Failed to write %s to '%s': %s"),
                       memsize, dest_uri,
                       gnome_vfs_result_to_string (result));
          g_free (memsize);

          gnome_vfs_close (read_handle);
          gnome_vfs_close (write_handle);
          return FALSE;
        }
    }

  gnome_vfs_close (read_handle);
  gnome_vfs_close (write_handle);

  return TRUE;
}
int
main (int argc, char **argv)
{
    GnomeVFSResult result;
    char *text_uri;
    GnomeVFSURI *src, *dest;
    GnomeVFSFileInfo *info;

    if (argc != 3) {
        printf ("Usage: %s <src> <dest>\n", argv[0]);
        return 1;
    }

    if (!gnome_vfs_init ()) {
        fprintf (stderr, "Cannot initialize gnome-vfs.\n");
        return 1;
    }

    command_line_authentication_init ();

    text_uri = gnome_vfs_make_uri_from_shell_arg (argv[1]);

    src = gnome_vfs_uri_new (text_uri);
    g_free (text_uri);

    text_uri = gnome_vfs_make_uri_from_shell_arg (argv[2]);

    dest = gnome_vfs_uri_new (text_uri);
    g_free (text_uri);

    if (src == NULL || dest == NULL) {
        result = GNOME_VFS_ERROR_INVALID_URI;
        goto out;
    }

    info   = gnome_vfs_file_info_new ();
    result = gnome_vfs_get_file_info_uri (dest, info,
                                          GNOME_VFS_FILE_INFO_DEFAULT);

    if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_NOT_FOUND) {
        gnome_vfs_file_info_unref (info);
        goto out;
    }

    /* If the target is a directory do not overwrite it but copy the
       source into the directory! (This is like cp does it) */
    if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE &&
            info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
        char *name;
        GnomeVFSURI *new_dest;

        name     = gnome_vfs_uri_extract_short_path_name (src);
        new_dest = gnome_vfs_uri_append_string (dest, name);
        gnome_vfs_uri_unref (dest);
        g_free (name);
        dest = new_dest;

    }

    gnome_vfs_file_info_unref (info);

    result = gnome_vfs_xfer_uri (src, dest,
                                 GNOME_VFS_XFER_RECURSIVE,
                                 GNOME_VFS_XFER_ERROR_MODE_ABORT,
                                 GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
                                 NULL, NULL);

out:
    if (src) {
        gnome_vfs_uri_unref (src);
    }

    if (dest) {
        gnome_vfs_uri_unref (dest);
    }

    if (result != GNOME_VFS_OK) {
        fprintf (stderr, "Failed to copy %s to %s\nReason: %s\n",
                 argv[1], argv[2], gnome_vfs_result_to_string (result));
        return 1;
    }

    return 0;
}
Example #13
0
gboolean
apply_transformation_jpeg (FileData       *file,
			   GthTransform    transform,
			   JpegMcuAction   mcu_action,
			   GError        **error)
{
	gboolean          result = TRUE;
	char             *tmp_dir = NULL;
	char             *tmp_output_file = NULL;
	JXFORM_CODE       transf;
	char		 *local_file;
	GnomeVFSFileInfo *info = NULL;

	if (file == NULL)
		return FALSE;

	if (transform == GTH_TRANSFORM_NONE)
		return TRUE;

	tmp_dir = get_temp_dir_name ();
	if (tmp_dir == NULL) {
		if (error != NULL)
			*error = g_error_new (GTHUMB_ERROR, 0, "%s", _("Could not create a temporary folder"));
		return FALSE;
	}

	local_file = get_cache_filename_from_uri (file->path);
	if (local_file == NULL) {
		if (error != NULL)
			*error = g_error_new (GTHUMB_ERROR, 0, "%s", _("Could not create a local temporary copy of the remote file."));
		result = FALSE;
		goto apply_transformation_jpeg__free_and_close;
	}

	info = gnome_vfs_file_info_new ();
	gnome_vfs_get_file_info (file->path, info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);

	switch (transform) {
	case GTH_TRANSFORM_NONE:
		transf = JXFORM_NONE;
		break;
	case GTH_TRANSFORM_FLIP_H:
		transf = JXFORM_FLIP_H;
		break;
	case GTH_TRANSFORM_ROTATE_180:
		transf = JXFORM_ROT_180;
		break;
	case GTH_TRANSFORM_FLIP_V:
		transf = JXFORM_FLIP_V;
		break;
	case GTH_TRANSFORM_TRANSPOSE:
		transf = JXFORM_TRANSPOSE;
		break;
	case GTH_TRANSFORM_ROTATE_90:
		transf = JXFORM_ROT_90;
		break;
	case GTH_TRANSFORM_TRANSVERSE:
		transf = JXFORM_TRANSVERSE;
		break;
	case GTH_TRANSFORM_ROTATE_270:
		transf = JXFORM_ROT_270;
		break;
	default:
		transf = JXFORM_NONE;
		break;
	}

	tmp_output_file = get_temp_file_name (tmp_dir, NULL);
	if (! jpegtran (local_file, tmp_output_file, transf, mcu_action, error)) {
		result = FALSE;
		goto apply_transformation_jpeg__free_and_close;
	}

	if (! local_file_move (tmp_output_file, local_file)) {
		if (error != NULL)
			*error = g_error_new (GTHUMB_ERROR, 0, "%s", _("Could not move temporary file to local destination. Check folder permissions."));
		result = FALSE;
		goto apply_transformation_jpeg__free_and_close;	
	}

	if (info != NULL) {
		char *local_uri;
		
		local_uri = get_uri_from_local_path (local_file);
		gnome_vfs_set_file_info (local_uri, info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS | GNOME_VFS_SET_FILE_INFO_OWNER);
		gnome_vfs_file_info_unref (info);
		g_free (local_uri);
	}

apply_transformation_jpeg__free_and_close:

	local_dir_remove_recursive (tmp_dir);
	g_free (tmp_output_file);
	g_free (tmp_dir);

	return result;
}
Example #14
0
static int
pygvfinfo_setattr(PyGnomeVFSFileInfo *self, const gchar *attr, PyObject *value)
{
    GnomeVFSFileInfo *finfo;

    if (!self->finfo)
	self->finfo = gnome_vfs_file_info_new();
    finfo = self->finfo;

    if (!strcmp(attr, "__members__")) {
	PyErr_SetString(PyExc_TypeError, "readonly attribute");
	return -1;

    } else if (!strcmp(attr, "name")) {
        if (!PyString_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'name' attribute must be a string");
                return -1;
        }
	if (finfo->name) g_free(finfo->name);
        finfo->name = g_strdup(PyString_AsString(value));
	return 0;

    } else if (!strcmp(attr, "valid_fields")) {
        if (!PyInt_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'valid_fields' attribute must be an int");
                return -1;
        }
	finfo->valid_fields = PyInt_AsLong(value);
        return 0;

    } else if (!strcmp(attr, "type")) {
        if (!PyInt_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'type' attribute must be an int");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_TYPE;
	finfo->type = PyInt_AsLong(value);
        return 0;

    } else if (!strcmp(attr, "permissions")) {
        if (!PyInt_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'permissions' attribute must be an int");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS;
	finfo->permissions = PyInt_AsLong(value);
        return 0;

    } else if (!strcmp(attr, "access")) {
        if (!PyInt_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'access' attribute must be an int");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_ACCESS;
	finfo->permissions |= PyInt_AsLong(value);
        return 0;

    } else if (!strcmp(attr, "flags")) {
        if (!PyInt_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'flags' attribute must be an int");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_FLAGS;
	finfo->flags = PyInt_AsLong(value);
        return 0;

    } else if (!strcmp(attr, "device")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'device' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_DEVICE;
	if (PyInt_Check(value))
	    finfo->device = PyInt_AsLong(value);
	else
	    finfo->device = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "inode")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'inode' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_INODE;
	if (PyInt_Check(value))
	    finfo->inode = PyInt_AsLong(value);
	else
	    finfo->inode = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "link_count")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'link_count' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_LINK_COUNT;
	if (PyInt_Check(value))
	    finfo->link_count = PyInt_AsLong(value);
	else
	    finfo->link_count = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "uid")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'uid' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_IDS;
	if (PyInt_Check(value))
	    finfo->uid = PyInt_AsLong(value);
	else
	    finfo->uid = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "gid")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'gid' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_IDS;
	if (PyInt_Check(value))
	    finfo->gid = PyInt_AsLong(value);
	else
	    finfo->gid = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "size")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'size' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SIZE;
	if (PyInt_Check(value))
	    finfo->size = PyInt_AsLong(value);
	else
	    finfo->size = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "block_count")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'block_count' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT;
	if (PyInt_Check(value))
	    finfo->block_count = PyInt_AsLong(value);
	else
	    finfo->block_count = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "io_block_size")) {
        if (!(PyInt_Check(value) || PyLong_Check(value))) {
            	PyErr_SetString(PyExc_TypeError,
                                "'io_block_size' attribute must be an int or long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_IO_BLOCK_SIZE;
	if (PyInt_Check(value))
	    finfo->io_block_size = PyInt_AsLong(value);
	else
	    finfo->io_block_size = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "atime")) {
        if (!PyLong_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'atime' attribute must be a long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_ATIME;
	finfo->atime = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "mtime")) {
        if (!PyLong_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'mtime' attribute must be a long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_MTIME;
	finfo->mtime = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "ctime")) {
        if (!PyLong_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'ctime' attribute must be a long");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_CTIME;
	finfo->ctime = PyLong_AsUnsignedLongLong(value);
        return 0;

    } else if (!strcmp(attr, "symlink_name")) {
        if (!PyString_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'symlink_name' attribute must be a string");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME;
	if (finfo->symlink_name) g_free(finfo->symlink_name);
        finfo->symlink_name = g_strdup(PyString_AsString(value));
	return 0;

    } else if (!strcmp(attr, "mime_type")) {
        if (!PyString_Check(value)) {
            	PyErr_SetString(PyExc_TypeError,
                                "'mime_type' attribute must be a string");
                return -1;
        }
	finfo->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE;
	if (finfo->mime_type) g_free(finfo->mime_type);
        finfo->mime_type = g_strdup(PyString_AsString(value));
	return 0;

    } else {
	PyObject *name = PyString_FromString(attr);
	int ret = PyObject_GenericSetAttr((PyObject *)self, name, value);

	Py_DECREF(name);
	return ret;
    }
}