home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / zc.lzh / ZC / ZCSRC.LZH / IOLib / misc / chdir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-10  |  683 b   |  37 lines

  1. #include <libraries/dos.h>
  2. #include <exec/memory.h>
  3.  
  4. #ifndef NULL
  5. #define NULL 0L
  6. #endif
  7.  
  8. typedef    struct Lock LOCK
  9. extern LOCK Lock();
  10. extern long IoErr();
  11. extern void UnLock();
  12. extern LOCK CurrentDir();
  13.  
  14. /*------------------------------------------------------------------*/
  15. /*    chdir(path): make path the current directory. Return Ok/Not */
  16. /*------------------------------------------------------------------*/
  17.  
  18. int chdir( path )
  19. char *path;
  20. {
  21.     register LOCK    *lock;
  22.     LOCK        *oldLock;
  23.  
  24.     if ( *path == '\0' )
  25.         return 0;
  26.  
  27.     lock = Lock( path, ACCESS_READ );
  28.     if ( lock == NULL )
  29.         return (int)IoErr();
  30.  
  31.     oldLock = CurrentDir( lock );
  32.     if ( oldLock )
  33.         UnLock( oldLock );
  34.  
  35.     return 0;
  36. }
  37.