File: deltest.c

package info (click to toggle)
libzip 0.10.1-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,496 kB
  • sloc: sh: 10,520; ansic: 5,689; makefile: 271
file content (37 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "zip.h"
#include "error.h"

char *prg;
#define BUFSIZE 65536

int
main(int argc, char *argv[])
{
    struct zip *za;

    if (argc != 2) {
	fprintf(stderr, "%s: call with one option: zip-file. First file"
		" in zip-file will be deleted\n", argv[0]);
	return 1;
    }

    if ((za=zip_open(argv[1], ZIP_CHECKCONS))==NULL) {
	fprintf(stderr, "%s: can't open '%s': %s\n", argv[0], argv[1],
		zip_err_str[zip_err]);
	return 1;
    }

    if (zip_delete(za, 0)< 0) {
	fprintf(stderr, "%s: can't delete first file in '%s': %s", 
		argv[0], argv[1], zip_err_str[zip_err]);
	return 1;
    }

    if (zip_close(za)!=0) {
	fprintf(stderr, "%s: can't close file '%s': %s", argv[0], argv[1],
		zip_err_str[zip_err]);
	return 1;
    }
    
    return 0;
}