Tcl_GetCwd(3)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

Tcl_GetCwd πŸ’– β€” manipulate the current working directory

okay bestie, so we're in Tcl_GetCwd(3) territory, and this is literally the Tcl Library Procedures page for Tcl_GetCwd and Tcl_Chdir. two lil functions, one big vibe: getting and setting where your app thinks it lives. 🏠✨


🌸 SYNOPSIS 🌸

#include <tcl.h>

char *
Tcl_GetCwd(interp, bufferPtr)

int
Tcl_Chdir(dirName)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tcl_Interp *interp (in) β€” the interpreter where we drop an error message if anything goes sideways. it's giving "tell the interp, not me" energy. πŸ™ˆ
  • Tcl_DString *bufferPtr (in/out) β€” this dynamic string is where the current working directory gets stored. at the time of the call it should be uninitialized or free. and bestie, the caller must eventually call Tcl_DStringFree to free up anything stored here. no leaks, we don't do that. πŸ’…
  • const char *dirName (in) β€” the file path, in UTF-8 format. πŸ¦‹

✨ DESCRIPTION ✨

these procedures may be used to manipulate the current working directory for the application. they give you C-level access to the exact same functionality as the Tcl pwd command. iykyk. πŸ”₯

Tcl_GetCwd returns a pointer to a string specifying the current directory, or NULL if the current directory could not be determined. if NULL comes back, 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 application's 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. main character behavior honestly. πŸ‘‘


🫢 KEYWORDS 🫢

pwd


and that's the whole page, bestie!! πŸ’œ this was the Tcl 8.1 era, dated right there in the footer, from the Tcl Library Procedures manual set β€” so if you ever need to know where you are or tell your app where to be, you know exactly who to call. slay, periodt, go free your Tcl_DStrings. πŸŽ€βœ¨

πŸ“¦ where this page comes from