Can I get a file name or its path from a fstream
object? I looked through the methods of fstream
and didn't find anything close to it.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- How to replace file-access references for a module
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
No, that is not possible, not at least in the Standard conformant implementation of the library.
The fstream class doesn't store the filename, and doesn't provide any function for retrieving it.
So one way to keep track of this information is to use
std::map
as:Or, simply pass around the filename as well.
you may also design a little class which inherits from
fstream
and behaves like afstream
but also stores its file name.