home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff218.lzh / EdLib / chdir.c < prev    next >
C/C++ Source or Header  |  1989-06-04  |  615b  |  37 lines

  1. /*
  2.  * edlib v1.1 Copyright 1989 Edwin Hoogerbeets
  3.  * This code is freely redistributable as long as no charge other than
  4.  * reasonable copying fees are levied for it.
  5.  */
  6. #include "edlib.h"
  7. #include <libraries/dos.h>
  8. #include <errno.h>
  9.  
  10. extern struct FileLock *Lock();
  11. extern struct FileLock *CurrentDir();
  12.  
  13. int chdir(path)
  14. char *path;
  15. {
  16.   struct FileLock *lock;
  17.  
  18.   if ( !path ) {
  19.     errno = EFAULT;
  20.     return(-1);
  21.   }
  22.  
  23.   if ( !isdir(path) ) {
  24.     errno = ENOENT;
  25.     return(-1);
  26.   }
  27.  
  28.   if ( !(lock = Lock(path,ACCESS_READ)) ) {
  29.     errno = EACCES;
  30.     return(-1);
  31.   }
  32.  
  33.   lock = CurrentDir(lock);
  34.  
  35.   return(0);
  36. }
  37.