Imported Upstream version 0.10.1
[platform/upstream/libzip.git] / regress / deltest.c
1 #include "zip.h"
2 #include "error.h"
3
4 char *prg;
5 #define BUFSIZE 65536
6
7 int
8 main(int argc, char *argv[])
9 {
10     struct zip *za;
11
12     if (argc != 2) {
13         fprintf(stderr, "%s: call with one option: zip-file. First file"
14                 " in zip-file will be deleted\n", argv[0]);
15         return 1;
16     }
17
18     if ((za=zip_open(argv[1], ZIP_CHECKCONS))==NULL) {
19         fprintf(stderr, "%s: can't open '%s': %s\n", argv[0], argv[1],
20                 zip_err_str[zip_err]);
21         return 1;
22     }
23
24     if (zip_delete(za, 0)< 0) {
25         fprintf(stderr, "%s: can't delete first file in '%s': %s", 
26                 argv[0], argv[1], zip_err_str[zip_err]);
27         return 1;
28     }
29
30     if (zip_close(za)!=0) {
31         fprintf(stderr, "%s: can't close file '%s': %s", argv[0], argv[1],
32                 zip_err_str[zip_err]);
33         return 1;
34     }
35     
36     return 0;
37 }