Index: zip.c =================================================================== --- zip.c (revision 658) +++ zip.c (working copy) @@ -1968,7 +1968,7 @@ {"8", "compress-8", o_NO_VALUE, o_NOT_NEGATABLE, '8', "compress 8"}, {"9", "compress-9", o_NO_VALUE, o_NOT_NEGATABLE, '9', "compress 9"}, {"A", "adjust-sfx", o_NO_VALUE, o_NOT_NEGATABLE, 'A', "adjust self extractor offsets"}, -#if defined(WIN32) +#if defined(WIN32) || defined(OS2) {"AC", "archive-clear", o_NO_VALUE, o_NOT_NEGATABLE, o_AC, "clear DOS archive bit of included files"}, {"AS", "archive-set", o_NO_VALUE, o_NOT_NEGATABLE, o_AS, "include only files with archive bit set"}, #endif @@ -2339,7 +2339,7 @@ hidden_files = 0; /* process hidden and system files */ volume_label = 0; /* add volume label */ dirnames = 1; /* include directory entries by default */ -#if defined(WIN32) +#if defined(WIN32) || defined(OS2) only_archive_set = 0; /* only include if DOS archive bit set */ clear_archive_bits = 0; /* clear DOS archive bit of included files */ #endif @@ -2667,7 +2667,7 @@ level = (int)option - '0'; break; case 'A': /* Adjust unzipsfx'd zipfile: adjust offsets only */ adjust = 1; break; -#if defined(WIN32) +#if defined(WIN32) || defined(OS2) case o_AC: clear_archive_bits = 1; break; case o_AS: @@ -5984,6 +5984,19 @@ # endif } } + +#elif defined(OS2) + /* All looks good so, if requested, clear the DOS archive bits */ + if (clear_archive_bits) { + if (noisy) + zipmessage("Clearing archive bits...", ""); + for (z = zfiles; z != NULL; z = z->nxt) + { + if (!ClearArchiveBit(z->name)){ + zipwarn("Could not clear archive bit for: ", z->oname); + } + } + } #endif /* finish logfile (it gets closed in freeup() called by finish()) */ Index: zip.h =================================================================== --- zip.h (revision 658) +++ zip.h (working copy) @@ -431,7 +431,7 @@ extern int dirnames; /* include directory names */ extern int filter_match_case; /* 1=match case when filter() */ extern int diff_mode; /* 1=require --out and only store changed and add */ -#if defined(WIN32) +#if defined(WIN32) || defined(OS2) extern int only_archive_set; /* only include if DOS archive bit set */ extern int clear_archive_bits; /* clear DOS archive bit of included files */ #endif @@ -863,6 +863,13 @@ */ /*--------------------------------------------------------------------------- + OS2-only functions: + ---------------------------------------------------------------------------*/ +#ifdef OS2 + int ClearArchiveBit OF((char *)); /* os2zip.c */ +#endif + +/*--------------------------------------------------------------------------- WIN32-only functions: ---------------------------------------------------------------------------*/ #ifdef WIN32 Index: os2/os2.c =================================================================== --- os2/os2.c (revision 658) +++ os2/os2.c (working copy) @@ -19,6 +19,17 @@ #include #endif +// ALT +#ifndef FILE_HIDDEN + #define FILE_HIDDEN 0x0002 +#endif +#ifndef FILE_SYSTEM + #define FILE_SYSTEM 0x0004 +#endif +#ifndef FILE_ARCHIVED + #define FILE_ARCHIVED 0x0020 +#endif + /* Extra malloc() space in names for cutpath() */ #define PAD 0 #define PATH_END '/' @@ -60,7 +71,7 @@ int amatch = 0, e = ZE_MISS; if (!isshexp(wildtail)) { -#ifdef LARGE_FILE_SUPPORT +#ifdef LARGE_FILE_SUPPORT z_stat s; /* dummy buffer for stat() */ #else struct stat s; /* dummy buffer for stat() */ @@ -341,7 +352,7 @@ char *e; /* pointer to name from readd() */ int m; /* matched flag */ char *p; /* path for recursion */ -#ifdef LARGE_FILE_SUPPORT +#ifdef LARGE_FILE_SUPPORT z_stat s; /* result of stat() */ #else struct stat s; /* result of stat() */ @@ -383,9 +394,17 @@ *p = '/'; if ((s.st_mode & S_IFDIR) == 0) { - /* add or remove name of file */ - if ((m = newname(n, 0, caseflag)) != ZE_OK) - return m; + /* add exclusions in directory recurse but ignored for single file */ + int dwAttr = GetFileMode(n); + + if ((hidden_files || + !(dwAttr & FILE_HIDDEN || dwAttr & FILE_SYSTEM)) && + (!only_archive_set || (dwAttr & FILE_ARCHIVED))) + { + /* add or remove name of file */ + if ((m = newname(n, 0, caseflag)) != ZE_OK) + return m; + } } else { /* Add trailing / to the directory name */ if ((p = malloc(strlen(n)+2)) == NULL) Index: os2/os2zip.c =================================================================== --- os2/os2zip.c (revision 658) +++ os2/os2zip.c (working copy) @@ -70,7 +70,7 @@ #ifndef UTIL -#ifndef __KLIBC__ +#ifndef __KLIBC__ extern int noisy; #ifndef S_IFMT @@ -1231,4 +1231,28 @@ } /* end function version_local() */ +int ClearArchiveBit(char *path) +{ + FILESTATUS3L fsts3l; + APIRET rc; + ULONG cbBuf = sizeof(FILESTATUS3L); + USHORT nLength; + char name[CCHMAXPATH]; + + strcpy(name, path); + nLength = strlen(name); + if (name[nLength - 1] == '/') + name[nLength - 1] = 0; + + rc = DosQueryPathInfo(name, FIL_STANDARDL, &fsts3l, cbBuf); + if (rc != NO_ERROR) + return (0); + + if (!(fsts3l.attrFile & FILE_ARCHIVED)) + return (1); + fsts3l.attrFile &= ~FILE_ARCHIVED; + rc = DosSetPathInfo(name, FIL_STANDARDL, &fsts3l, cbBuf, 0); + return ((rc == NO_ERROR)? 1 : 0); +} + #endif /* OS2 */ Index: os2/os2zip.h =================================================================== --- os2/os2zip.h (revision 658) +++ os2/os2zip.h (working copy) @@ -78,6 +78,8 @@ int IsFileSystemFAT(char *dir); void ChangeNameForFAT(char *name); +int ClearArchiveBit(char *path); + char *GetLongNameEA(const char *name); char *GetLongPathEA(const char *name); void GetEAs(char *name, char **bufptr, size_t *size, Index: globals.c =================================================================== --- globals.c (revision 658) +++ globals.c (working copy) @@ -98,7 +98,7 @@ int dirnames = 1; /* include directory entries by default */ int filter_match_case = 1; /* 1=match case when filter() */ int diff_mode = 0; /* 1=require --out and only store changed and add */ -#if defined(WIN32) +#if defined(WIN32) || defined(OS2) int only_archive_set = 0; /* include only files with DOS archive bit set */ int clear_archive_bits = 0; /* clear DOS archive bit of included files */ #endif