diff options
Diffstat (limited to 'filters/chalk/xcf/xcf/xcf-seek.cpp')
-rw-r--r-- | filters/chalk/xcf/xcf/xcf-seek.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/filters/chalk/xcf/xcf/xcf-seek.cpp b/filters/chalk/xcf/xcf/xcf-seek.cpp new file mode 100644 index 000000000..a24271f5e --- /dev/null +++ b/filters/chalk/xcf/xcf/xcf-seek.cpp @@ -0,0 +1,79 @@ +/* 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; +} |