Subversion Repositories SvarDOS

Rev

Rev 1682 | Rev 1889 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1682 Rev 1880
Line 94... Line 94...
94
}
94
}
95
 
95
 
96
 
96
 
97
static int pkginst(const char *file, int flags, const char *dosdir, const struct customdirs *dirlist) {
97
static int pkginst(const char *file, int flags, const char *dosdir, const struct customdirs *dirlist) {
98
  char pkgname[9];
98
  char pkgname[9];
99
  int t, lastpathdelim = -1, lastdot = -1, res = 1;
99
  int res = 1;
100
  struct ziplist *zipfileidx;
100
  struct ziplist *zipfileidx;
101
  FILE *zipfilefd;
101
  FILE *zipfilefd;
102
  /* copy the filename into pkgname (without path elements and without extension) */
-
 
103
  for (t = 0; file[t] != 0; t++) {
-
 
104
    switch (file[t]) {
-
 
105
      case '/':
-
 
106
      case '\\':
-
 
107
        lastpathdelim = t;
-
 
108
        break;
-
 
109
      case '.':
-
 
110
        lastdot = t;
-
 
111
        break;
-
 
112
    }
-
 
113
  }
102
 
114
  if (lastdot <= lastpathdelim) lastdot = t; /* a dot before last path delimiters is not an extension prefix */
-
 
115
  t = lastdot - (lastpathdelim + 1);
-
 
116
  if (t + 1 > sizeof(pkgname)) {
-
 
117
    puts(svarlang_str(3, 24)); /* "ERROR: package name too long" */
-
 
118
    return(1);
-
 
119
  }
-
 
120
  memcpy(pkgname, file + lastpathdelim + 1, t);
-
 
121
  pkgname[t] = 0;
-
 
122
  strlwr(pkgname); /* package name must be all lower-case for further file matching in the zip file */
-
 
123
  /* prepare the zip file and install it */
103
  /* prepare the zip file for installation and fetch package's name */
124
  zipfileidx = pkginstall_preparepackage(pkgname, file, flags, &zipfilefd, dosdir, dirlist);
104
  zipfileidx = pkginstall_preparepackage(pkgname, file, flags, &zipfilefd, dosdir, dirlist);
125
  if (zipfileidx != NULL) {
105
  if (zipfileidx != NULL) {
-
 
106
 
-
 
107
    /* package name must be all lower-case for further file matching in the zip file */
-
 
108
    strlwr(pkgname);
-
 
109
 
126
    /* remove the old version of the package if we are UPDATING it */
110
    /* remove the old version of the package if we are UPDATING it */
127
    res = 0;
111
    res = 0;
128
    if (flags & PKGINST_UPDATE) res = pkgrem(pkgname, dosdir);
112
    if (flags & PKGINST_UPDATE) res = pkgrem(pkgname, dosdir);
-
 
113
 
129
    if (res == 0) res = pkginstall_installpackage(pkgname, dosdir, dirlist, zipfileidx, zipfilefd);
114
    if (res == 0) res = pkginstall_installpackage(pkgname, dosdir, dirlist, zipfileidx, zipfilefd);
130
    zip_freelist(&zipfileidx);
115
    zip_freelist(&zipfileidx);
131
  }
116
  }
132
 
117
 
133
  fclose(zipfilefd);
118
  fclose(zipfilefd);