blob: d9a88d7d8e6a4b831f94db318a2a457a55c02d49 [file] [log] [blame]
Thomas Klausnere93f73d2000-11-04 23:26:53 +00001/*
Dieter Baronadaf98c2003-10-06 16:37:42 +00002 $NiH: zip_get_name.c,v 1.5 2003/10/02 14:13:30 dillo Exp $
Dieter Baron1c5ffe22002-06-06 09:27:17 +00003
Thomas Klausnere93f73d2000-11-04 23:26:53 +00004 zip_get_name.c -- get filename for a file in zip file
Dieter Baron9360da02003-10-01 09:51:01 +00005 Copyright (C) 1999, 2003 Dieter Baron and Thomas Klausner
Thomas Klausnere93f73d2000-11-04 23:26:53 +00006
Dieter Barondd9afca2003-10-02 14:13:37 +00007 This file is part of libzip, a library to manipulate ZIP archives.
Thomas Klausnere93f73d2000-11-04 23:26:53 +00008 The authors can be contacted at <nih@giga.or.at>
9
Dieter Barondd9afca2003-10-02 14:13:37 +000010 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions
12 are met:
13 1. Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in
17 the documentation and/or other materials provided with the
18 distribution.
19 3. The names of the authors may not be used to endorse or promote
20 products derived from this software without specific prior
21 written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Thomas Klausnere93f73d2000-11-04 23:26:53 +000034*/
35
36
37
38#include "zip.h"
39#include "zipint.h"
40
41
42
Dieter Baron9360da02003-10-01 09:51:01 +000043const char *
Thomas Klausnere93f73d2000-11-04 23:26:53 +000044zip_get_name(struct zip *zf, int idx)
45{
46 if (idx < 0 || idx >= zf->nentry) {
Dieter Baronadaf98c2003-10-06 16:37:42 +000047 _zip_error_set(&zf->error, ZERR_INVAL, 0);
Thomas Klausnere93f73d2000-11-04 23:26:53 +000048 return NULL;
49 }
50
51 return zf->entry[idx].fn;
52}