~peter-pearse/ubuntu/natty/zip/prop001

« back to all changes in this revision

Viewing changes to win32/win32zip.c

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2005-03-23 20:12:12 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050323201212-jzsk2g6kn8v49mwp
Tags: 2.31-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  Copyright (c) 1990-1999 Info-ZIP.  All rights reserved.
 
2
  Copyright (c) 1990-2005 Info-ZIP.  All rights reserved.
3
3
 
4
 
  See the accompanying file LICENSE, version 1999-Oct-05 or later
 
4
  See the accompanying file LICENSE, version 2004-May-22 or later
5
5
  (the contents of which are also included in zip.h) for terms of use.
6
6
  If, for some reason, both of these files are missing, the Info-ZIP license
7
 
  also may be found at:  ftp://ftp.cdrom.com/pub/infozip/license.html
 
7
  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
8
8
*/
9
9
#ifndef UTIL    /* this file contains nothing used by UTIL */
10
10
 
522
522
   a file size of -1 */
523
523
{
524
524
  struct stat s;        /* results of stat() */
525
 
  char name[FNMAX];
526
 
  int len = strlen(f), isstdin = !strcmp(f, "-");
 
525
  char *name;
 
526
  unsigned int len = strlen(f);
 
527
  int isstdin = !strcmp(f, "-");
527
528
 
528
529
  if (f == label) {
529
530
    if (a != NULL)
534
535
      t->atime = t->mtime = t->ctime = label_utim;
535
536
    return label_time;
536
537
  }
 
538
 
 
539
  if ((name = malloc(len + 1)) == NULL) {
 
540
    ZIPERR(ZE_MEM, "filetime");
 
541
  }
537
542
  strcpy(name, f);
538
543
  if (MBSRCHR(name, '/') == (name + len - 1))
539
544
    name[len - 1] = '\0';
540
545
  /* not all systems allow stat'ing a file with / appended */
541
546
 
542
547
  if (isstdin) {
543
 
    if (fstat(fileno(stdin), &s) != 0)
 
548
    if (fstat(fileno(stdin), &s) != 0) {
 
549
      free(name);
544
550
      error("fstat(stdin)");
 
551
    }
545
552
    time((time_t *)&s.st_mtime);       /* some fstat()s return time zero */
546
 
  } else if (LSSTAT(name, &s) != 0)
 
553
  } else if (LSSTAT(name, &s) != 0) {
547
554
             /* Accept about any file kind including directories
548
555
              * (stored with trailing / with -r option)
549
556
              */
 
557
    free(name);
550
558
    return 0;
 
559
  }
551
560
 
552
561
  if (a != NULL) {
553
562
    *a = ((ulg)s.st_mode << 16) | (isstdin ? 0L : (ulg)GetFileMode(name));
560
569
    t->ctime = s.st_ctime;
561
570
  }
562
571
 
 
572
  free(name);
 
573
 
563
574
  return unix2dostime((time_t *)&s.st_mtime);
564
575
}
565
576
 
608
619
  }
609
620
 
610
621
  /* # bytes to compress: compress type, CRC, data bytes */
611
 
  cbytes = sizeof(USHORT) + sizeof(ULONG) + bytes;
 
622
  cbytes = (2 + 4 + EB_DEFLAT_EXTRA) + bytes;
612
623
 
613
624
 
614
625
  /* our two possible failure points.  don't allow trashing of any data