Skip to content

Commit

Permalink
Uses installed directory on upgrade.
Browse files Browse the repository at this point in the history
Fixes #15
  • Loading branch information
fr3nd committed Feb 14, 2021
1 parent b1f6609 commit 17482dd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
47 changes: 46 additions & 1 deletion src/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1445,8 +1445,53 @@ void uninstall(char *package) {
}

void upgrade(char *package) {
int fp;
int n, m;
int bytes_read;
char buffer[MAX_PATH_SIZE];
char current_file[MAX_PATH_SIZE];

// Get installed directory so upgrade is installed in the same one
strcpy(buffer, configpath);
strcat(buffer, "\\IDB\\");
strcat(buffer, package);
fp = open(buffer, O_RDONLY);

if (fp < 0) {
n = (fp >> 0) & 0xff;
if (n == 0xD7) {
die("Package %s is not installed.", package);
} else {
printf("Error reading configuration %s: 0x%X\r\n", buffer, n);
explain(buffer, n);
die("%s", buffer);
}
}

current_file[0] = '\0';
m = 0;
while(1) {
bytes_read = read(buffer, MAX_PATH_SIZE, fp);

for (n=0; n<bytes_read ;n++) {
if (buffer[n] != '\n' && buffer[n] != '\r') {
current_file[m] = buffer[n];
m++;
} else if (buffer[n] == '\n') {
current_file[m] = '\0';
m = 0;
}
}

if (bytes_read < MAX_PATH_SIZE) {
break;
}
}
close(fp);

printf("- Installation dir: %s\r\n", current_file);
uninstall(package);
install(package, "");
install(package, current_file);
}

void configure(void) {
Expand Down
2 changes: 1 addition & 1 deletion src/include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "asm.h"

#define MSXHUB_VERSION "1.0.5"
#define MSXHUB_VERSION "1.0.6"

/* DOS errors */
#define NOFIL 0xD7
Expand Down

0 comments on commit 17482dd

Please sign in to comment.