Files
amiga-libnix2/libnix/sources/nix/extra/chdir.c
T
jshepher a99f123db5 Fixed missing function warnings.
Moved headers around so we include <devices/timer.h> before <sys/time.h>
(so we don't have to patch the OS headers)
2004-12-04 00:49:38 +00:00

44 lines
611 B
C
Executable File

#include <proto/dos.h>
#include <stdlib.h>
#include <unistd.h>
#include "stabs.h"
extern void __seterrno(void);
static BPTR oldlock;
static int havelock=0;
int chdir(const char *path)
{
BPTR fl;
int ret;
if ((fl=Lock((STRPTR)path,SHARED_LOCK)))
{
UnLock(CurrentDir(fl)); ret=0;
}
else
{
__seterrno(); ret=-1;
}
return ret;
}
void __initchdir(void)
{
BPTR fl;
if (!(fl=Lock("",SHARED_LOCK)))
exit(20);
oldlock=CurrentDir(fl);
havelock=1;
}
void __exitchdir(void)
{
if (havelock) UnLock(CurrentDir(oldlock));
}
ADD2INIT(__initchdir,-35);
ADD2EXIT(__exitchdir,-35);