Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/acorn/acorn.c view on Meta::CPAN
} else {
printf(" Filetype: &%.3X\n",(block->loadaddr & 0x000FFF00) >> 8);
}
}
printf(" Access: ");
if (block->attr & (1<<3))
printf("L");
if (block->attr & (1<<0))
printf("W");
if (block->attr & (1<<1))
printf("R");
printf("/");
if (block->attr & (1<<4))
printf("w");
if (block->attr & (1<<5))
printf("r");
printf("\n\n");
}
#endif /* DEBUG */
/**********************************************/
/* internal help function for time conversion */
/**********************************************/
static int uxtime2acornftime(unsigned *pexadr, unsigned *pldadr, time_t ut)
{
unsigned timlo; /* 3 lower bytes of acorn file-time plus carry byte */
unsigned timhi; /* 2 high bytes of acorn file-time */
timlo = ((unsigned)ut & 0x00ffffffU) * 100 + 0x00996a00U;
timhi = ((unsigned)ut >> 24);
timhi = timhi * 100 + 0x0000336eU + (timlo >> 24);
if (timhi & 0xffff0000U)
return 1; /* calculation overflow, do not change time */
/* insert the five time bytes into loadaddr and execaddr variables */
*pexadr = (timlo & 0x00ffffffU) | ((timhi & 0x000000ffU) << 24);
*pldadr = (*pldadr & 0xffffff00U) | ((timhi >> 8) & 0x000000ffU);
return 0; /* subject to future extension to signal overflow */
}
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G)
__GDEF
{
zvoid *spark_ef;
fclose(G.outfile);
if ((spark_ef = getRISCOSexfield(G.extra_field, G.lrec.extra_field_length))
!= NULL) {
setRISCOSexfield(G.filename, spark_ef);
} else {
unsigned int loadaddr, execaddr;
int attr;
int mode=G.pInfo->file_attr&0xffff; /* chmod equivalent mode */
time_t m_time;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
#endif
/* 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
#endif /* USE_EF_UT_TIME */
m_time = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
/* set the file's time-stamp and attributes */
SWI_OS_File_5(G.filename, NULL, &loadaddr, NULL, NULL, &attr);
if (uO.D_flag <= 1)
/* set the file's modification time */
uxtime2acornftime(&execaddr, &loadaddr, m_time);
loadaddr = (loadaddr & 0xfff000ffU) |
((G.pInfo->file_attr&0xfff00000) >> 12);
attr=(attr&0xffffff00) | ((mode&0400) >> 8) | ((mode&0200) >> 6) |
((mode&0004) << 2) | ((mode&0002) << 4);
SWI_OS_File_1(G.filename, loadaddr, execaddr, attr);
}
} /* end function close_outfile() */
#ifdef TIMESTAMP
/***************************/
/* Function stamp_file() */
/***************************/
int stamp_file(fname, modtime)
ZCONST char *fname;
time_t modtime;
{
unsigned int loadaddr, execaddr;
int attr;
/* set the file's modification time */
( run in 1.614 second using v1.01-cache-2.11-cpan-54e63673c56 )