You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
koffice/filters/chalk/xcf/xcf/xcf-seek.cpp

80 lines
2.1 KiB

/* The GIMP -- an image manipulation program
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include <stdio.h>
#include <errno.h>
#include <glib-object.h>
#include "core/core-types.h"
#include "xcf-private.h"
#include "xcf-seek.h"
#include "gimp-intl.h"
bool
xcf_seek_pos (XcfInfo *info,
TQ_UINT32 pos,
GError **error)
{
if (info->cp != pos)
{
info->cp = pos;
if (fseek (info->fp, info->cp, SEEK_SET) == -1)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not seek in XCF file: %s"),
g_strerror (errno));
return FALSE;
}
}
return TRUE;
}
bool
xcf_seek_end (XcfInfo *info,
GError **error)
{
if (fseek (info->fp, 0, SEEK_END) == -1)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not seek in XCF file: %s"),
g_strerror (errno));
return FALSE;
}
info->cp = ftell (info->fp);
if (fseek (info->fp, 0, SEEK_END) == -1)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not seek in XCF file: %s"),
g_strerror (errno));
return FALSE;
}
return TRUE;
}