filters

xcf-seek.cc

00001 /* The GIMP -- an image manipulation program
00002  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #include "config.h"
00020 
00021 #include <stdio.h>
00022 #include <errno.h>
00023 
00024 #include <glib-object.h>
00025 
00026 #include "core/core-types.h"
00027 
00028 #include "xcf-private.h"
00029 #include "xcf-seek.h"
00030 
00031 #include "gimp-intl.h"
00032 
00033 bool
00034 xcf_seek_pos (XcfInfo  *info,
00035           Q_UINT32     pos,
00036           GError  **error)
00037 {
00038     if (info->cp != pos)
00039     {
00040         info->cp = pos;
00041         if (fseek (info->fp, info->cp, SEEK_SET) == -1)
00042         {
00043             g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
00044                          _("Could not seek in XCF file: %s"),
00045                          g_strerror (errno));
00046 
00047             return FALSE;
00048         }
00049     }
00050 
00051     return TRUE;
00052 }
00053 
00054 bool
00055 xcf_seek_end (XcfInfo  *info,
00056               GError  **error)
00057 {
00058     if (fseek (info->fp, 0, SEEK_END) == -1)
00059     {
00060         g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
00061                      _("Could not seek in XCF file: %s"),
00062                      g_strerror (errno));
00063 
00064         return FALSE;
00065     }
00066 
00067     info->cp = ftell (info->fp);
00068 
00069     if (fseek (info->fp, 0, SEEK_END) == -1)
00070     {
00071         g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
00072                      _("Could not seek in XCF file: %s"),
00073                      g_strerror (errno));
00074 
00075         return FALSE;
00076     }
00077 
00078     return TRUE;
00079 }
KDE Home | KDE Accessibility Home | Description of Access Keys