io

Faster I/O in C

Hi, I have a problem which will take 1000000 lines of inputs like below from console. 0 1 23 4 5 1 3 5 2 56 12 2 3 33 5 ... ... I have used scanf, but it is very very slow. Is there anyway to get the input from console in a faster way? I could use read(), but I am not sure about the no of bytes in each line, so I can not as read() t...

Is there an equivalent of BufferedReader.readLine() that lets me pick what my end of line characters are?

The Javadoc for BufferedReader.readLine() says: A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. I need slightly better control than this (e.g. I would like to be able to specify that an end of line is "\r\n", so that an "\n"...

How to load all files from a directory?

Like the title says; how do I load every file in a directory? I'm interested in both c++ and lua. Edit: For windows I'd be glad for some real working code and especially for lua. I can do with boost::filesystem for c++. ...

What's the difference with buffered synchronous I/O and asynchronous I/O?

When using a synchronous I/O such as fread which is buffered, the read operations are postponed and combined, I think that isn't done synchronously. So what's the difference between a buffered synchronous I/O and an asynchronous I/O? ...

C nonblocking IO on Linux

How do you do nonblocking console IO on Linux/OS X in C? ...

How to compute accurately the time it takes a Java program to write or read a file ?

How to compute accurately the time it takes a Java program to write or read a number of bytes from/to a file ? It is really important that the time is being measured accurately. (The time should be computed by the program itself). ...

Should I use DataInputStream or BufferedInputStream

I want to read each line from a text file and store them in an ArrayList (each line being one entry in the ArrayList). So far I understand that a BufferedInputStream writes to the buffer and only does another read once the buffer is empty which minimises or at least reduces the amount of operating system operations. Am I correct - do I...

lib to read a DVD FS (data disc)

I am thinking i might want to port a lib to read a DVD filesystem. I am not talking about movies but datadisc. Theres existing code for me to do raw reads from the disc. I need code that request this data and allow me to browse files on the disc. What lib can i use for this? -edit- NOTE: I am using an OSless hardware. Ppl seem to miss t...

Copy files with double credentials (windows)

Assume we have c:\DirA that can be read by User1 only, and c:\DirB that can be written by User2 only. Both credentials are know. How can I copy files from DirA to DirB directly? ...

Reading an input file in C++

I would like to read an input file in C++, for which the structure (or lack of) would be something like a series of lines with text = number, such as input1 = 10 input2 = 4 set1 = 1.2 set2 = 1.e3 I want to get the number out of the line, and throw the rest away. Numbers can be either integers or doubles, but I know when they are one o...

Win32 Overlapped I/O - Completion routines or WaitForMultipleObjects ?

I'm wondering which approach is faster and why ? While writing a Win32 server I have read a lot about the Completion Ports and the Overlapped I/O, but I have not read anything to suggest which set of API's yields the best results in the server. Should I use completion routines, or should I use the WaitForMultipleObjects API and why ? ...

Haskell streams with IO effects

Consider the following Haskell program. I am trying to program in a "stream style" where functions operate on streams (implemented here simply as lists). Things like normalStreamFunc work great with lazy lists. I can pass an infinite list to normalStreamFunc and effectively get out another infinite list, but with a function mapped ont...

How to quickly check if folder is empty (.NET)?

Hello. I have to check, if directory on disk is empty. It means, that it does not contain any folders/files. I know, that there is a simple method. We get array of FileSystemInfo's and check if count of elements equals to zero. Something like that: public static bool CheckFolderEmpty(string path) { if (string.IsNullOrEmpty(path))...

Streams in java

hello everyone well, i am developing a single server multiple-client program in java. My problem is can i use single stream for all the clients or do i have to create a seperate stream for each client? please help thank you ...

How to understand asynchronous io in Windows?

1.How to understand asynchronous io in Windows?? 2.If I write/read something to the file using asynchronous io : WriteFile(); ReadFile(); WriteFile(); How many threads does the OS generate to accomplish these task? Do the 3 task run simultaneously and in multi-threading way or run one after another just with different order? 3.Ca...

Why does IO.Path.Combine only take 2 arguments?

I'm surprised there's not an overload that can take a string array. Anyway, what is the best way to avoid nesting calls to Path.Combine? pathValue = Path.Combine(path1, Path.Combine(path2, Path.Combine(path3, path4))) This seems inefficient since it results in 4 new strings being created just to get 1. ...

Java: File.toURL() deprecated?

Why is the function java.io.File.toURL() deprecated? I need to pass an URL to Toolkit.createImage() which accepts a URL object. Javadoc recommends me to use File.toURI().toURL(). However: C:\Documents and settings\Administrator\... becomes: C:\Documents%20and%20settings\Administrator\... which obviously is an invalid file location. I...

fstream replace portion of a file

When I do fstream someFile("something.dat", ios::binary|ios::out); someFile.seekp(someLocation, ios::beg); someFile.write(someData, 100); It seems to replace the entire file with those 100 bytes instead of replacing only the appropriate 100 bytes, as if I had specified ios::trunc. Is there a portable way to not have it truncate the f...

Is GHC able to tail-call optimize IO actions?

Will GHC perform tail-call optimization on the following function by default? The only weird thing about it is that it is recursively defining an IO action, but I don't see why this couldn't be TCO'd. import Control.Concurrent.MVar consume :: MVar a -> [a] -> IO () consume _ [] = return () consume store (x:xs) = do putMVar store x ...

Delete Content of a File in Java

Hi, I'm writing bytes to temp.fls file. After completing the operation, I want to delete the last 256 bytes from the temp.fls file. How can I achieve this? Please help me. Thanks in advance. ...