Subversion Repositories SvarDOS

Rev

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

Rev 1878 Rev 1892
Line 15... Line 15...
15
 
15
 
16
#include "trim.h"
16
#include "trim.h"
17
#include "helpers.h"
17
#include "helpers.h"
18
 
18
 
19
 
19
 
20
/* returns the DOS boot drive */
-
 
21
static unsigned char GETDOSBOOTDRIVE(void);
-
 
22
#pragma aux GETDOSBOOTDRIVE = \
-
 
23
"mov ax, 0x3305" /* int 0x21,AX=3305 - get boot drive (MS-DOS 4.0+) */ \
-
 
24
"int 0x21" \
-
 
25
"jnc GOOD" \
-
 
26
"mov dl, 3"      /* fall back to "C" on error (DOS 3.x...) */ \
-
 
27
"GOOD:" \
-
 
28
"add dl, '@'"    /* convert the drive id (A=1, B=2...) into a drive letter */ \
-
 
29
modify [ax] \
-
 
30
value [dl]
-
 
31
 
-
 
32
 
-
 
33
/* change all / to \ in a string */
20
/* change all / to \ in a string */
34
void slash2backslash(char *str) {
21
void slash2backslash(char *str) {
35
  int x;
22
  int x;
36
  for (x = 0; str[x] != 0; x++) {
23
  for (x = 0; str[x] != 0; x++) {
37
    if (str[x] == '/') str[x] = '\\';
24
    if (str[x] == '/') str[x] = '\\';
Line 103... Line 90...
103
}
90
}
104
 
91
 
105
 
92
 
106
/* returns a pointer to the start of the filename, out of a path\to\file string, and
93
/* returns a pointer to the start of the filename, out of a path\to\file string, and
107
   fills respath with the local folder where the file should be placed. */
94
   fills respath with the local folder where the file should be placed. */
108
char *computelocalpath(char *longfilename, char *respath, const char *dosdir, const struct customdirs *dirlist) {
95
char *computelocalpath(char *longfilename, char *respath, const char *dosdir, const struct customdirs *dirlist, char bootdrive) {
109
  int x, lastsep = 0, firstsep = -1;
96
  int x, lastsep = 0, firstsep = -1;
110
  char savedchar;
97
  char savedchar;
111
  char *shortfilename, *pathstart;
98
  char *shortfilename, *pathstart;
112
  pathstart = longfilename;
99
  pathstart = longfilename;
113
  for (x = 0; longfilename[x] != 0; x++) {
100
  for (x = 0; longfilename[x] != 0; x++) {
Line 116... Line 103...
116
      if (firstsep < 0) firstsep = x;
103
      if (firstsep < 0) firstsep = x;
117
    }
104
    }
118
  }
105
  }
119
  /* if it's a file without any directory, then it goes to BOOTDRIVE:\ (COMMAND.COM, KERNEL.SYS...) */
106
  /* if it's a file without any directory, then it goes to BOOTDRIVE:\ (COMMAND.COM, KERNEL.SYS...) */
120
  if (firstsep < 0) {
107
  if (firstsep < 0) {
121
    sprintf(respath, "%c:\\", GETDOSBOOTDRIVE());
108
    sprintf(respath, "%c:\\", bootdrive);
122
    return(longfilename);
109
    return(longfilename);
123
  }
110
  }
124
  /* */
111
  /* */
125
  shortfilename = &longfilename[lastsep + 1];
112
  shortfilename = &longfilename[lastsep + 1];
126
  /* look for possible custom path */
113
  /* look for possible custom path */