Tcl\_GetCwd(3) Tcl Library Procedures Tcl\_GetCwd(3)

```

```

# [NAME](#NAME)

Tcl\_GetCwd, Tcl\_Chdir - manipulate the current working directory

# [SYNOPSIS](#SYNOPSIS)

```
#include <tcl.h>

char *
Tcl_GetCwd(interp, bufferPtr)

int
Tcl_Chdir(dirName)
```

# [ARGUMENTS](#ARGUMENTS)

Tcl\_Interp *\*interp* (in)

Interpreter in which to report an error, if any.

Tcl\_DString *\*bufferPtr* (in/out)

This dynamic string is used to store the current working directory. At the time of the call it should be uninitialized or free. The caller must eventually call **Tcl\_DStringFree** to free up anything stored here.

const char *\*dirName* (in)

File path in UTF-8 format.

```
    
```

# [DESCRIPTION](#DESCRIPTION)

These procedures may be used to manipulate the current working directory for the application. They provide C-level access to the same functionality as the Tcl **pwd** command.

**Tcl\_GetCwd** returns a pointer to a string specifying the current directory, or NULL if the current directory could not be determined. If NULL is returned, an error message is left in the *interp*'s result. Storage for the result string is allocated in bufferPtr; the caller must call **Tcl\_DStringFree()** when the result is no longer needed. The format of the path is UTF-8.

**Tcl\_Chdir** changes the applications current working directory to the value specified in *dirName*. The format of the passed in string must be UTF-8. The function returns -1 on error or 0 on success.

# [KEYWORDS](#KEYWORDS)

pwd

8.1 Tcl

---

Document: Tcl_GetCwd(3) from tcl 9.1.0-r0 (Chainguard OS)
Source: https://downloads.sourceforge.net/project/tcl/Tcl/9.1.0/tcl9.1.0-src.tar.gz
