summaryrefslogtreecommitdiff
path: root/usr.bin/mg/dir.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-02-25 19:08:53 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-02-25 19:08:53 +0000
commit998d769a0cf8bef7d4ca0d26945c151a23b542ec (patch)
treefe53a083eaa06a2bf7631453e18a161a86ad9d62 /usr.bin/mg/dir.c
parentb0226ecd4460819556afd27fd575d64421fd0f68 (diff)
initial import of mg2a
Diffstat (limited to 'usr.bin/mg/dir.c')
-rw-r--r--usr.bin/mg/dir.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c
new file mode 100644
index 00000000000..b8f40f973ee
--- /dev/null
+++ b/usr.bin/mg/dir.c
@@ -0,0 +1,59 @@
+/*
+ * Name: MG 2a
+ * Directory management functions
+ * Created: Ron Flax (ron@vsedev.vse.com)
+ * Modified for MG 2a by Mic Kaczmarczik 03-Aug-1987
+ */
+
+#include "def.h"
+
+#ifndef NO_DIR
+#ifndef getwd /* may be a #define */
+char *getwd();
+#endif
+char *wdir;
+static char cwd[NFILEN];
+
+/*
+ * Initialize anything the directory management routines need
+ */
+dirinit()
+{
+ if (!(wdir = getwd(cwd)))
+ panic("Can't get current directory!");
+}
+
+/*
+ * Change current working directory
+ */
+/*ARGSUSED*/
+changedir(f, n)
+{
+ register int s;
+ char bufc[NPAT];
+
+ if ((s=ereply("Change default directory: ", bufc, NPAT)) != TRUE)
+ return(s);
+ if (bufc[0] == '\0')
+ (VOID) strcpy(bufc, wdir);
+ if (chdir(bufc) == -1) {
+ ewprintf("Can't change dir to %s", bufc);
+ return(FALSE);
+ } else {
+ if (!(wdir = getwd(cwd)))
+ panic("Can't get current directory!");
+ ewprintf("Current directory is now %s", wdir);
+ return(TRUE);
+ }
+}
+
+/*
+ * Show current directory
+ */
+/*ARGSUSED*/
+showcwdir(f, n)
+{
+ ewprintf("Current directory: %s", wdir);
+ return(TRUE);
+}
+#endif