In my class I have FILE* ascii_file;
data member, which always is initialized via class constructor. How can I get full path of the asci_file
? I don't want to store more information about the file expect ascii_file
, and want it to work on windows, linux and solaris.
This task is going to require non-portable code.
On Windows you can convert FILE*
to CRT file descriptor using _fileno, and then convert to an OS handle using _get_osfhandle.
Then you can get the filename as shown here (using file mapping).
Obtaining a File Name From a File Handle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With