[Solved] How to use getcwd() in Windows, Rust 1.1


#1

I’ve search the API docs for a way to get a string representation of the current working directory of my executing program, but I can only find the function getcwd() in libc, which seeems really tedious to use.

But in the source code at github.com I can clearly see that there exists functions for getcwd() for each platform.
Here, as an example, you can find the windows version of getcwd(): https://github.com/rust-lang/rust/blob/fe0b5c0d38fc937ff6cf3623c4277b0463b17748/src/libstd/sys/windows/os.rs

This confuses the hell out of me.

What is the proper way to get the current working directory?

I’m a Rust beginner and new to the community. Please guide me if I do anything wrong.
My programming experience lies in Ruby and basic C.


#2

https://doc.rust-lang.org/std/env/fn.current_dir.html


#3

Thank you very much, @gkoz. It works flawlessly. : )

It seems the real problem is to know what to search for in the API docs.