1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * gsf-zip-utils.c: tools for zip archive output.
5 * Copyright (C) 2002-2006 Jon K Hellan (hellan@acm.org)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of version 2.1 of the GNU Lesser General Public
9 * License as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Outc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22 #include <gsf-config.h>
24 #include <sys/types.h>
26 #include "gsf-zip-impl.h"
30 * @Short_description: Utilities for reading and writing ZIP/JAR files
33 * #GsfInfile and #GsfOutfile support for zip files.
36 /* Doesn't do much, but include for symmetry */
38 gsf_zip_dirent_new (void)
40 return g_new0 (GsfZipDirent, 1);
44 gsf_zip_dirent_free (GsfZipDirent *dirent)
46 g_return_if_fail (dirent != NULL);
48 g_free (dirent->name);
55 gsf_vdir_new (char const *name, gboolean is_directory, GsfZipDirent *dirent)
57 GsfZipVDir *vdir = g_new (GsfZipVDir, 1);
59 vdir->name = g_strdup (name);
60 vdir->is_directory = is_directory;
61 vdir->dirent = dirent;
62 vdir->children = NULL;
67 gsf_vdir_free (GsfZipVDir *vdir, gboolean free_dirent)
74 for (l = vdir->children; l; l = l->next)
75 gsf_vdir_free ((GsfZipVDir *)l->data, free_dirent);
77 g_slist_free (vdir->children);
79 if (free_dirent && vdir->dirent)
80 gsf_zip_dirent_free (vdir->dirent);
85 gsf_vdir_add_child (GsfZipVDir *vdir, GsfZipVDir *child)
87 GSList *tail = g_slist_append (NULL, child);
89 vdir->last_child->next = tail;
91 vdir->children = tail;
92 vdir->last_child = tail;