I want to iteratively read a fixed number of bytes in a file, and return them
My code is below. I have taken it from an example on the internet
File.open('textfile.txt') do |file|
while (buffer = file.read(size)) do
yield buffer
end
end
I get the error no block given.
...
I looked at boost's mapped_file, and CreateFileMapping/MapViewOfFile, but they seem overly complicated to use.
Anything simpler I can use to overwrite a few bytes here and there in an existing file? Performance is not a very high consideration.
...
I am writing a comparefiles subroutine in Perl that reads a line of text from one file (f1) and then searches for it in another (f2) in the normal O(n^2) way.
sub comparefiles {
my($f1, $f2) = @_;
while(<f1>) {
# reset f2 to the beginning of the file
while(<f2>) {
}
}
}
sub someother {
open (one,...
I have massive directories, and I would like to read all the files as fast as I can. I mean, not DirectoryInfo.GetFiles fast, but 'get-clusters-from-disk-low-level' fast.
Of course, .NET 2.0, c#
Similar question was here, but this approach wasn't any good:
http://stackoverflow.com/questions/1941223/c-directory-listing-massive-directo...
I have a program that outputs some lists that I want to store to work with later. For example, suppose it outputs a list of student names and another list of their midterm scores. I can store this output in the following two ways:
Standard File Output way:
newFile = open('trialWrite1.py','w')
newFile.write(str(firstNames))
newFile.wri...
As most other people, I deal with file I/O a lot and I wanted to make sure that I wasn't losing time on reading the file. I currently know of FileReader() as the most efficient way to read files in Java, but I was hoping there would be something obscure that was better.
Also, can you skip reading a line in a file in Java/C?
...
I used this code to read file. But fread function always return 0. What is my mistake?
FILE *file = fopen(pathToSourceFile, "rb");
if(file!=NULL)
{
char aByte[50000];
int ret = fread(aByte, sizeof(aByte), 1, file);
if(ret != 0)
{
not jump into there;
fseek(file, 0, SEEK_SET);
fwrite(aByte, ret, 1...
3 days ago I asked for help in acquiring data from a text file generated by a C program (. Exe).
Thanks to the programmer "second" I solved the problem but yesterday I discovered that the output file is more complex than I had expected. I also ask you help.
The file output is:
V|0|0|0|t|0|1|1|4|11|T4|H13||||||||||||
P|40|0.01...
In MSDN,
String Meaning
\\.\C: Opens the C: volume.
\\.\C:\ Opens the file system of the C: volume.
I could open \\.\C: volume device.
But I couldn't open \\.\C:\ directory by CreateFile.
How can I open the directory by CreateFile with \\.\ prefix.
And if I open the directory, what can I do by using the handle.
Are ...
Hi
I have created these functions which I described in the question. However I think the way I did it is not the optimal way of doing it.
[HttpPost]
public ActionResult Create(FormCollection collection, string schooljaarparam, FlatONASAanbieder foa) {
if (ModelState.IsValid) {
// var r = new List<V...
Out of curiosity, is it possible to implement an interval at which the various events are raised when using the FileSystemWatcher?
Thanks!
...
I get "System.NotSupportedException: The given path's format is not supported. at System.Security.Util.StringExpressionSet" when trying to download an item from an ftp(which have access to). The upload seems to work fine and is done similarly I'll post both functions below:
private void Download(string filePath, string fileName)
{...
Reading lines in a foreach loop, a function looks for a value by a key in a CSV-like structured text file. After a specific line is found, it is senseless to continue reading lines looking for something there. How to stop as there is no break statement in Scala?
...
i am using a text file to store my data records. the data is stored in the following format.
Antony|9876543210
Azar|9753186420
Branda|1234567890
David|1357924680
John|6767676767
Thousands of records are stored in that file. i want to delete a particular record, say "David|1357924680". I am using C, how to delete the particular record e...
My code can be found here http://stackoverflow.com/questions/3604864/c-asp-net-ftp-error
I am trying to download a file from an FTP server when I try to download it it says I do not have access I have been googling this all morning and have not had any luck. I went to the designated folder and added Everyone with full permissions hoping...
I need to detect if a filehandle is using binary mode or text mode - this is required in order to be able to encode/decode str/bytes. How can I do that?
When using binary mode myfile.write(bytes) works, and when in text mode myfile.write(str) works.
The idea is that I need to know this in order to be able to encode/decode the argument ...
The task is to look for a specific field (by it's number in line) value by a key field value in a simple CSV file (just commas as separators, no field-enclosing quotes, never a comma inside a field), having a header in it's first line.
User uynhjl has given an example (but with a different character as a separator):
val src = Source....
I have a script which generates an XML file when the user accesses the link like so:
domain.com/dirList.php
I would like to print the contents of the XML to the user at the end of the POST or GET request (have not implemented this yet). At the moment I am just viewing the link through a web browser.
This is the code I am using to ...
I'm using FileSystemWatcher to check when a file is modified or deleted, but I'm wondering if there is any way to check when a file is read by another application.
Example:
I have the file C:\test.txt on my harddrive and am watching it using FileSystemWatcher. Another program (not under my control) goes to read that file; I would like t...
Currently I use something like:
#include <sys/stat.h>
#include "My_Class.h"
void My_Class::my_function(void)
{
std::ofstream my_file;
struct stat file_info;
if ( filename_str.compare("")!=0 &&
stat(filename_str.c_str(),&file_info) == 0 )
{
my_file.open(filename_str.data(),std::ios::trunc);
//do stuff
my_...