buffer

Line wrapping within emacs *compilation* buffer

Hi, I have a little problem with compiling my project in emacs. The compilation buffer does not line-wrap and I have some very long compile and link commands which I would like to sanity check sometimes. Does anyone know how to force line-wrap on the output added to the compilation buffer, ideally as it is added (a la auto-fill). V...

Reading binary files without buffering the whole file into memory in C++

Hi, In order to make a binary comparer I'm trying to read in the binary contents of two files using the CreateFileW function. However, that causes the whole file to be bufferred into memory, and that becomes a problem for large (500MB) files. I've looked around for other functions that'll let me just buffer part of the file instead,...

Java NIO: reading variable-sized blocks

I would like to read a string from a TCP stream that is given with a byte length followed by the actual data. In Python, I would do length = ord(stream.read(1)) data = stream.read(length) How do I do the same in Java NIO? What I have is a buffer (of capacity 257) stream.read(buffer); // cannot specify a size here int length = buffer....

GNU Screen: files to numbered buffers?

I unefficiently use "^a + ESC SPACE -- SPACE" and "^a + ]". 1. How can I copy a big file to GNU Screen buffer like ^a + : cat big_file > new_buffer ^a + : new_buffer ] 2. How can specify the number for each buffer like ^a + : cat big_file 2> new_buffer_number_2 ^a + 2] ...

GNU Screen: Environment variables

[Updated] The question is related to the questions GNU Screen: Programmers quotes in Readbuf and GNU Screen: files to numbered buffers?. Since they are not solved, the question targets more general concept about environment variables. My belief is that they are the key to make Screen more efficient. 1. How can I use Bash's variables in ...

Does a Java Scanner implicitly create a buffer even if you do not pass it one?

If I have the following example file where each number is represents a byte (123 has bytes 1, 2, and 3): 123456789 Let's say I create a FileInputStream. This reads in the binary byte by byte. So .read() returns 1, then 2, etc. Now let's say I create a buffer. The initial chunk it reads in (if I understand buffers correctly) is 1-5. Th...

Java - is it possible to read a file line by line, stop, and then immediately start reading bytes where I stopped?

I'm having an issue trying to parse the ascii part of a file, and once I hit the end tag, IMMEDIATELY start reading in the bytes from that point on. Everything I know in Java to read off a line or a whole word creates a buffer, which ruins any chance of getting the bytes immediately following my stop point. Is the only way to do this rea...

Buffers and bytes?

Could someone explain to me the uses of using buffers, and perhaps some simple (documented) examples of a buffer in use. Thanks. I lack much knowledge in this area of Java programming, so forgive me if I asked the question wrong. :s ...

How best to handle large buffers in a layered protocol stack?

Hi, I am working on a simple protocol stack for a small embedded system (multidrop, rs485 type stuff). In this stack, losely models after OSI layers: Application Network Datalink physical (serial driver) Each layer has its own header / footer portion that wraps the payload of the layer above it. I will be using my own buffer pool ...

python file-like buffer object

I've written a buffer class that provides a File-like interface with read, write, seek, tell, flush methods to a simple string in memory. Of course it is incomplete (e.g. I didn't write readline). It's purpose is to be filled by a background thread from some external data source, but let a user treat it like a file. I'd expect it to cont...

writing image to directory fail

Hi, Some overflow runtime error happens when my C++ program is trying to write some .png images into a directory. The directory where the images are written into is given as a command line argument. The program is compiled with gcc -ggdb3 -O3. It is strange that the error disappears if I change the directory to another one when rerun...

Vim copy-paste to system buffer not behaving as expected

I'm having a headache trying to figure out why vim isn't copying to a system buffer. Here's my workflow: vim asd y1y :q vim qwe p On computerA and computerB, this works as I want it to: the line yanked from the file asd is put into the file qwe. On computerC, this doesn't work. All systems are running Ubuntu 8.04. computerA has th...

Buffering filtering pipe on Linux

I commonly build up long, multi-command pipes on Linux/Unix to process large text files (sed | grep | sort | less , etc.). I would like to be able to use a pipeline element that would buffer everything received via stdin until a key phrase/string is detected (e.g. "SUCCESS"), at which point it releases everything received up to that poi...

php output buffering callback problem

here is the code ob_start(array(&$dispatcher, 'outputCallback')); include($file); ob_end_flush(); function outputCallback($string) { if(ob_get_level() == 1) { $static =& ParserStatic::getInstance(); return $static->insertToppings($string); } return false; } the problem is when i return $string it b...

Suggestions for a thread safe non-blocking buffer manager

I've created a simple buffer manager class to be used with asyncroneous sockets. This will protect against memory fragmentation and improve performance. Any suggestions for further improvements or other approaches? public class BufferManager { private int[] free; private byte[] buffer; private readonly int blocksize; pu...

manipulating pipe buffer size in C or python

hello, I have a general question about popen (and all related functions), applicable to all operating systems, when I write a python script or some c code and run the resulting executable from the console (win or linux), i can immediately see the output from the process. However, if I run the same executable as a forked process with its ...

How to read and write bits to a byte array

I have a unsigned char buffer, and I'm wondering how I would write and read signed and unsigned bits to this byte buffer. In the Source Engine there is a class named bf_write, which two main methods (used by WriteString, WriteChar, WriteLong, etc.) use two functions named WriteUBitLong and WriteSBitLong. Thanks in advance ...

C++ cin Question...

Okay, I was writing a simple C++ function to combine cin'd strings. I'm working on Linux at the moment, so I don't have the luxury of a simple "getline(cin, input)" command. Here's the code so far: string getLine() { string dummy; string retvalue; do { cin << dummy; retvalue ...

Faster means of checking for an empty buffer in C?

By 'empty buffer,' I mean a buffer full of zeroes. I am searching for a faster method of accomplishing this: int is_empty(char * buf, int size) { int i; for(i = 0; i < size; i++) { if(buf[i] != 0) return 0; } return 1; } I realize I am searching micro optimization unnecessary except in extreme cases, but I know a faster method ...

Help! I get OutofMemory while Retrieving web pages.

I am retrieving the HTML from the web. I get "java.lang.OutOfMemoryError: Java heap space (repl-1:3)" ;; fetch: URL -> String ;; fetch returns the string of the HTML url (defn fetch [url] (with-open [stream (. url openStream)] (let [buffer (BufferedReader. (InputStreamReader. stream))] (apply str (line-seq buffer))))) ...