Ticket #21: zip_archive_diffs

File zip_archive_diffs, 6.7 KB (added by ataylor, 11 years ago)

diffs for implementing OS/2 -AC and -AS support in zip

Line 
1Index: zip.c
2===================================================================
3--- zip.c (revision 658)
4+++ zip.c (working copy)
5@@ -1968,7 +1968,7 @@
6 {"8", "compress-8", o_NO_VALUE, o_NOT_NEGATABLE, '8', "compress 8"},
7 {"9", "compress-9", o_NO_VALUE, o_NOT_NEGATABLE, '9', "compress 9"},
8 {"A", "adjust-sfx", o_NO_VALUE, o_NOT_NEGATABLE, 'A', "adjust self extractor offsets"},
9-#if defined(WIN32)
10+#if defined(WIN32) || defined(OS2)
11 {"AC", "archive-clear", o_NO_VALUE, o_NOT_NEGATABLE, o_AC, "clear DOS archive bit of included files"},
12 {"AS", "archive-set", o_NO_VALUE, o_NOT_NEGATABLE, o_AS, "include only files with archive bit set"},
13 #endif
14@@ -2339,7 +2339,7 @@
15 hidden_files = 0; /* process hidden and system files */
16 volume_label = 0; /* add volume label */
17 dirnames = 1; /* include directory entries by default */
18-#if defined(WIN32)
19+#if defined(WIN32) || defined(OS2)
20 only_archive_set = 0; /* only include if DOS archive bit set */
21 clear_archive_bits = 0; /* clear DOS archive bit of included files */
22 #endif
23@@ -2667,7 +2667,7 @@
24 level = (int)option - '0'; break;
25 case 'A': /* Adjust unzipsfx'd zipfile: adjust offsets only */
26 adjust = 1; break;
27-#if defined(WIN32)
28+#if defined(WIN32) || defined(OS2)
29 case o_AC:
30 clear_archive_bits = 1; break;
31 case o_AS:
32@@ -5984,6 +5984,19 @@
33 # endif
34 }
35 }
36+
37+#elif defined(OS2)
38+ /* All looks good so, if requested, clear the DOS archive bits */
39+ if (clear_archive_bits) {
40+ if (noisy)
41+ zipmessage("Clearing archive bits...", "");
42+ for (z = zfiles; z != NULL; z = z->nxt)
43+ {
44+ if (!ClearArchiveBit(z->name)){
45+ zipwarn("Could not clear archive bit for: ", z->oname);
46+ }
47+ }
48+ }
49 #endif
50
51 /* finish logfile (it gets closed in freeup() called by finish()) */
52Index: zip.h
53===================================================================
54--- zip.h (revision 658)
55+++ zip.h (working copy)
56@@ -431,7 +431,7 @@
57 extern int dirnames; /* include directory names */
58 extern int filter_match_case; /* 1=match case when filter() */
59 extern int diff_mode; /* 1=require --out and only store changed and add */
60-#if defined(WIN32)
61+#if defined(WIN32) || defined(OS2)
62 extern int only_archive_set; /* only include if DOS archive bit set */
63 extern int clear_archive_bits; /* clear DOS archive bit of included files */
64 #endif
65@@ -863,6 +863,13 @@
66 */
67
68 /*---------------------------------------------------------------------------
69+ OS2-only functions:
70+ ---------------------------------------------------------------------------*/
71+#ifdef OS2
72+ int ClearArchiveBit OF((char *)); /* os2zip.c */
73+#endif
74+
75+/*---------------------------------------------------------------------------
76 WIN32-only functions:
77 ---------------------------------------------------------------------------*/
78 #ifdef WIN32
79Index: os2/os2.c
80===================================================================
81--- os2/os2.c (revision 658)
82+++ os2/os2.c (working copy)
83@@ -19,6 +19,17 @@
84 #include <dirent.h>
85 #endif
86
87+// ALT
88+#ifndef FILE_HIDDEN
89+ #define FILE_HIDDEN 0x0002
90+#endif
91+#ifndef FILE_SYSTEM
92+ #define FILE_SYSTEM 0x0004
93+#endif
94+#ifndef FILE_ARCHIVED
95+ #define FILE_ARCHIVED 0x0020
96+#endif
97+
98 /* Extra malloc() space in names for cutpath() */
99 #define PAD 0
100 #define PATH_END '/'
101@@ -60,7 +71,7 @@
102 int amatch = 0, e = ZE_MISS;
103
104 if (!isshexp(wildtail)) {
105-#ifdef LARGE_FILE_SUPPORT
106+#ifdef LARGE_FILE_SUPPORT
107 z_stat s; /* dummy buffer for stat() */
108 #else
109 struct stat s; /* dummy buffer for stat() */
110@@ -341,7 +352,7 @@
111 char *e; /* pointer to name from readd() */
112 int m; /* matched flag */
113 char *p; /* path for recursion */
114-#ifdef LARGE_FILE_SUPPORT
115+#ifdef LARGE_FILE_SUPPORT
116 z_stat s; /* result of stat() */
117 #else
118 struct stat s; /* result of stat() */
119@@ -383,9 +394,17 @@
120 *p = '/';
121 if ((s.st_mode & S_IFDIR) == 0)
122 {
123- /* add or remove name of file */
124- if ((m = newname(n, 0, caseflag)) != ZE_OK)
125- return m;
126+ /* add exclusions in directory recurse but ignored for single file */
127+ int dwAttr = GetFileMode(n);
128+
129+ if ((hidden_files ||
130+ !(dwAttr & FILE_HIDDEN || dwAttr & FILE_SYSTEM)) &&
131+ (!only_archive_set || (dwAttr & FILE_ARCHIVED)))
132+ {
133+ /* add or remove name of file */
134+ if ((m = newname(n, 0, caseflag)) != ZE_OK)
135+ return m;
136+ }
137 } else {
138 /* Add trailing / to the directory name */
139 if ((p = malloc(strlen(n)+2)) == NULL)
140Index: os2/os2zip.c
141===================================================================
142--- os2/os2zip.c (revision 658)
143+++ os2/os2zip.c (working copy)
144@@ -70,7 +70,7 @@
145
146 #ifndef UTIL
147
148-#ifndef __KLIBC__
149+#ifndef __KLIBC__
150 extern int noisy;
151
152 #ifndef S_IFMT
153@@ -1231,4 +1231,28 @@
154
155 } /* end function version_local() */
156
157+int ClearArchiveBit(char *path)
158+{
159+ FILESTATUS3L fsts3l;
160+ APIRET rc;
161+ ULONG cbBuf = sizeof(FILESTATUS3L);
162+ USHORT nLength;
163+ char name[CCHMAXPATH];
164+
165+ strcpy(name, path);
166+ nLength = strlen(name);
167+ if (name[nLength - 1] == '/')
168+ name[nLength - 1] = 0;
169+
170+ rc = DosQueryPathInfo(name, FIL_STANDARDL, &fsts3l, cbBuf);
171+ if (rc != NO_ERROR)
172+ return (0);
173+
174+ if (!(fsts3l.attrFile & FILE_ARCHIVED))
175+ return (1);
176+ fsts3l.attrFile &= ~FILE_ARCHIVED;
177+ rc = DosSetPathInfo(name, FIL_STANDARDL, &fsts3l, cbBuf, 0);
178+ return ((rc == NO_ERROR)? 1 : 0);
179+}
180+
181 #endif /* OS2 */
182Index: os2/os2zip.h
183===================================================================
184--- os2/os2zip.h (revision 658)
185+++ os2/os2zip.h (working copy)
186@@ -78,6 +78,8 @@
187 int IsFileSystemFAT(char *dir);
188 void ChangeNameForFAT(char *name);
189
190+int ClearArchiveBit(char *path);
191+
192 char *GetLongNameEA(const char *name);
193 char *GetLongPathEA(const char *name);
194 void GetEAs(char *name, char **bufptr, size_t *size,
195Index: globals.c
196===================================================================
197--- globals.c (revision 658)
198+++ globals.c (working copy)
199@@ -98,7 +98,7 @@
200 int dirnames = 1; /* include directory entries by default */
201 int filter_match_case = 1; /* 1=match case when filter() */
202 int diff_mode = 0; /* 1=require --out and only store changed and add */
203-#if defined(WIN32)
204+#if defined(WIN32) || defined(OS2)
205 int only_archive_set = 0; /* include only files with DOS archive bit set */
206 int clear_archive_bits = 0; /* clear DOS archive bit of included files */
207 #endif