1
голосов
1ответов
160 просмотров

Network File Streaming Performance Vista

How can I achieve the best file streaming performance in Vista? My goal is to read a large file (several hundred MB) over the network directly into memory. I've allocated a memory block the same size as the file. This is also my destination buffer. I've tried ReadFile, _read, fread, ifstream::re...

3
голосов
3ответов
2532 просмотров

syncing iostream with stdio

I am trying to add iostream to the legacy code and thus want to sync those two libraries. According to this article, I should use std::ios_base::sync_with_stdio. Now, I wonder how it is used in practice (examples please), side-effects I should be aware of. Thx

33
голосов
8ответов
121536 просмотров

How to update/modify an XML file in python?

I have an XML document that I would like to update after it already contains data. I thought about opening the XML file in "a" (append) mode. The problem is that the new data will be written after the root closing tag. How can I delete the last line of a file, then start writing data from that ...

1
голосов
3ответов
375 просмотров

programs running in parallel, read/writing in C

I'm considering a set of 4 programs: (Prog1, Prog2, Prog3, Prog4) interacting with 4 files (FileA, FileB, FileC, FileD) Prog1: writes (appends) to FileA Prog2: reads File A and writes (appends) to FileB Prog3: reads File A, and writes (appends) to FileC Prog4: reads File B, and writes (appends)...

57
голосов
4ответов
47571 просмотров

Difference between the access modes of the `File` object (ie. w+, r+)

When using files in Ruby, what is the difference between the r+ and w+ modes? What about the a+ mode?

1
голосов
2ответов
11220 просмотров

Read In Hex Values (C)

I am currently attempting to read in Hex values from a text file. There can be multiple lines of Hex's and each line can be as long as needed: f53d6d0568c7c7ce 1307a7a1c84058 b41af04b24f3eb83ce Currently, I put together a simple loop to read in the Hex values into an unsigned char lin...

3
голосов
1ответов
2218 просмотров

Java Web Start: How to write files to windows UNC Path?

I have an Java application for copying large amounts of data from users' workstations to a server. The java.io.File class is supposed to work with UNC paths very well and in fact it does but only when I run the app in standard execution model. When the application is launched via Web Start I get...

2
голосов
1ответов
4924 просмотров

BASH script passing stdin input to a program and giving control back to user input

(I looked everywhere for this, perhaps my googling skill is off today) I have a program that requires a handful of initialization cmds from stdin (and not through arguments). It'd be nice to move those commands into a script so when the script completes I can start keying the real work. So somet...

0
голосов
2ответов
50 просмотров

What is the standard way to handle users opening incorrect file types?

I hope my Q was clear ... I am curious about the typical way to code for someone clicking File|Open, and selecting a file that is inappropriate for the program--like someone using a word processing program and trying to open a binary file. In my case, my files have multiple streams streamed tog...

7
голосов
4ответов
7536 просмотров

Java multithreading reading a single large file

What is an efficient way for a Java multithreaded application where many threads have to read the exact same file (> 1GB in size) and expose it as an input stream? I've noticed that if there are many threads (> 32), the system starts to contend over I/O and has a lot of I/O waits. I've co...

5
голосов
4ответов
4888 просмотров

C# Get the difference between two files and use it for incremental backup

I want to create my own incremental backup solution using C#. How can I obtain the difference between two files (version 1 and version 2 of ABC.TXT) and then update ABC.TXT version 1 with the difference? Would appreciate some hints! Thank you!

0
голосов
2ответов
491 просмотров

Creating files on AppEngine

I'm trying to store some data in a binary file: import os, pickle o = some_object() file = open('test', 'wb') #this causes the error pickle.dump(o, file) file.close() I get this error: IOError: invalid mode: wb It doesn't work (neither on test server or GAE itself), apparantly because it doe...

1437
голосов
13ответов
1692259 просмотров

Looping through the content of a file in Bash

How do I iterate through each line of a text file with Bash? With this script: echo "Start!" for p in (peptides.txt) do echo "${p}" done I get this output on the screen: Start! ./runPep.sh: line 3: syntax error near unexpected token `(' ./runPep.sh: line 3: `for p in (peptides.txt)' (L...

10
голосов
6ответов
3520 просмотров

Segmentation fault question

I have observed that sometimes in C programs, if we have a printf in code anywhere before a segmentation fault, it does not print. Why is this so?

2
голосов
2ответов
871 просмотров

Probing for filesystem block size

I'm going to first admit that this is for a class project, since it will be pretty obvious. We are supposed to do reads to probe for the block size of the filesystem. My problem is that the time taken to do this appears to be linearly increasing, with no steps like I would expect. I am timing ...

9
голосов
3ответов
716 просмотров

What is in simple words blocking IO and non-blocking IO?

How would you explain a simple mortal about blocking IO and non-blocking IO? I've found these concepts are not very clear among many of us programmers.

0
голосов
2ответов
1637 просмотров

How to get the compressed image data from JPEG encoder in Java

I want to compress an image using JPEG encoder and instead of writing it to a file I want to pass the compressed data to another application. My problem is that I can compress the data but don't know how to get that compressed image data. I am using this code : out = new FileOutputStream ( file...

1
голосов
1ответов
494 просмотров

Combining Multiple Files Into Single Archive (Silverlight/C#)

In Silverlight one does not have access to the entire .NET Library and therefore I am considering the best way to get the functionality I would have courtesy of System.IO.Packaging. I have multiple text files and I want to combine them into a single archive. Compression is not important but cou...

1
голосов
2ответов
1161 просмотров

Splitting huge file based on contents with ruby

Disclaimer: I'm not a programmer, never was, never learned algorithms, CS, etc. Just have to work with it. My question is: I need to split a huge (over 4 GB) CSV file into smaller ones (then process it with require 'win32ole') based on the first field. In awk it's rather easy: awk -F ',' '{myfi...

2
голосов
1ответов
3747 просмотров

What is SQLite3 Disk I/O Error in Cocoa

I am programming in snow Leopard 10.6. My application opens up a locally stored database successfully, but when it tries to insert into the database, I continue to receive 'Disk I/O error". Anyone has any ideas as to what could possibly cause this? Thanks Yang

2
голосов
3ответов
183 просмотров

Casting an mmapped ByteString to other types?

I realize this may be a rather heretical question, but I wonder whether I can mmap a file of data, via System.IO.Posix.MMap, and then cast the resulting ByteString into a strict array of some other type? Eg. if I know that the file contains doubles, can I somehow get this mmapped data into an UAr...

5
голосов
4ответов
1127 просмотров

How to structure Haskell code for IO?

I'm trying to learn Haskell, so I decided to write a simple program to simulate the orbits of the planets around the sun, but I've run into a problem with printing out coordinates from the simulation, the top level function in my code is the following: runSim :: [Body] -> Integer -> Doubl...

81
голосов
2ответов
49465 просмотров

Buffered vs unbuffered IO

I learned that by default I/O in programs is buffered, i.e they are served from a temporary storage to the requesting program. I understand that buffering improves IO performance (maybe by reducing system calls). I have seen examples of disabling buffering, like setvbuf in C. What is the differ...

2
голосов
4ответов
2249 просмотров

Reading previous line of file with Ruby

How to read the prevous line of a file. The opposite of IO.gets.I initially thought to set IO.lineno to the line number I wanted to read but that doesn't work as expect. How do you actually read the previous line?

1
голосов
1ответов
865 просмотров

Reading previous line of file with Ruby

Using Ruby, I am reading a file line by line, using IO.gets to incrementally read the next line of the file. Under certain circumstances I want to do the opposite (look at the previous line by decrementing). The way I tried to accomplish this was... IO.lineno = int IO.gets It seems that no mat...

5
голосов
1ответов
11454 просмотров

How do I read formatted input in Java?

Suppose my input file contains: 3 4 5 6 7 8 9 10 I want to run a while loop and read integers, so that I will get 3,4,5,6,7,8 and 10 respectively after each iteration of the loop. This is really simple to do in C/C++ but not in Java... I tried this code: try { DataIn...

30
голосов
5ответов
15859 просмотров

Why Java OutputStream.write() Takes Integer but Writes Bytes

I am writing an OutputStream, just noticed this in the OutputStream interface, public abstract void write(int b) throws IOException; This call write one byte to the stream but why it takes integer as an argument?

0
голосов
1ответов
874 просмотров

How can I use Directory.GetFiles skipping UnauthorizedAccessException?

When I use System.IO.Directory.GetFiles method in C:\, an error is raised: Access to the path 'c:\System Volume Information' is denied. How can I handle that?

188
голосов
9ответов
158446 просмотров

Do I need to close() both FileReader and BufferedReader?

I'm reading a local file using a BufferedReader wrapped around a FileReader: BufferedReader reader = new BufferedReader(new FileReader(fileName)); // read the file // (error handling snipped) reader.close(); Do I need to close() the FileReader as well, or will the wrapper handle that? I've see...

0
голосов
2ответов
1929 просмотров

How to retrieve and download server files (File.Exists and URL)

I have a database table where the user marks files to be downloaded. Subsequently, I browse this table and need to create a fileList to pass to an ActiveX downloader. My routine works locally and on the server for ONLY the first file. I know my logic must be bad, but I cannot find it. All of...