Thomas Klausner | e93f73d | 2000-11-04 23:26:53 +0000 | [diff] [blame] | 1 | /* |
Dieter Baron | adaf98c | 2003-10-06 16:37:42 +0000 | [diff] [blame] | 2 | $NiH: zip_get_name.c,v 1.5 2003/10/02 14:13:30 dillo Exp $ |
Dieter Baron | 1c5ffe2 | 2002-06-06 09:27:17 +0000 | [diff] [blame] | 3 | |
Thomas Klausner | e93f73d | 2000-11-04 23:26:53 +0000 | [diff] [blame] | 4 | zip_get_name.c -- get filename for a file in zip file |
Dieter Baron | 9360da0 | 2003-10-01 09:51:01 +0000 | [diff] [blame] | 5 | Copyright (C) 1999, 2003 Dieter Baron and Thomas Klausner |
Thomas Klausner | e93f73d | 2000-11-04 23:26:53 +0000 | [diff] [blame] | 6 | |
Dieter Baron | dd9afca | 2003-10-02 14:13:37 +0000 | [diff] [blame] | 7 | This file is part of libzip, a library to manipulate ZIP archives. |
Thomas Klausner | e93f73d | 2000-11-04 23:26:53 +0000 | [diff] [blame] | 8 | The authors can be contacted at <nih@giga.or.at> |
| 9 | |
Dieter Baron | dd9afca | 2003-10-02 14:13:37 +0000 | [diff] [blame] | 10 | 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 Klausner | e93f73d | 2000-11-04 23:26:53 +0000 | [diff] [blame] | 34 | */ |
| 35 | |
| 36 | |
| 37 | |
| 38 | #include "zip.h" |
| 39 | #include "zipint.h" |
| 40 | |
| 41 | |
| 42 | |
Dieter Baron | 9360da0 | 2003-10-01 09:51:01 +0000 | [diff] [blame] | 43 | const char * |
Thomas Klausner | e93f73d | 2000-11-04 23:26:53 +0000 | [diff] [blame] | 44 | zip_get_name(struct zip *zf, int idx) |
| 45 | { |
| 46 | if (idx < 0 || idx >= zf->nentry) { |
Dieter Baron | adaf98c | 2003-10-06 16:37:42 +0000 | [diff] [blame] | 47 | _zip_error_set(&zf->error, ZERR_INVAL, 0); |
Thomas Klausner | e93f73d | 2000-11-04 23:26:53 +0000 | [diff] [blame] | 48 | return NULL; |
| 49 | } |
| 50 | |
| 51 | return zf->entry[idx].fn; |
| 52 | } |