Logo

Programming-Idioms

  • Rust
  • Js

Idiom #106 Get program working directory

Assign to string dir the path of the working directory.
(This is not necessarily the folder containing the executable itself)

let dir = process.cwd ()

Only works in NodeJS because JavaScript in the browser does not know about your directories.
use std::env;
let dir = env::current_dir().unwrap();

dir has type PathBuf
with Ada.Directories; use Ada.Directories;
Dir : String := Current_Directory;

New implementation...
< >
programming-idioms.org