File: popd.c

package info (click to toggle)
dosemu-freedos 1%3A0.0.b9r5a%2Betch.1-0etch1
  • links: PTS
  • area: contrib
  • in suites: etch
  • size: 19,744 kB
  • ctags: 23,279
  • sloc: ansic: 143,864; asm: 20,397; makefile: 3,868; perl: 1,106; yacc: 690; sh: 553; pascal: 297; xml: 150; cpp: 67
file content (39 lines) | stat: -rw-r--r-- 719 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 *  DSTACK.C - Directory stack PUSHD/POPD support, compatible with 4/NDOS
 *
 *	POPD [*]
 *
 * Pops a directory off the stack, and sets it as cwd.
 * Accepts the parameter '*', causing it to wipe the stack.
 */

#include "../config.h"

#include <stdlib.h>

#include "../include/context.h"
#include "../include/command.h"
#include "../include/misc.h"
#include "../strings.h"

int cmd_popd(char *param)
{
	if(!param || *param != '*') {
		char *todir;

		if(ctxtPop(CTXT_TAG_DIRSTACK, &todir)) {
			int rc;

			rc = cmd_cdd(todir);
			free(todir);
			return rc;
		}

		displayString(TEXT_DIRSTACK_EMPTY);
	}

		/* Wipe the dirstack */
	ctxtClear(CTXT_TAG_DIRSTACK);

	return 0;
}