streams

Read from file or stdin - C

Hello, I am writing a utility which accepts either a filename, or reads from stdin I would like to know the most robust / fastest way of checking to see if stdin exists (data is being piped to the program) and if so reading that data in. If it doesn't exist, the processing will take place on the filename given. I have tried using the...

Question about STDIN STDOUT STDERR

I'm designing a MIPS simulator in c++ and my simplified OS must be able to run stat() occasionally (when a program being executed on my simulator requires an input or an output or something.) The problem is, I need to be able to assert STDIN, STDOUT, and STDERR as parameters to stat "stat("stdin",buff)" where buff is the pointer to th...

Are stdin, stdout, and stderr Files?

Someone told me that whenever a C++ program is run three files STDIN, STDOUT and STDERR are opened and he gave this link in his support.. http://tldp.org/LDP/abs/html/io-redirection.html But I am confused weather these streams are actually Files? Can anyone clarify? ...

Rave Reports and Intraweb ?

Anyone have an example of using Rave Reports (PDF output) and Intraweb ? (or even WebBroker) in delphi ? I'm assuming you write to a memory stream and then output this to the browser. Any help on Rave Reports/Memory Streams and Intraweb or Webbroker appreciated. ...

Streams in Common Lisp?

Section 3.5 of Structure and Interpretation of Computer Programs describes streams. Does Common Lisp have such streams built in or is there a good Common Lisp library implementing such streams? [I mean streams in all the generality presented in section 3.5 of SICP; not just your usual i/o streams.] ...

Max number of streams in CUDA?

Is there a maximum number of streams that can be created in CUDA? To clarify I mean CUDA streams as in the stream that allows you to execute kernels and memory operations. ...

how to get stream positions of xml elements in .NET

How can I get the stream position of an XElement in .NET 4 in a reasonably efficient way? 1 2 3 4 5 6 7 8 01234567890123456789012345678901234567890123456789012345678901234567890123456789012 <root><group id="0" combiner="or"><filter id="1" /><filter id="2" /></group></root...

Java's [Input|Output]Streams' one-method-call-for-each-byte: a performance problem?

[Input|Output]Streams exist since JDK1.0, while their character-counterparts Readers|Writers exist since JDK1.1. Most concepts seem similar, with one exception: the base classes of streams declare an abstract method which processes one single byte at a time, while base readers/writers classes declare an abstract method which processes w...

How do command-line interpreters work?

I have been under the impression that processes on the operating system have three standard streams: stdin, stdout, and stderr. I have also thought that text editors like vim work by taking input over stdin and sending ANSI escape characters over stdout. However, my view of how command-line interpreters isn't holding up in this one case:...

adapting an old-fashioned cast of a std::streampos to be g++ 4.4 compatible

Good afternoon, I'm attempting to get some old-fashioned code to function in g++ 4.4. My understanding is the code compiled fine in g++ 4.0, but g++ has become more strict between 4.0 and 4.4. This code in particular causes the compiler to stop and complain: sprintf(s,"%.7d",(long)tellp()); tellp() is a std::streampos object. The ab...

Write Int array to Stream in .NET

Hi, what's the best way to write the binary representation of an int array (Int32[]) to a Stream? Stream.Write only accepts byte[] as source and I would like to avoid converting/copying the array to an byte[] (array but instead streaming directly from the 'original location'). In a more system-oriented language (a.k.a. C++) I would s...

Can DeflateStream or GZipStream be used to deflate an uncompressed file?

I'm trying to implement file compression to an application. The application has been around for a while, so it needs to be able to read uncompressed documents written by previous versions. I expected that DeflateStream would be able to process an uncompressed file, but for GZipStream I get the "The magic number in GZip header is not co...

Passing a stream object to a function where the stream can be the console or a file

I want to write a function that accepts a stream argument. Ideally I would like that argument to be the console (if I want the output to go to the screen), or a file (if I want to save the output). Something like this: void myFunc(<some stream object> strm) { strm.Write("something"); } How do I declare and call the function to get...

OneTimePad implementation fails. Maybe a stream problem?

Hi, I had some time and decided to implement a one time pad just for fun and self education. Now I end up with a weird behavior of the data. Its driving me crazy ^^. Would you please help me? Thanks in advance. There is an encrypt method which takes as arguements: an InputStream for the plain text an OutputStreams for the cipher tex...

How to copy binary data from one stream to another?

Currently i have a program that loads binary data into a stringstream and then pases the data to a fstream like so: stringstream ss(stringstream::binary | stringstream::in | stringstream::out); ss.write(data, 512); // Loads data into stream // Uses a memory block to pass the data between the streams char* memBlock = new char[512]; ss....

Who should be responsible for closing a stream

I'm writing an application that creates a "Catalog" of files, which can be attributed with other meta data files such as attachments and thumbnails. I'm trying to abstract the interface to a catalog to the point where a consumer of a catalog does not need to know about the underlying file system used to store the files. So I've created ...

Socket's input byte stream wrapped in two different stream types?

I'm trying to implement such a protocol: Client side: 1) client sends command (String) 2) client sends object 3) client receives object or data [depends on command] Server side: 1) server reads command (String) 2) server receives object [type depends on command] 3) server sends object or data [depe...

actionscript videochat

I want to implement video chatting on my site. I understand that I need a table of users online with their ips and that there will be flash clients but I do not understand how the streams are handled. Do I need to have some sort of special stream process running somewhere? Can I just store the ips in a db and set them connections up in p...

Seeking a ByteArrayInputStream using java.io

How can I seek (change the position) of a ByteArrayInputStream (java.io)? It is something so obvious, but I can't seem to find a method for this anywhere (mark/reset is not enough, I need to set the position to anywhere on the InputStream). If it can't be done using java.io and I must switch to java.nio and use a ByteBuffer, how can I g...

Streams and Compression

How does something like System.IO.Compression.GZipStream have anychance of working? Doesn't something like GZip need to look at the contents of an entire unzipped file before it can start writing the zip file? Does GZipStream buffer everything before it writes anything? If so, what is the point of implementing the stream? ...