Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

popen equivalent in C++



Hi --

I don't know if this is a gcc 3 question or a Macintosh question:
On other unixes, with gcc 2.9x, I've used code like the following to
open a compressed file and read it as a C++ istream:

  FILE *file = popen("gunzip -c " + name, "r"); // 'name' is a string
  ifstream *stream = new ifstream(fileno(file));

This doesn't work with gcc 3.1/OS X 10.2 because ifstream::ifstream(int)
doesn't exist anymore.  What's the modern way of doing this?  A web search
turned up references to procbuf, a gcc extension class derived from streambuf
for reading from pipes, but I can't find any header files referring to it
on my 10.2 system.

Thanks for any advice.  I'm sure I'm missing or forgetting something obvious.

-- Steve


-- -- EMail: email@hidden Phone: (301) 975-5423 -- -- WWW: http://math.nist.gov/mcsd/Staff/SLanger/ Fax: (301) 990-4127 -- -- Mail: NIST; 100 Bureau Drive -- Stop 8910; Gaithersburg, Md 20899-8910 -- _______________________________________________ unix-porting mailing list | email@hidden Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting Do not post admin requests to the list. They will be ignored.





Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.