home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d3xx / d352 / mg.lha / MG / src.LZH / mg / dir.c < prev    next >
C/C++ Source or Header  |  1990-05-23  |  1KB  |  67 lines

  1. /*
  2.  * Name:    MG 2a Directory management functions Created:    Ron Flax
  3.  * (ron@vsedev.vse.com) Modified for MG 2a by Mic Kaczmarczik 03-Aug-1987
  4.  */
  5.  
  6. #include "no_dir.h"
  7.  
  8. #ifndef NO_DIR
  9. #include "def.h"
  10.  
  11. #ifdef    ANSI
  12. #include <string.h>
  13. #endif
  14.  
  15. #ifndef    getwd            /* may be a #define */
  16. char           *getwd();
  17. #endif
  18. char           *wdir;
  19. static char     cwd[NFILEN];
  20.  
  21. /*
  22.  * Initialize anything the directory management routines need
  23.  */
  24. VOID
  25. dirinit()
  26. {
  27.     if (!(wdir = getwd(cwd)))
  28.         panic("Can't get current directory!");
  29. }
  30.  
  31. /*
  32.  * Change current working directory
  33.  */
  34. /* ARGSUSED */
  35. changedir(f, n)
  36. {
  37.     register int    s;
  38.     char            bufc[NPAT];
  39.  
  40.     if ((s = ereply("Change default directory: ", bufc, NPAT)) != TRUE)
  41.         return (s);
  42.     if (bufc[0] == '\0')
  43.         (VOID) strcpy(bufc, wdir);
  44.     if (chdir(bufc) == -1) {
  45.         ewprintf("Can't change dir to %s", bufc);
  46.         return (FALSE);
  47.     } else {
  48.         if (!(wdir = getwd(cwd)))
  49.             panic("Can't get current directory!");
  50.         ewprintf("Current directory is now %s", wdir);
  51.         return (TRUE);
  52.     }
  53. }
  54.  
  55. /*
  56.  * Show current directory
  57.  */
  58. /* ARGSUSED */
  59. showcwdir(f, n)
  60. {
  61.     ewprintf("Current directory: %s", wdir);
  62.     return (TRUE);
  63. }
  64. #else
  65. #include "nullfile.h"
  66. #endif
  67.