/*
 * edlib v1.1 Copyright 1989 Edwin Hoogerbeets
 * This code is freely redistributable as long as no charge other than
 * reasonable copying fees are levied for it.
 */
#include "edlib.h"
#include <libraries/dos.h>
#include <errno.h>

extern struct FileLock *Lock();
extern struct FileLock *CurrentDir();

int chdir(path)
char *path;
{
  struct FileLock *lock;

  if ( !path ) {
    errno = EFAULT;
    return(-1);
  }

  if ( !isdir(path) ) {
    errno = ENOENT;
    return(-1);
  }

  if ( !(lock = Lock(path,ACCESS_READ)) ) {
    errno = EACCES;
    return(-1);
  }

  lock = CurrentDir(lock);

  return(0);
}
