There's nothing in the DIR object that gives you the name of the directory that the DIR object is reading. There is no function in the C library that does this.
You will need to implement this logic yourself. Wherever you open a DIR: save the name of the directory you opened, and consult it as needed.
There's nothing in the
DIRobject that gives you the name of the directory that theDIRobject is reading. There is no function in the C library that does this.You will need to implement this logic yourself. Wherever you open a
DIR: save the name of the directory you opened, and consult it as needed.Or, in modern C++, you can also use the filesystem library, instead of this C API.