Archive-Unzip-Burst

 view release on metacpan or  search on metacpan

unzip-6.0/amiga/amiga.c  view on Meta::CPAN




/**************************************/
/* Function close_outfile() */
/**************************************/
/* this part differs slightly with Zip */
/*-------------------------------------*/

void close_outfile(__G)
    __GDEF
{
    time_t m_time;
#ifdef USE_EF_UT_TIME
    iztimes z_utime;
#endif
    LONG FileDate();

    if (uO.cflag)               /* can't set time or filenote on stdout */
        return;

  /* close the file *before* setting its time under AmigaDOS */

    fclose(G.outfile);

    /* skip restoring time stamps on user's request */
    if (uO.D_flag <= 1) {
#ifdef USE_EF_UT_TIME
        if (G.extra_field &&
#ifdef IZ_CHECK_TZ
            G.tz_is_valid &&
#endif
            (ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
                              G.lrec.last_mod_dos_datetime, &z_utime, NULL)
             & EB_UT_FL_MTIME))
        {
            TTrace((stderr, "close_outfile:  Unix e.f. modif. time = %ld\n",
                             z_utime.mtime));
            m_time = z_utime.mtime;
        } else {
            /* Convert DOS time to time_t format */
            m_time = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
        }
#else /* !USE_EF_UT_TIME */
        /* Convert DOS time to time_t format */
        m_time = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
#endif /* ?USE_EF_UT_TIME */

#ifdef DEBUG
        Info(slide, 1, ((char *)slide, "\nclose_outfile(): m_time=%s\n",
             ctime(&m_time)));
#endif

        if (!FileDate(G.filename, &m_time))
            Info(slide, 1, ((char *)slide,
                 "warning:  cannot set the time for %s\n", G.filename));
    }

    /* set file perms after closing (not done at creation)--see mapattr() */

    chmod(G.filename, G.pInfo->file_attr);

    /* give it a filenote from the zipfile comment, if appropriate */

    if (uO.N_flag && G.filenotes[G.filenote_slot]) {
        SetComment(G.filename, G.filenotes[G.filenote_slot]);
        free(G.filenotes[G.filenote_slot]);
        G.filenotes[G.filenote_slot] = NULL;
    }

} /* end function close_outfile() */


#ifdef TIMESTAMP

/*************************/
/* Function stamp_file() */
/*************************/

int stamp_file(fname, modtime)
    ZCONST char *fname;
    time_t modtime;
{
    time_t m_time;
    LONG FileDate();

    m_time = modtime;
    return (FileDate((char *)fname, &m_time));

} /* end function stamp_file() */

#endif /* TIMESTAMP */


#ifndef __SASC
/********************************************************************/
/* Load filedate as a separate external file; it's used by Zip, too.*/
/*                                                                  */
#  include "amiga/filedate.c"                                    /* */
/*                                                                  */
/********************************************************************/

/********************* do linewise with stat.c **********************/

#  include "amiga/stat.c"
/* this is the exact same stat.c used by Zip */
#endif /* !__SASC */
/* SAS/C makes separate object modules of these; there is less  */
/* trouble that way when redefining standard library functions. */

#include <stdio.h>

void _abort(void)               /* called when ^C is pressed */
{
    /* echon(); */
    close_leftover_open_dirs();
    fflush(stdout);
    fputs("\n^C\n", stderr);
    exit(1);
}



( run in 1.003 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )