home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
CHDIR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
924b
|
47 lines
#include <errno.h>
#include <osbind.h>
#include <stddef.h>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <unistd.h>
#include "lib.h"
/***************************************************************
chdir: change the directory and (possibly) the drive.
By ERS: it's in the public domain.
****************************************************************/
int chdir(dir)
const char *dir;
{
int drv, old;
int r;
char tmp[PATH_MAX];
register char *d;
assert ((dir != NULL));
(void)_unx2dos(dir, tmp); /* convert Unix filename to DOS */
d = tmp;
old = Dgetdrv();
if (*d && *(d+1) == ':') {
drv = toupper(*d) - 'A';
d+=2;
(void)Dsetdrv(drv);
}
else
drv = old;
if (!*d) { /* empty path means root directory */
*d = '\\';
*(d+1) = '\0';
}
if ((r = Dsetpath(d)) < 0) {
(void)Dsetdrv(old);
errno = -r;
return -1;
}
return 0;
}