2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2000-02-24 16:11:26 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2001-07-03 18:38:56 +00:00
|
|
|
#include "config.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-07-03 18:38:56 +00:00
|
|
|
#include <stdio.h>
|
2002-12-20 06:26:34 +00:00
|
|
|
#include <errno.h>
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-12-07 16:10:53 +00:00
|
|
|
#include <glib-object.h>
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-07-03 18:38:56 +00:00
|
|
|
#include "core/core-types.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-07-03 18:38:56 +00:00
|
|
|
#include "xcf-private.h"
|
|
|
|
#include "xcf-seek.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-12-20 06:26:34 +00:00
|
|
|
gboolean
|
2003-09-10 10:40:57 +00:00
|
|
|
xcf_seek_pos (XcfInfo *info,
|
2006-04-12 12:49:29 +00:00
|
|
|
guint pos,
|
|
|
|
GError **error)
|
2001-07-03 18:38:56 +00:00
|
|
|
{
|
|
|
|
if (info->cp != pos)
|
|
|
|
{
|
|
|
|
info->cp = pos;
|
2002-12-20 06:26:34 +00:00
|
|
|
if (fseek (info->fp, info->cp, SEEK_SET) == -1)
|
|
|
|
{
|
|
|
|
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
2003-09-10 10:40:57 +00:00
|
|
|
_("Could not seek in XCF file: %s"),
|
2002-12-20 06:26:34 +00:00
|
|
|
g_strerror (errno));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-07-03 18:38:56 +00:00
|
|
|
}
|
2002-12-20 06:26:34 +00:00
|
|
|
|
2003-09-10 10:40:57 +00:00
|
|
|
return TRUE;
|
2001-07-03 18:38:56 +00:00
|
|
|
}
|
|
|
|
|
2002-12-20 06:26:34 +00:00
|
|
|
gboolean
|
2003-09-10 10:40:57 +00:00
|
|
|
xcf_seek_end (XcfInfo *info,
|
|
|
|
GError **error)
|
2001-07-03 18:38:56 +00:00
|
|
|
{
|
2002-12-20 06:26:34 +00:00
|
|
|
if (fseek (info->fp, 0, SEEK_END) == -1)
|
|
|
|
{
|
|
|
|
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
2003-09-10 10:40:57 +00:00
|
|
|
_("Could not seek in XCF file: %s"),
|
2002-12-20 06:26:34 +00:00
|
|
|
g_strerror (errno));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-09-10 10:40:57 +00:00
|
|
|
|
2001-07-03 18:38:56 +00:00
|
|
|
info->cp = ftell (info->fp);
|
2002-12-20 06:26:34 +00:00
|
|
|
|
|
|
|
if (fseek (info->fp, 0, SEEK_END) == -1)
|
|
|
|
{
|
|
|
|
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
2003-09-10 10:40:57 +00:00
|
|
|
_("Could not seek in XCF file: %s"),
|
2002-12-20 06:26:34 +00:00
|
|
|
g_strerror (errno));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-09-10 10:40:57 +00:00
|
|
|
|
2002-12-20 06:26:34 +00:00
|
|
|
return TRUE;
|
2001-07-03 18:38:56 +00:00
|
|
|
}
|