April 19, 2005
"Regan Heath" <regan@netwin.co.nz> wrote in message news:opsphdcp0r23k2f5@nrage.netwin.co.nz...
> As promised... Tho it should be noted that you cannot simply run "dir" with this. it wants an actual executable not a cmd.exe command like "dir". However you can run "cmd /c dir" and get a directory listing.
>
> It would be nice if Ben had time to look at it and make sure I have not abused Stream ;)

Cool stuff. My first thought is that it would be more standard to have
Process be a class that has two Stream members (one for the in pipe and one
for the out pipe). Something like
class Process  {
  InputStream input;
  OutputStream output;
}
...
  Process proc = new Process("cmd /c dir");
  stdout.writefln("%s",proc.input.readLine());

But that's just becuase it feels odd to have Process subclass Stream. But I
haven't thought about it too much...
See for example Java's Process and PipeStream classes.


April 20, 2005
On Tue, 19 Apr 2005 19:30:30 -0400, Ben Hinkle <ben.hinkle@gmail.com> wrote:
> "Regan Heath" <regan@netwin.co.nz> wrote in message
> news:opsphdcp0r23k2f5@nrage.netwin.co.nz...
>> As promised... Tho it should be noted that you cannot simply run "dir"
>> with this. it wants an actual executable not a cmd.exe command like "dir".
>> However you can run "cmd /c dir" and get a directory listing.
>>
>> It would be nice if Ben had time to look at it and make sure I have not
>> abused Stream ;)
>
> Cool stuff. My first thought is that it would be more standard to have
> Process be a class that has two Stream members (one for the in pipe and one
> for the out pipe). Something like
> class Process  {
>   InputStream input;
>   OutputStream output;
> }
> ...
>   Process proc = new Process("cmd /c dir");
>   stdout.writefln("%s",proc.input.readLine());
>
> But that's just becuase it feels odd to have Process subclass Stream. But I
> haven't thought about it too much...
> See for example Java's Process and PipeStream classes.

Sounds good. I wasn't really sure how it was all supposed to "hang together".

So we derive a PipeStream class from Stream. In the PipeStream constructor pass IN or OUT (kinda like how File works). I might give that a go if I find some more time, or if you (or someone else) wants to, feel free.

Regan
April 20, 2005
Regan Heath wrote:
> As promised... Tho it should be noted that you cannot simply run "dir"  with this. it wants an actual executable not a cmd.exe command like "dir".  However you can run "cmd /c dir" and get a directory listing.
> 
> It would be nice if Ben had time to look at it and make sure I have not  abused Stream ;)
> 
> Regan
> 

Great. Thanks. Maybe this should go to Phobos? What do you guys think?

-- 
Carlos Santander Bernal
April 20, 2005
On Tue, 19 Apr 2005 20:31:17 -0500, Carlos Santander B. <csantander619@gmail.com> wrote:
> Regan Heath wrote:
>> As promised... Tho it should be noted that you cannot simply run "dir"  with this. it wants an actual executable not a cmd.exe command like "dir".  However you can run "cmd /c dir" and get a directory listing.
>>  It would be nice if Ben had time to look at it and make sure I have not  abused Stream ;)
>>  Regan
>>
>
> Great. Thanks. Maybe this should go to Phobos? What do you guys think?

It's fine by me :)
However, Ben has pointed out a few design changes which I think are a good idea.

Regan
April 20, 2005
Regan Heath wrote:
> On Tue, 19 Apr 2005 19:30:30 -0400, Ben Hinkle <ben.hinkle@gmail.com>
>  wrote:
> 
>> "Regan Heath" <regan@netwin.co.nz> wrote in message news:opsphdcp0r23k2f5@nrage.netwin.co.nz...
>> 
>>> As promised... Tho it should be noted that you cannot simply run
>>> "dir" with this. it wants an actual executable not a cmd.exe
>>> command like "dir". However you can run "cmd /c dir" and get a
>>> directory listing.
>>> 
>>> It would be nice if Ben had time to look at it and make sure I
>>> have not abused Stream ;)
>> 
>> 
>> Cool stuff. My first thought is that it would be more standard to
>> have Process be a class that has two Stream members (one for the in
>> pipe and  one for the out pipe). Something like class Process  { InputStream input; OutputStream output; } ... Process proc = new
>> Process("cmd /c dir"); stdout.writefln("%s",proc.input.readLine());

I hope you put in a stream for stderr, too!

>> But that's just becuase it feels odd to have Process subclass
>> Stream. But I haven't thought about it too much... See for example
>> Java's Process and PipeStream classes.
> 
> 
> Sounds good. I wasn't really sure how it was all supposed to "hang together".
> 
> So we derive a PipeStream class from Stream. In the PipeStream constructor  pass IN or OUT (kinda like how File works). I might give
>  that a go if I  find some more time, or if you (or someone else)
> wants to, feel free.
> 
> Regan
April 20, 2005
On Wed, 20 Apr 2005 09:37:29 +0300, Georg Wrede <georg.wrede@nospam.org> wrote:
> Regan Heath wrote:
>> On Tue, 19 Apr 2005 19:30:30 -0400, Ben Hinkle <ben.hinkle@gmail.com>
>>  wrote:
>>
>>> "Regan Heath" <regan@netwin.co.nz> wrote in message news:opsphdcp0r23k2f5@nrage.netwin.co.nz...
>>>
>>>> As promised... Tho it should be noted that you cannot simply run
>>>> "dir" with this. it wants an actual executable not a cmd.exe
>>>> command like "dir". However you can run "cmd /c dir" and get a
>>>> directory listing.
>>>>  It would be nice if Ben had time to look at it and make sure I
>>>> have not abused Stream ;)
>>>   Cool stuff. My first thought is that it would be more standard to
>>> have Process be a class that has two Stream members (one for the in
>>> pipe and  one for the out pipe). Something like class Process  { InputStream input; OutputStream output; } ... Process proc = new
>>> Process("cmd /c dir"); stdout.writefln("%s",proc.input.readLine());
>
> I hope you put in a stream for stderr, too!

:) I have actually. I started coding a new version using Ben's idea.

Regan
April 20, 2005
On Wed, 20 Apr 2005 22:48:38 +1200, Regan Heath <regan@netwin.co.nz> wrote:
> On Wed, 20 Apr 2005 09:37:29 +0300, Georg Wrede <georg.wrede@nospam.org> wrote:
>> Regan Heath wrote:
>>> On Tue, 19 Apr 2005 19:30:30 -0400, Ben Hinkle <ben.hinkle@gmail.com>
>>>  wrote:
>>>
>>>> "Regan Heath" <regan@netwin.co.nz> wrote in message news:opsphdcp0r23k2f5@nrage.netwin.co.nz...
>>>>
>>>>> As promised... Tho it should be noted that you cannot simply run
>>>>> "dir" with this. it wants an actual executable not a cmd.exe
>>>>> command like "dir". However you can run "cmd /c dir" and get a
>>>>> directory listing.
>>>>>  It would be nice if Ben had time to look at it and make sure I
>>>>> have not abused Stream ;)
>>>>   Cool stuff. My first thought is that it would be more standard to
>>>> have Process be a class that has two Stream members (one for the in
>>>> pipe and  one for the out pipe). Something like class Process  {
>>>> InputStream input; OutputStream output; } ... Process proc = new
>>>> Process("cmd /c dir"); stdout.writefln("%s",proc.input.readLine());
>>
>> I hope you put in a stream for stderr, too!
>
> :) I have actually. I started coding a new version using Ben's idea.

And here it is!
Thoughts?

Regan

April 20, 2005
> So we derive a PipeStream class from Stream. In the PipeStream constructor pass IN or OUT (kinda like how File works). I might give that a go if I find some more time, or if you (or someone else) wants to, feel free.

Sounds reasonable. It might be worth subclassing (or maybe even just reusing) std.stream.File since a pipe is (I think) implemented as file descriptors on the OS's I know about. For example on Windows pipes use ReadFile and WriteFile.

I don't know if you were planning on suggesting it to Walter but it might be nice to put the Process class into std.process, too.


April 20, 2005
On Wed, 20 Apr 2005 08:24:42 -0400, Ben Hinkle <ben.hinkle@gmail.com> wrote:
>> So we derive a PipeStream class from Stream. In the PipeStream constructor
>> pass IN or OUT (kinda like how File works). I might give that a go if I
>> find some more time, or if you (or someone else) wants to, feel free.
>
> Sounds reasonable. It might be worth subclassing (or maybe even just
> reusing) std.stream.File since a pipe is (I think) implemented as file
> descriptors on the OS's I know about. For example on Windows pipes use
> ReadFile and WriteFile.

They do.. if anything I would think that std.stream.File would use PipeStream (see my latest code). The reason I say this is that std.stream.File uses pipes, but also calls CreateFile to create a file on a disk. So it seems to me FileStream extends PipeStream, not the other way round.

We would need to move some of the functionality in std.stream.File into PipeStream though i.e. seekability check, seek routine, etc.

> I don't know if you were planning on suggesting it to Walter but it might be nice to put the Process class into std.process, too.

If he thinks it's useful, he's welcome to it.

Regan
April 20, 2005
Well, what are you waiting for?  Get at it! :-)

jic

Regan Heath says...
>
>On Tue, 19 Apr 2005 20:31:17 -0500, Carlos Santander B. <csantander619@gmail.com> wrote:
>> Regan Heath wrote:
>>> As promised... Tho it should be noted that you cannot simply run "dir"
>>> with this. it wants an actual executable not a cmd.exe command like
>>> "dir".  However you can run "cmd /c dir" and get a directory listing.
>>>  It would be nice if Ben had time to look at it and make sure I have
>>> not  abused Stream ;)
>>>  Regan
>>>
>>
>> Great. Thanks. Maybe this should go to Phobos? What do you guys think?
>
>It's fine by me :)
>However, Ben has pointed out a few design changes which I think are a good
>idea.
>
>Regan


1 2
Next ›   Last »