home *** CD-ROM | disk | FTP | other *** search
- #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 = '\\';
- #if 0
- /* 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;
- }
- }
- #endif
- *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;
- }
-
- #ifdef __GNUC__
- asm(".stabs \"_unx2dos\",5,0,0,__unx2dos"); /* dept of clean tricks */
- asm(".stabs \"_dos2unx\",5,0,0,__dos2unx"); /* dept of clean tricks */
- #endif
-