-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_version.c
50 lines (41 loc) · 1.28 KB
/
set_version.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <proto/dos.h>
#include <proto/utility.h>
#include <proto/exec.h>
#include <dos/dosextens.h>
#include <dos/dosextens.h>
#include <dos/dos.h>
#include <string.h>
#include "utility.h"
int set_version(const char *cmd, const char *version)
{
int32 rc;
char cmd_dir[MAX_PATH_BUF];
char path[MAX_PATH_BUF];
char target[MAX_PATH_BUF];
// Make sure the specified version exists
strcpy(path, SETCMD_CMDS);
IDOS->AddPart(path, cmd, MAX_PATH_BUF);
IDOS->AddPart(path, version, MAX_PATH_BUF);
if (!can_lock(path)) {
IDOS->Printf("%sERROR %s: version %s does not exist for command %s.\n", fmt(FG_RED), fmt(NORMAL), version, cmd);
dos_debug();
return RETURN_FAIL;
}
strcpy(target, path);
// Delete the link under the path directory
strcpy(path, SETCMD_PATH);
IDOS->AddPart(path, cmd, MAX_PATH_BUF);
rc = IDOS->Delete((char *)path);
if (!rc) {
IDOS->Printf("%sERROR %s: unexpected error deleting path link %s.\n", fmt(FG_RED), fmt(NORMAL), path);
dos_debug();
return RETURN_FAIL;
}
// Make the new link
rc = IDOS->MakeLink((char *)path, (char *)target, LINK_SOFT);
if (!rc) {
IDOS->Printf("%sERROR %s: unexpected error creating link %s => %s.\n", fmt(FG_RED), fmt(NORMAL), path, target);
dos_debug();
}
return RETURN_OK;
}