From bdccb5b1c712d2ecc8f4726bbc95a8c7af009046 Mon Sep 17 00:00:00 2001 From: siemargl Date: Wed, 30 Nov 2016 22:15:12 +0000 Subject: [PATCH] final cp866 version git-svn-id: svn://kolibrios.org@6775 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/fs/unzip60/extract.c | 12 +- programs/fs/unzip60/fileio.c | 2 +- programs/fs/unzip60/kolibri/Makefile.gcc | 14 +- .../fs/unzip60/kolibri/Makefile.gcc.static | 2 +- programs/fs/unzip60/kolibri/config.h | 31 +- programs/fs/unzip60/kolibri/dirent.c | 31 +- programs/fs/unzip60/kolibri/kolibri.cbp | 326 +++++++++++++++++ programs/fs/unzip60/kolibri/kos32.c | 328 ++++++------------ programs/fs/unzip60/kolibri/kos32sys1.h | 5 +- 9 files changed, 515 insertions(+), 236 deletions(-) create mode 100644 programs/fs/unzip60/kolibri/kolibri.cbp diff --git a/programs/fs/unzip60/extract.c b/programs/fs/unzip60/extract.c index 1acd769d64..a52e8131d7 100644 --- a/programs/fs/unzip60/extract.c +++ b/programs/fs/unzip60/extract.c @@ -652,7 +652,9 @@ int extract_or_test_files(__G) /* return PK-type error code */ and GIDs from the deepest level on up. ---------------------------------------------------------------------------*/ -#ifdef SET_DIR_ATTRIB +#ifdef SET_DIR_ATTRIB +//Trace((stderr, "SET_DIR_ATTRIB[%d] \n", num_dirs)); hmm, too big number + if (num_dirs > 0) { sorted_dirlist = (direntry **)malloc(num_dirs*sizeof(direntry *)); if (sorted_dirlist == (direntry **)NULL) { @@ -1483,12 +1485,12 @@ startover: #else /* !WINDLL */ extent fnlen; reprompt: - Info(slide, 0x81, ((char *)slide, + Info(slide, 0x81 & 0xFE, ((char *)slide, LoadFarString(ReplaceQuery), FnFilter1(G.filename))); if (fgets(G.answerbuf, sizeof(G.answerbuf), stdin) == (char *)NULL) { - Info(slide, 1, ((char *)slide, + Info(slide, 1 & 0xFE, ((char *)slide, LoadFarString(AssumeNone))); *G.answerbuf = 'N'; if (!error_in_archive) @@ -1498,7 +1500,7 @@ reprompt: case 'r': case 'R': do { - Info(slide, 0x81, ((char *)slide, + Info(slide, 0x81 & 0xFE, ((char *)slide, LoadFarString(NewNameQuery))); fgets(G.filename, FILNAMSIZ, stdin); /* usually get \n here: better check for it */ @@ -1538,7 +1540,7 @@ reprompt: fnlen = strlen(G.answerbuf); if (lastchar(G.answerbuf, fnlen) == '\n') G.answerbuf[--fnlen] = '\0'; - Info(slide, 1, ((char *)slide, + Info(slide, 1 & 0xFE, ((char *)slide, LoadFarString(InvalidResponse), G.answerbuf)); goto reprompt; /* yet another goto? */ } /* end switch (*answerbuf) */ diff --git a/programs/fs/unzip60/fileio.c b/programs/fs/unzip60/fileio.c index fe2aad1dec..ece90c7863 100644 --- a/programs/fs/unzip60/fileio.c +++ b/programs/fs/unzip60/fileio.c @@ -1214,7 +1214,7 @@ static int disk_error(__G) __GDEF { /* OK to use slide[] here because this file is finished regardless */ - Info(slide, 0x4a1, ((char *)slide, LoadFarString(DiskFullQuery), + Info(slide, 0x4a1 & 0xFE, ((char *)slide, LoadFarString(DiskFullQuery), FnFilter1(G.filename))); #ifndef WINDLL diff --git a/programs/fs/unzip60/kolibri/Makefile.gcc b/programs/fs/unzip60/kolibri/Makefile.gcc index 4132de84a3..1e0785128f 100644 --- a/programs/fs/unzip60/kolibri/Makefile.gcc +++ b/programs/fs/unzip60/kolibri/Makefile.gcc @@ -18,10 +18,10 @@ # emulation environment. SDK_DIR:= $(abspath ../../../contrib/sdk) NOASM=1 -CC_CPU_OPT=-march=pentium +CC_CPU_OPT=-march=pentium #USEZLIB=1 -#DEBUG=1 - +DEBUG=1 + ### Optional section @@ -97,7 +97,7 @@ CC_ENVIR_OPT = -DWIN32 -DFORCE_WIN32_OVER_UNIX endif endif ### kolibri specific -INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include -I $(SDK_DIR)/sources/zlib +INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include -I $(SDK_DIR)/sources/zlib LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib CC_ENVIR_OPT = -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOS32 \ @@ -164,7 +164,7 @@ LD_SPECIFIC_OPT = -o $@ -static -S -nostdlib -T $(SDK_DIR)/sources/newlib/app-dy ifdef USEZLIB LD_RELEASE_LIBS = -lz -lgcc -ldll -lc.dll -lapp else -LD_RELEASE_LIBS = -lgcc -ldll -lc.dll -lapp +LD_RELEASE_LIBS = -lgcc -ldll -lc.dll endif LD_DEBUG_LIBS = $(LD_RELEASE_LIBS) @@ -260,7 +260,7 @@ OBJB4 = unreducb$(OBJ) unshrnkb$(OBJ) zipinfob$(OBJ) ###OBJBS = win32b$(OBJ) win32i64b$(OBJ) ntb$(OBJ) OBJB = $(OBJLIB) $(OBJB1) $(OBJB2) $(OBJB3) $(OBJB4) $(OBJA) $(OBJBS) -UNZIP_H = unzip.h unzpriv.h globals.h +UNZIP_H = unzip.h unzpriv.h globals.h ###win32/w32cfg.h ###WINDLL_H = windll/windll.h windll/structs.h windll/decs.h ###DLLDEF = windll/windllgcc.def @@ -335,7 +335,7 @@ zipinfo$(OBJ): zipinfo.c $(UNZIP_H) crc_i386$(OBJ): crc_i386.S -kos32$(OBJ): kolibri/kos32.c kolibri/kos32sys1.h +kos32$(OBJ): kolibri/kos32.c kolibri/kos32sys1.h $(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< dirent$(OBJ): kolibri/dirent.c kolibri/kos32sys1.h $(CC) $(CFLAGS) $(CVER) $(GENFLAGS) -I. $< diff --git a/programs/fs/unzip60/kolibri/Makefile.gcc.static b/programs/fs/unzip60/kolibri/Makefile.gcc.static index 435d415cfa..a477625e9a 100644 --- a/programs/fs/unzip60/kolibri/Makefile.gcc.static +++ b/programs/fs/unzip60/kolibri/Makefile.gcc.static @@ -103,7 +103,7 @@ INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include -I $(SDK_DIR)/sources/zlib LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib CC_ENVIR_OPT = -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOS32 \ - $(INCLUDES) -DSTATIC_LIBC -DBUILD_LIBC + $(INCLUDES) -DSTATIC_LIBC ### Compiler-specific section diff --git a/programs/fs/unzip60/kolibri/config.h b/programs/fs/unzip60/kolibri/config.h index a1b4685140..0390f428fa 100644 --- a/programs/fs/unzip60/kolibri/config.h +++ b/programs/fs/unzip60/kolibri/config.h @@ -18,15 +18,40 @@ Started by Siemargl @Nov 2016 #define STRNICMP zstrnicmp #define NO_CHMOD #define NO_FCHOWN +//#define SET_DIR_ATTRIB internal unzip bug #define echoff(f) #define echon() #define getch() getchar() /* not correct, but may not be on a console */ #define HAVE_WORKING_GETCH -#define UNICODE_SUPPORT -#define UTF8_MAYBE_NATIVE -#define NO_NL_LANGINFO +/* next line turn on full unicode utf-8 support */ +//#define UNICODE_SUPPORT +#ifdef UNICODE_SUPPORT +# define UTF8_MAYBE_NATIVE +# define NO_NL_LANGINFO +#else /* cp866 is native */ +# define CRTL_CP_IS_OEM +#endif // UNICODE_SUPPORT + +/* +# ifdef CRTL_CP_IS_OEM +# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst) +# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));} +# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst) +# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));} +# endif +# define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1) +# define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1) +*/ +/* UzpPassword supplies ANSI-coded string regardless of C RTL's native CP */ +// remove for a while +// # define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst) + /* dummy defines to disable these functions, they are not needed */ +# define STR_TO_ISO +# define STR_TO_OEM + + /* # ifdef DATE_FORMAT # undef DATE_FORMAT diff --git a/programs/fs/unzip60/kolibri/dirent.c b/programs/fs/unzip60/kolibri/dirent.c index 2287100f9c..772b5f60ee 100644 --- a/programs/fs/unzip60/kolibri/dirent.c +++ b/programs/fs/unzip60/kolibri/dirent.c @@ -3,7 +3,7 @@ Kolibri OS port for gcc 5.4 Started by Siemargl @Nov 2016 -Contains realisation of directory handling functions: +Contains realization of directory handling functions: mkdir() closedir() opendir() @@ -20,6 +20,7 @@ Contains realisation of directory handling functions: #include #include #include "kos32sys1.h" +#include "sys/kos_io.h" /* defined in newlib headers int _EXFUN(mkdir,( const char *_path, mode_t __mode )); @@ -147,7 +148,7 @@ int mkdir(const char *_path, mode_t m) char namebuffer[1050]; // need for save data after di!!! struct fs_dirinfo *di = (struct fs_dirinfo *)namebuffer; -debug_board_printf("mkdir start (%s)\n", _path); +//debug_board_printf("mkdir start (%s)\n", _path); memset(di, 0, sizeof(struct fs_dirinfo)); //di.ppath = (char*)_path; // dont work with 70.9 strcpy(di->path, _path); @@ -159,7 +160,7 @@ debug_board_printf("mkdir start (%s)\n", _path); return -1; } -debug_board_printf("mkdir end (%s)\n", _path); +//debug_board_printf("mkdir end (%s)\n", _path); return 0; } @@ -230,3 +231,27 @@ void* read_folderdata(char* name) return retdir; } */ + +// while not in newlib +int set_fileinfo(const char *path, fileinfo_t *info) +{ + int retval; + + __asm__ __volatile__ ( + "pushl $0 \n\t" + "pushl $0 \n\t" + "movl %1, 1(%%esp) \n\t" + "pushl %%ebx \n\t" + "pushl $0 \n\t" + "pushl $0 \n\t" + "pushl $0 \n\t" + "pushl $6 \n\t" + "movl %%esp, %%ebx \n\t" + "movl $70, %%eax \n\t" + "int $0x40 \n\t" + "addl $28, %%esp \n\t" + :"=a" (retval) + :"r" (path), "b" (info)); + return retval; +}; + diff --git a/programs/fs/unzip60/kolibri/kolibri.cbp b/programs/fs/unzip60/kolibri/kolibri.cbp new file mode 100644 index 0000000000..a508530a90 --- /dev/null +++ b/programs/fs/unzip60/kolibri/kolibri.cbp @@ -0,0 +1,326 @@ + + + + + + diff --git a/programs/fs/unzip60/kolibri/kos32.c b/programs/fs/unzip60/kolibri/kos32.c index 18a6cdf8b4..a6c4656994 100644 --- a/programs/fs/unzip60/kolibri/kos32.c +++ b/programs/fs/unzip60/kolibri/kos32.c @@ -16,16 +16,14 @@ Contains: close_outfile() get_extattribs() do_wild() + set_direc_attribs() + defer_dir_attribs() todo - russian filenames in arh - datetime restore - overwrite request not in stderr - - too many open files error EMFILE when DEBUG - error in newlib open. fixed - -d dir error. Use -ddir or -d dir/ - - release, sizing removing old compression methods or zlib + datetime restore for dirs. buf in unzip - crash when SET_DIR_ATTRIB +fixed partial + -d dir error (only in unicode). Use -ddir or -d dir/ + russian filenames in arhives. Now works cp866 version, unicode need to fix @kos32.c:470 (GETPATH) */ #define FATTR FS_HIDDEN+FS_SYSTEM+FS_SUBDIR @@ -37,6 +35,12 @@ todo // Siemargl fork of Kolibri system API #include "kos32sys1.h" + +static ZCONST char CannotSetItemTimestamps[] = + "warning: cannot set modif./access times for %s\n %s\n"; +static ZCONST char CannotGetTimestamps[] = + " (warning) cannot get fileinfo for %s\n"; + /********************************************************************************************************************/ /*** Function version() */ @@ -154,7 +158,7 @@ int mapname(__G__ renamed) else ++cp; /* point to start of last component of path */ -fprintf(stderr, "mapname start[%s]\n", cp); + Trace((stderr, "mapname start[%s]\n", cp)); /*--------------------------------------------------------------------------- Begin main loop through characters in filename. @@ -323,7 +327,7 @@ fprintf(stderr, "mapname start[%s]\n", cp); checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */ checkdir(__G__ G.filename, GETPATH); -fprintf(stderr, "mapname end[%s]\n", pathcomp); + Trace((stderr, "mapname end[%s]\n", pathcomp)); return error; @@ -465,14 +469,24 @@ int checkdir(__G__ pathcomp, flag) GETPATH: copy full path to the string pointed at by pathcomp, and free G.buildpath. ---------------------------------------------------------------------------*/ - if (FUNCTION == GETPATH) { +// kolibri UTf8 support +#ifdef UNICODE_SUPPORT if(G.native_is_utf8) { - pathcomp[0] = 3; // kolibri utf8 flag - strcpy(pathcomp + 1, G.buildpath); + if (G.buildpath[0] == '/') + { + pathcomp[0] = '/'; // kolibri utf8 flag + pathcomp[1] = 3; // kolibri utf8 flag + strcpy(pathcomp + 2, G.buildpath); + } else + { + pathcomp[0] = 3; // kolibri utf8 flag + strcpy(pathcomp + 1, G.buildpath); + } } - else + else +#endif // UNICODE_SUPPORT strcpy(pathcomp, G.buildpath); Trace((stderr, "getting and freeing path [%s]\n", FnFilter1(pathcomp))); @@ -622,59 +636,24 @@ int checkdir(__G__ pathcomp, flag) } /* end function checkdir() */ -static int get_extattribs OF((__GPRO__ iztimes *pzt, ulg z_uidgid[2])); - -static int get_extattribs(__G__ pzt, z_uidgid) - __GDEF - iztimes *pzt; - ulg z_uidgid[2]; -{ -/*--------------------------------------------------------------------------- - Convert from MSDOS-format local time and date to Unix-format 32-bit GMT - time: adjust base year from 1980 to 1970, do usual conversions from - yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day- - light savings time differences. If we have a Unix extra field, however, - we're laughing: both mtime and atime are ours. On the other hand, we - then have to check for restoration of UID/GID. - ---------------------------------------------------------------------------*/ - int have_uidgid_flg; - unsigned eb_izux_flg; - - eb_izux_flg = 0; // kos32 -/* - (G.extra_field ? ef_scan_for_izux(G.extra_field, - G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime, -#ifdef IZ_CHECK_TZ - (G.tz_is_valid ? pzt : NULL), -#else - pzt, -#endif - z_uidgid) : 0); -*/ - if (eb_izux_flg & EB_UT_FL_MTIME) { - TTrace((stderr, "\nget_extattribs: Unix e.f. modif. time = %ld\n", - pzt->mtime)); - } else { - pzt->mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime); - } - if (eb_izux_flg & EB_UT_FL_ATIME) { - TTrace((stderr, "get_extattribs: Unix e.f. access time = %ld\n", - pzt->atime)); - } else { - pzt->atime = pzt->mtime; - TTrace((stderr, "\nget_extattribs: modification/access times = %ld\n", - pzt->mtime)); - } - - /* if -X option was specified and we have UID/GID info, restore it */ - have_uidgid_flg = -#ifdef RESTORE_UIDGID - (uO.X_flag && (eb_izux_flg & EB_UX2_VALID)); -#else - 0; -#endif - return have_uidgid_flg; -} + +/****************************/ +/* Function dos_to_kolibri_time() */ +/****************************/ +void dos_to_kolibri_time(unsigned dos_datetime, unsigned *fdat, unsigned *ftim) +{ + char* pc = (char*)fdat; + *pc++ = (dos_datetime >> 16) & 0x1F; // day + *pc++ = (dos_datetime >> 21) & 0xF; // month + short *ps = (short*)pc; + *ps = (dos_datetime >> 25) + 1980; // year + *ftim = 0; + pc = (char*)ftim; + *pc++ = (dos_datetime & 0x1F) << 1; // sec + *pc++ = (dos_datetime >> 5) & 0x3F; // min + *pc = (dos_datetime >> 11) & 0x1F; // hour +} /* end function dos_to_kolibri_time() */ + /****************************/ /* Function close_outfile() */ @@ -683,160 +662,37 @@ static int get_extattribs(__G__ pzt, z_uidgid) void close_outfile(__G) /* GRR: change to return PK-style warning level */ __GDEF { - union { - iztimes t3; /* mtime, atime, ctime */ - ztimbuf t2; /* modtime, actime */ - } zt; - ulg z_uidgid[2]; - int have_uidgid_flg; - - have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid); - -/*--------------------------------------------------------------------------- - If symbolic links are supported, allocate storage for a symlink control - structure, put the uncompressed "data" and other required info in it, and - add the structure to the "deferred symlinks" chain. Since we know it's a - symbolic link to start with, we shouldn't have to worry about overflowing - unsigned ints with unsigned longs. - ---------------------------------------------------------------------------*/ - -#ifdef SYMLINKS - if (G.symlnk) { - extent ucsize = (extent)G.lrec.ucsize; -# ifdef SET_SYMLINK_ATTRIBS - extent attribsize = sizeof(unsigned) + - (have_uidgid_flg ? sizeof(z_uidgid) : 0); -# else - extent attribsize = 0; -# endif - /* size of the symlink entry is the sum of - * (struct size (includes 1st '\0') + 1 additional trailing '\0'), - * system specific attribute data size (might be 0), - * and the lengths of name and link target. - */ - extent slnk_entrysize = (sizeof(slinkentry) + 1) + attribsize + - ucsize + strlen(G.filename); - slinkentry *slnk_entry; - - if (slnk_entrysize < ucsize) { - Info(slide, 0x201, ((char *)slide, - "warning: symbolic link (%s) failed: mem alloc overflow\n", - FnFilter1(G.filename))); - fclose(G.outfile); - return; - } - - if ((slnk_entry = (slinkentry *)malloc(slnk_entrysize)) == NULL) { - Info(slide, 0x201, ((char *)slide, - "warning: symbolic link (%s) failed: no mem\n", - FnFilter1(G.filename))); - fclose(G.outfile); - return; - } - slnk_entry->next = NULL; - slnk_entry->targetlen = ucsize; - slnk_entry->attriblen = attribsize; -# ifdef SET_SYMLINK_ATTRIBS - memcpy(slnk_entry->buf, &(G.pInfo->file_attr), - sizeof(unsigned)); - if (have_uidgid_flg) - memcpy(slnk_entry->buf + 4, z_uidgid, sizeof(z_uidgid)); -# endif - slnk_entry->target = slnk_entry->buf + slnk_entry->attriblen; - slnk_entry->fname = slnk_entry->target + ucsize + 1; - strcpy(slnk_entry->fname, G.filename); - - /* move back to the start of the file to re-read the "link data" */ - rewind(G.outfile); - - if (fread(slnk_entry->target, 1, ucsize, G.outfile) != ucsize) - { - Info(slide, 0x201, ((char *)slide, - "warning: symbolic link (%s) failed\n", - FnFilter1(G.filename))); - free(slnk_entry); - fclose(G.outfile); - return; - } - fclose(G.outfile); /* close "link" file for good... */ - slnk_entry->target[ucsize] = '\0'; - if (QCOND2) - Info(slide, 0, ((char *)slide, "-> %s ", - FnFilter1(slnk_entry->target))); - /* add this symlink record to the list of deferred symlinks */ - if (G.slink_last != NULL) - G.slink_last->next = slnk_entry; - else - G.slink_head = slnk_entry; - G.slink_last = slnk_entry; - return; - } -#endif /* SYMLINKS */ - -#ifdef QLZIP - if (G.extra_field) { - static void qlfix OF((__GPRO__ uch *ef_ptr, unsigned ef_len)); - - qlfix(__G__ G.extra_field, G.lrec.extra_field_length); - } -#endif #if (defined(NO_FCHOWN)) fclose(G.outfile); Trace((stdout, "File (%s) closed\n", FnFilter1(G.filename))); #endif -// kos. add set file datetime ? -#ifndef KOS32 - /* if -X option was specified and we have UID/GID info, restore it */ - if (have_uidgid_flg - /* check that both uid and gid values fit into their data sizes */ - && ((ulg)(uid_t)(z_uidgid[0]) == z_uidgid[0]) - && ((ulg)(gid_t)(z_uidgid[1]) == z_uidgid[1])) { - TTrace((stderr, "close_outfile: restoring Unix UID/GID info\n")); -#if (defined(NO_FCHOWN)) - if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1])) -#else - if (fchown(fileno(G.outfile), (uid_t)z_uidgid[0], (gid_t)z_uidgid[1])) -#endif - { - if (uO.qflag) - Info(slide, 0x201, ((char *)slide, CannotSetItemUidGid, - z_uidgid[0], z_uidgid[1], FnFilter1(G.filename), - strerror(errno))); - else - Info(slide, 0x201, ((char *)slide, CannotSetUidGid, - z_uidgid[0], z_uidgid[1], strerror(errno))); - } - } - -#if (!defined(NO_FCHOWN) && defined(NO_FCHMOD)) - fclose(G.outfile); -#endif - -#if (!defined(NO_FCHOWN) && !defined(NO_FCHMOD)) -/*--------------------------------------------------------------------------- - Change the file permissions from default ones to those stored in the - zipfile. - ---------------------------------------------------------------------------*/ - - if (fchmod(fileno(G.outfile), filtattr(__G__ G.pInfo->file_attr))) - perror("fchmod (file attributes) error"); - - fclose(G.outfile); -#endif /* !NO_FCHOWN && !NO_FCHMOD */ - /* skip restoring time stamps on user's request */ if (uO.D_flag <= 1) { - /* set the file's access and modification times */ - if (utime(G.filename, &(zt.t2))) { - if (uO.qflag) - Info(slide, 0x201, ((char *)slide, CannotSetItemTimestamps, - FnFilter1(G.filename), strerror(errno))); - else - Info(slide, 0x201, ((char *)slide, CannotSetTimestamps, - strerror(errno))); - } + /* set the file's access and modification times */ + /* siemargl: dont using extra fields */ + unsigned ftim, fdat; + dos_to_kolibri_time(G.lrec.last_mod_dos_datetime, &fdat, &ftim); + + fileinfo_t finfo; + if (get_fileinfo(G.filename, &finfo)) + { + Info(slide, 1, ((char *)slide, CannotGetTimestamps, + FnFilter1(G.filename))); + return; + } + finfo.flags = G.pInfo->file_attr; + finfo.cr_time = finfo.acc_time = finfo.mod_time = ftim; + finfo.cr_date = finfo.acc_date = finfo.mod_date = fdat; + Trace((stderr, "Trying to set fileinfo[%s] date %X, time %X, attr %X\n", FnFilter1(G.filename), fdat, ftim, finfo.flags)); + + if (set_fileinfo(G.filename, &finfo)) + { + Info(slide, 1, ((char *)slide, CannotSetItemTimestamps, + FnFilter1(G.filename), strerror(errno))); + return; + } } #if (defined(NO_FCHOWN) || defined(NO_FCHMOD)) @@ -851,7 +707,6 @@ void close_outfile(__G) /* GRR: change to return PK-style warning level */ #endif #endif /* NO_FCHOWN || NO_FCHMOD */ -#endif // 0 } /* end function close_outfile() */ @@ -977,4 +832,49 @@ char *do_wild(__G__ wildspec) return (char *)NULL; } /* end function do_wild() */ + +#ifdef SET_DIR_ATTRIB +int defer_dir_attribs(__G__ pd) + __GDEF + direntry **pd; +{ + // do nothing + return PK_OK; +} + +int set_direc_attribs(__G__ d) + __GDEF + direntry *d; +{ + /* skip restoring time stamps on user's request */ + if (uO.D_flag <= 0) { + /* set the file's access and modification times */ + /* siemargl: dont using extra fields */ + unsigned ftim, fdat; + dos_to_kolibri_time(G.lrec.last_mod_dos_datetime, &fdat, &ftim); + + fileinfo_t finfo; + if (get_fileinfo(G.filename, &finfo)) + { + Info(slide, 1, ((char *)slide, CannotGetTimestamps, + FnFilter1(G.filename))); + return PK_WARN; + } + finfo.flags = G.pInfo->file_attr; + finfo.cr_time = finfo.acc_time = finfo.mod_time = ftim; + finfo.cr_date = finfo.acc_date = finfo.mod_date = fdat; + Trace((stderr, "Trying to set dirinfo[%s] date %X, time %X, attr %X\n", FnFilter1(G.filename), fdat, ftim, finfo.flags)); + + if (set_fileinfo(G.filename, &finfo)) + { + Info(slide, 1, ((char *)slide, CannotSetItemTimestamps, + FnFilter1(G.filename), strerror(errno))); + return PK_WARN; + } + } + + return PK_OK; +} /* end function set_direc_attribs() */ + +#endif // SET_DIR_ATTRIB diff --git a/programs/fs/unzip60/kolibri/kos32sys1.h b/programs/fs/unzip60/kolibri/kos32sys1.h index a2f03ef2b7..e99ad3f91c 100644 --- a/programs/fs/unzip60/kolibri/kos32sys1.h +++ b/programs/fs/unzip60/kolibri/kos32sys1.h @@ -8,6 +8,7 @@ //#include //#include +//#include #include #include typedef unsigned int uint32_t; @@ -141,7 +142,7 @@ typedef struct __attribute__((packed)) file_op_t char* args; uint32_t res1, res2; char zero; - char* app_name + char* app_name #ifdef __TINYC__ __attribute__((packed)) #endif @@ -862,7 +863,7 @@ static inline int font_size(int color) /// decode font size in pixels from color as SysFn4 /// returns (width, hight) -{ +{ int font = color >> 24; int font_multipl = (font & 7) + 1; int width_sym, hight_sym;