Re: [Vala] Gio and stdin



Hi Luca,

On 06/11/2011 10:46 PM, Luca Bruno wrote:
On Sat, Jun 11, 2011 at 08:57:10PM +0200, Christian Siefkes wrote:
I use Gio to read files line by line, as in the example at
https://live.gnome.org/Vala/GIOSamples#Reading_Text_File_Line_by_Line .
I would like to support the frequent Unix convention that '-' as filename
means "read from standard", but I didn't find a way to convert a FileStream
(stdin) to an InputStream. Can anyone tell me how to do it?

You can create a unix input stream with fd 0.

Yes, I could do that, thanks for the hint. But if I do that, my program
would no longer work (or even compile) on non-Unix systems, while
FileStreams and the standard variables, stdin|out|err, work everywhere (even
though they are rarely used outside Unix). So maybe I'll better switch
to working with FileStreams instead of Gio.

On the other hand, Gio has a nicer API and the neat property of being able
to directly work with URLs as well as with local files (if you call
File.new_for_commandline_arg(...)). Hmm...

Best regards
        Christian

-- 
|------- Dr. Christian Siefkes ------- christian siefkes net -------
| Homepage: http://www.siefkes.net/ | Blog: http://www.keimform.de/
|    Peer Production Everywhere:       http://peerconomy.org/wiki/
|---------------------------------- OpenPGP Key ID: 0x346452D8 --
I've never seen a child who didn't want to build something out of blocks, or
learn something new, or try the next task. And the only reason why adults
aren't like that is, I suppose, that they have been sent to school and other
oppressive institutions, which have driven that out of them.
        -- Noam Chomsky (The Chomsky-Foucault Debate: On Human Nature)

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]