How can I call ioctl() on an fstream object?

B

barisdemiray

Hello,

I have a wrapper class for file operations and I utilized fstream
class for that. Everything was fine untill I was required to call ioctl
() on
one of that objects and now I'm totally stuck although I STFNed and
RTFMed which returned me no clues.

Is there anyone with a solution to get a file descriptor of an
fstream
object? I'll appreciate even a quick-and-dirty way to do that.

Regards,
 
F

Francesco S. Carta

Hello,

I have a wrapper class for file operations and I utilized fstream
class for that. Everything was fine untill I was required to call ioctl
() on
one of that objects and now I'm totally stuck although I STFNed and
RTFMed which returned me no clues.

Is there anyone with a solution to get a file descriptor of an
fstream
object? I'll appreciate even a quick-and-dirty way to do that.

Hi, the ioctl() function is a non-standard C++ function which varies
on different OS.

You should point out exactly what you're using it for and eventually
also point out which implementation of ioctl() you're using - not that
it'd make this all more on-topic, but at least you could receive
better help about it.

Consider also posting this to a fitting OS/implementation specific
group.

Hope that helps,
cheers,
Francesco
 
J

James Kanze

I have a wrapper class for file operations and I utilized
fstream class for that. Everything was fine untill I was
required to call ioctl () on one of that objects and now I'm
totally stuck although I STFNed and RTFMed which returned me
no clues.
Is there anyone with a solution to get a file descriptor of an
fstream object? I'll appreciate even a quick-and-dirty way to
do that.

The simple answer is that you can't. The implementation of
filebuf (and [io]fstream) that you're using might offer the
possibility of obtaining the system level file descriptor as an
extension, but you'll have to check the system documentation for
that. (Under Unix, look for a function along the lines of
filebuf::fileno or filebuf::fd.)

Otherwise, you're stuck with implementing a custom filebuf, with
the functionality you need. (It's not that difficult, at least
if you don't need all of the more complicated machinery: code
translation, seeking, etc.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,809
Members
48,797
Latest member
PeterSimpson
Top