Subversion Repositories SvarDOS

Rev

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

Rev 269 Rev 613
Line 1... Line 1...
1
/*
1
/*
2
 * This file is part of the pkg (SvarDOS) project.
2
 * This file is part of the pkg (SvarDOS) project.
3
 * Copyright (C) Mateusz Viste 2012-2021
3
 * Copyright (C) Mateusz Viste 2012-2022
4
 */
4
 */
5
 
5
 
6
#include <ctype.h>    /* toupper() */
6
#include <ctype.h>    /* toupper() */
7
#include <stdio.h>
7
#include <stdio.h>
8
#include <string.h>    /* strlen() */
8
#include <string.h>    /* strlen() */
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, "Out of memory! Could not store directory %s!", path);
35
    kitten_printf(4, 3, path); /* "Out of memory! Could not store directory %s!" */
36
    puts("");
36
    puts("");
37
    return(NULL);
37
    return(NULL);
38
  }
38
  }
39
  strcpy(res->dirname, path);
39
  strcpy(res->dirname, path);
40
  res->next = dirlist;
40
  res->next = dirlist;
Line 72... Line 72...
72
 
72
 
73
  /* open the file %DOSDIR%\packages\pkgname.lst */
73
  /* open the file %DOSDIR%\packages\pkgname.lst */
74
  sprintf(fpath, "%s\\packages\\%s.lst", dosdir, pkgname);
74
  sprintf(fpath, "%s\\packages\\%s.lst", dosdir, pkgname);
75
  flist = fopen(fpath, "rb");
75
  flist = fopen(fpath, "rb");
76
  if (flist == NULL) {
76
  if (flist == NULL) {
77
    kitten_printf(4, 0, "Package %s is not installed, so not removed.", pkgname);
77
    kitten_printf(4, 0, pkgname); /* "Package %s is not installed, so not removed." */
78
    puts("");
78
    puts("");
79
    return(-1);
79
    return(-1);
80
  }
80
  }
81
 
81
 
82
  /* remove all files/folders listed in pkgname.lst but NOT pkgname.lst */
82
  /* remove all files/folders listed in pkgname.lst but NOT pkgname.lst */
Line 101... Line 101...
101
 
101
 
102
    /* do not delete pkgname.lst at this point - I am using it (will be deleted later) */
102
    /* do not delete pkgname.lst at this point - I am using it (will be deleted later) */
103
    if (strcasecmp(buff, fpath) == 0) continue;
103
    if (strcasecmp(buff, fpath) == 0) continue;
104
 
104
 
105
    /* remove it */
105
    /* remove it */
106
    kitten_printf(4, 4, "removing %s", buff);
106
    kitten_printf(4, 4, buff); /* "removing %s" */
107
    puts("");
107
    puts("");
108
    unlink(buff);
108
    unlink(buff);
109
  }
109
  }
110
 
110
 
111
  /* close the lst file */
111
  /* close the lst file */
Line 134... Line 134...
134
    free(dirlistpos);
134
    free(dirlistpos);
135
  }
135
  }
136
 
136
 
137
  /* remove the lst file */
137
  /* remove the lst file */
138
  unlink(fpath);
138
  unlink(fpath);
139
  kitten_printf(4, 5, "Package %s has been removed.", pkgname);
139
  kitten_printf(4, 5, pkgname); /* "Package %s has been removed." */
140
  puts("");
140
  puts("");
141
  return(0);
141
  return(0);
142
}
142
}