home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
UNX2DOS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
2KB
|
97 lines
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <osbind.h>
#include <types.h>
extern int __mint;
extern char _rootdir; /* in main.c: user's preferred root directory */
int _unixmode; /* not used right now */
/*
* returns 0 for ordinary files, 1 for special files (like /dev/tty)
*/
int
_unx2dos(unx, dos)
const char *unx;
char *dos;
{
const char *u;
char *d, c;
dos[0] = 0;
u = unx; d = dos;
if (!strncmp(u, "/dev/", 5)) {
u += 5;
/* make /dev/A/foo the same as A:/foo */
if (*u && (u[1] == 0 || (u[1] == '/' || u[1] == '\\'))) {
d[0] = *u++;
d[1] = ':';
d += 2;
}
/* check for a unix device name */
else if (__mint) {
if (__mint >= 8) {
strcpy(d, "U:\\dev\\"); d += 7;
} else {
strcpy(d, "V:\\");
d += 3;
}
}
else {
strcpy(d, u);
strcat(d, ":");
if (!strcmp(d, "tty:"))
strcpy(d, "con:");
return 1;
}
} else if (__mint && !strncmp(u, "/pipe/", 6)) {
u += 6;
if (__mint >= 9) {
strcpy(d, "U:\\pipe\\"); d += 8;
} else {
strcpy(d, "Q:\\"); d += 3;
}
} else if (*u == '/' && _rootdir) {
*d++ = _rootdir;
*d++ = ':';
}
while( (c = *u++) != 0 ) {
if (c == '/')
c = '\\';
/* translate "c:/foo/d:/bar" into "d:\bar" */
else if (c == ':') {
if ( (d > &dos[1] && d[-2] == '\\')
|| (d == &dos[1]) ) {
*dos = d[-1];
d = dos+1;
}
}
*d++ = c;
}
*d++ = 0;
return 0;
}
int
_dos2unx(dos, unx)
const char *dos;
char *unx;
{
char c;
while ( (c = *dos++) != 0) {
if (c == '\\')
c = '/';
else if (__mint < 7)
c = tolower(c);
*unx++ = c;
}
*unx++ = 0;
return 0;
}