01: /*
02: * PwdCmd.java
03: *
04: * This file contains the Jacl implementation of the built-in Tcl "pwd"
05: * command.
06: *
07: * Copyright (c) 1997 Cornell University.
08: * Copyright (c) 1997 Sun Microsystems, Inc.
09: *
10: * See the file "license.terms" for information on usage and
11: * redistribution of this file, and for a DISCLAIMER OF ALL
12: * WARRANTIES.
13: *
14: * RCS: @(#) $Id: PwdCmd.java,v 1.2 1999/05/09 01:12:14 dejong Exp $
15: *
16: */
17:
18: package tcl.lang;
19:
20: import java.io.*;
21:
22: /*
23: * This class implements the built-in "pwd" command in Tcl.
24: */
25:
26: class PwdCmd implements Command {
27:
28: /*
29: *-----------------------------------------------------------------------------
30: *
31: * cmdProc --
32: *
33: * This procedure is invoked to process the "pwd" Tcl command.
34: * See the user documentation for details on what it does.
35: *
36: * Results:
37: * None.
38: *
39: * Side effects:
40: * See the user documentation.
41: *
42: *-----------------------------------------------------------------------------
43: */
44:
45: public void cmdProc(Interp interp, // Current interp to eval the file cmd.
46: TclObject argv[]) // Args passed to the file command.
47: throws TclException {
48: if (argv.length != 1) {
49: throw new TclNumArgsException(interp, 1, argv, null);
50: }
51:
52: // Get the name of the working dir.
53:
54: String dirName = interp.getWorkingDir().toString();
55:
56: // Java File Object methods use backslashes on Windows.
57: // Convert them to forward slashes before returning the dirName to Tcl.
58:
59: if (JACL.PLATFORM == JACL.PLATFORM_WINDOWS) {
60: dirName = dirName.replace('\\', '/');
61: }
62:
63: interp.setResult(dirName);
64: }
65:
66: } // end PwdCmd class
|