files

Directory walker on modern operating systems slower when it's multi-threaded?

Hello! Once I had the theory that on modern operating systems multithreaded read access on the HDD should perform better. I thought that: the operating system queues all read requests, and rearranges them in such a way, that it could read from the HDD more sequentially. The more requests it would get, the better it could rearrange the...

HID Mouse position Linux Kernel Source Code

Hi all, I want to work on HID Mouse events. Which linux kernel module shall I work on to handle the events? And then pass those events (x,y) to input subsystem. The modules can be hid-core.c / usbhid hid-quirks.c or hiddev.c I have all the kernel source code and am able to add in my kernel. Output: lsmod | grep hid myus...

Deleting duplicate lines in a file using Java

As part of a project I'm working on, I'd like to clean up a file I generate of duplicate line entries. These duplicates often won't occur near each other, however. I came up with a method of doing so in Java (which basically made a copy of the file, then used a nested while-statement to compare each line in one file with the rest of the ...

Reliable File.renameTo() alternative on Windows?

Java's File.renameTo() is problematic, especially on Windows, it seems. As the API documentation says, Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a f...

How do I concatenate files in Python?

I have multiple (between 40 and 50) MP3 files that I'd like to concatenate into one file. What's the best way to do this in Python? Use fileinput module to loop through each line of each file and write it to an output file? Outsource to windows copy command? ...

Problems with BufferedReader / PrintWriter?

I'm using BufferedReader and PrintWriter to go through each line of an input file, make a change to some lines, and output the result. If a line doesn't undergo a change, it's just printed as is to the output file. For some reason however, the process ends prematurely. The code looks something like this: BufferedReader in = new Buffered...

How does the OS know what to do with a file when the "Open With..." option is selected?

Explanation: I don't remember about Linux and I don't know about OS X, but in Windows you can right-click a file and select a program to open it. But how does the OS know exactly how to make the program open it? Does it keep track of the "Open file" dialogs the program has? Does the developer have to specify a special event handler or so...

How to tell whether a file system object is a path or a directory

Possible Duplicate: .NET How to check if path is a file and not a directory? Hi, Can anyone think of a good way of telling whether a file system object path equates to a a file or a directory? I did have the following method: public static bool PathIsFile(this string fullPath) { return (Path.GetExtension(fullPath).Length ...

Modify file content programatically

I have to modify a text in a file programatically with C#. What's the best way to do this and avoid rewriting the entire file content. I want to edit only some words and save it. ...

Lookup and combine data in Python

I have 3 text files many lines of value1<tab>value2 (maybe 600) many more lines of value2<tab>value3 (maybe 1000) many more lines of value2<tab>value4 (maybe 2000) Not all lines match, some will have one or more vals missing. I want to take file 1, read down it and lookup corresponding values in files 2 & 3, and write the output as -...

Who owns a file handle in windows?

How do you discover which process has an open handle on a file? Specifically, how do you do this programmaticly? ...

Most efficient idiom to read one integer only from a file?

In trying to resolve Facebook's Puzzle "Hoppity Hop", http://www.facebook.com/careers/puzzles.php?puzzle_id=7, I'm reading one integer only from a file. I'm wondering if this is the most efficient mechanism to do this? private static int readSoleInteger(String path) throws IOException { BufferedReader buffer = null; int integer = 0; ...

How to split jQuery plugin over multiple files

I'm writing a small CMS as a jQuery AJAX plugin and though it's by no means excessively long (currently about 500 lines) I can see it would be nice to be able to split it into separate files, one for each "subclass": (function($) { $.fn.myCMS = function() { this.classOne = function() { ... } this.classTwo = function() { ... ...

How to send files over tcp with TcpListener/Client? SocketException problem

I'm developing a simple application to send files over TCP using the TCPListener and TCPClient classes. Here's the code that sends the file. Stop is a volatile boolean which helps stopping the process at any time and WRITE_BUFFER_SIZE might be changed in runtime (another volatile) while (remaining > 0 && !stop) { DateTime current = D...

how to get number of sub files in PHP?

[root@file nutch-0.9]# ls resume/ crawldb index indexes linkdb segments like the above example, how to get number of sub files(can be file or directory) in PHP? ...

Difference in writing string vs. char array with System.IO.BinaryWriter

I’m writing text to a binary file in C# and see a difference in quantity written between writing a string and a character array. I’m using System.IO.BinaryWriter and watching BinaryWriter.BaseStream.Length as the writes occur. These are my results: using(BinaryWriter bw = new BinaryWriter(File.Open(“data.dat”), Encoding.ASCII)) { stri...

How to get X newest files from a directory in PHP?

The code below is part of a function for grabbing 5 image files from a given directory. At the moment readdir returns the images 'in the order in which they are stored by the filesystem' as per the spec. My question is, how can I modify it to get the latest 5 images? Either based on the last_modified date or the filename (which look li...

How to create a temporary text file in c++?

Hi, I'm trying to create a temporary text file in c++ and then delete it at the end of the program. I haven't had much luck with google. Could you tell me which functions to use? Thanks. edit: The answers below tell me how to create a temp file. What if I just want to create a file (tmp.txt) and then delete it? How would I do that?...

Read file into array

I have a file of words/phrases separated by newlines. I need to get the file and read each word/phrase into the array. I have this so far: NSFileHandle *wordsFile = [NSFileHandle fileHandleForReadingAtPath:[[NSBundle mainBundle] pathForResource:@"WordList" ofType:nil]]; NSData *words = [w...

Can I avoid handling a file twice if I need the number of lines and I need to append to the file?

I am writing a file to disk in stages. As I write it I need to know the line numbers that I am writing to use to build an index. The file now has 12 million lines so I need to build the index on the fly. I am doing this in four steps, with four groupings of the value that I am indexing on. Based on some examples I found elsewhere on ...