Subversion Repositories SvarDOS

Rev

Rev 1963 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1963 Rev 1965
Line 9... Line 9...
9
#include <stdlib.h>    /* free() */
9
#include <stdlib.h>    /* free() */
10
#include <unistd.h>    /* rmdir(), unlink() */
10
#include <unistd.h>    /* rmdir(), unlink() */
11
#include <direct.h>  /* watcom needs this for the rmdir() prototype */
11
#include <direct.h>  /* watcom needs this for the rmdir() prototype */
12
 
12
 
13
#include "helpers.h"   /* slash2backslash() */
13
#include "helpers.h"   /* slash2backslash() */
14
#include "kprintf.h"
14
#include "svarlang.lib\svarlang.h"
15
 
15
 
16
#include "pkgrem.h"
16
#include "pkgrem.h"
17
 
17
 
18
 
18
 
19
struct dirliststruct {
19
struct dirliststruct {
Line 30... Line 30...
30
    if (strcasecmp(res->dirname, path) == 0) return(dirlist);
30
    if (strcasecmp(res->dirname, path) == 0) return(dirlist);
31
  }
31
  }
32
  /* not in the list yet - add it */
32
  /* not in the list yet - add it */
33
  res = malloc(sizeof(struct dirliststruct) + strlen(path));
33
  res = malloc(sizeof(struct dirliststruct) + strlen(path));
34
  if (res == NULL) {  /* out of memory */
34
  if (res == NULL) {  /* out of memory */
35
    kitten_printf(4, 3, path); /* "Out of memory! Could not store directory %s!" */
35
    outputnl(svarlang_str(2,14)); /* "Out of memory!" */
36
    outputnl("");
-
 
37
    return(NULL);
36
    return(NULL);
38
  }
37
  }
39
  strcpy(res->dirname, path);
38
  strcpy(res->dirname, path);
40
  res->next = dirlist;
39
  res->next = dirlist;
41
  return(res);
40
  return(res);
Line 76... Line 75...
76
  flist = fopen(fpath, "rb");
75
  flist = fopen(fpath, "rb");
77
  if (flist == NULL) {
76
  if (flist == NULL) {
78
    sprintf(fpath, "%s\\appinfo\\%s.lsm", dosdir, pkgname);
77
    sprintf(fpath, "%s\\appinfo\\%s.lsm", dosdir, pkgname);
79
    flist = fopen(fpath, "rb");
78
    flist = fopen(fpath, "rb");
80
    if (flist == NULL) {
79
    if (flist == NULL) {
81
      kitten_printf(4, 0, pkgname); /* "Package %s is not installed, so not removed." */
80
      /* "Package %s is not installed, so not removed" */
-
 
81
      sprintf(buff, svarlang_str(4,0), pkgname);
82
      outputnl("");
82
      outputnl(buff);
83
      return(-1);
83
      return(-1);
84
    }
84
    }
85
  }
85
  }
86
 
86
 
87
  /* remove all files/folders listed in pkgname.lsm but NOT pkgname.lsm */
87
  /* remove all files/folders listed in pkgname.lsm but NOT pkgname.lsm */
Line 117... Line 117...
117
    /* do not delete pkgname.lst at this point because I am using it (will be
117
    /* do not delete pkgname.lst at this point because I am using it (will be
118
     * deleted later) */
118
     * deleted later) */
119
    if (strcasecmp(buff, fpath) == 0) continue;
119
    if (strcasecmp(buff, fpath) == 0) continue;
120
 
120
 
121
    /* remove it */
121
    /* remove it */
122
    kitten_printf(4, 4, buff); /* "removing %s" */
122
    output(svarlang_str(4,4)); /* removing */
123
    outputnl("");
123
    output(" ");
-
 
124
    outputnl(buff);
124
    unlink(buff);
125
    unlink(buff);
125
  }
126
  }
126
 
127
 
127
  /* close the lsm file */
128
  /* close the lsm file */
128
  fclose(flist);
129
  fclose(flist);
Line 149... Line 150...
149
    dirlist = dirlistpos->next;
150
    dirlist = dirlistpos->next;
150
    free(dirlistpos);
151
    free(dirlistpos);
151
  }
152
  }
152
 
153
 
153
  /* remove the lst file */
154
  /* remove the lst file */
154
  kitten_printf(4, 4, fpath); /* "removing %s" */
155
  output(svarlang_str(4,4)); /* "removing" */
155
  outputnl("");
156
  output(" ");
-
 
157
  outputnl(fpath);
156
  unlink(fpath);
158
  unlink(fpath);
157
 
159
 
158
  kitten_printf(4, 5, pkgname); /* "Package %s has been removed." */
160
  sprintf(buff, svarlang_str(4,5), pkgname); /* "Package %s has been removed." */
159
  outputnl("");
161
  outputnl(buff);
160
  return(0);
162
  return(0);
161
}
163
}