file-io

C++ reading in specific segments of data from a file redirected to my program

I'm working on a program that takes a redirected file as input. For example, if my program was called foo I would call the program with ./foo < input.txt. The files I'm running through my program are supposed to be formatted with a single integer on the first line, two integers on the second line. So something like 3 1 8 I'm finding t...

C#'s FileStream opening file with write privileges?

Hey all, I'm attempting to read a binary file and I keep getting errors on 64-bit systems where it appears that the file is being open with write privileges and thus throws an error when placed in a secure folder (Program Files in 64 bit Windows). I can duplicate this error on my system (XP, 32 bit) by setting the folder containing the...

Catching errors when downloading massive files via PHP

I am attempting to download fairly large files (up to, possibly over 1GB) from a remote HTTP server through a PHP script. I am using fgets() to read the remote file line by line and write the file contents into a local file that is created through tempnam(). However, the downloads of very large files (several hundred MB) are failing. Is ...

C: File output stops at 524,0 kb

Hello, I'm writing a brute-force program for enumerating a certain kind of integer sequence (not important what this sequence actually is). In order to get my results, I create a file and I'd like to write all program output to this file. However, it seems that the file "stagnates" at 524 kb even if the program should write something i...

Access external config file from J2EE app

I have to access a config file which is in a directory on the app server file system, but is not deployed as part of my J2EE app. Would getResourceAsStream() help me in this case? Thanks ...

How can I test if I can write to a filehandle?

I have some subroutines that I call like this myWrite($fileName, \@data). myWrite() opens the file and writes out the data in some way. I want to modify myWrite so that I can call it as above or with a filehandle as the first argument. (The main reason for this modification is to delegate the opening of the file to the calling script ...

Erlang File I/O: Large binary files and gzip streaming

I have two questions regarding Erlang file i/o; what is the best way to achieve in Erlang: reading large binary files (many gigabytes) without copying the whole file into memory reading a gzipped binary file as a decompressed stream Thanks! ...

FileInputStream is Null?

Okay, so this is the line that's returning null. What am I doing wrong while creating this FileInputStream? FileInputStream fin = new FileInputStream(new File(getClass().getResource("data/levellocks.lv").toURI())); ...

Deleting a file using delete() - Java

All, My code makes use of BufferedReader to read from a file [main.txt] and PrintWriter to write to a another temp [main.temp] file. I close both the streams and yet I was not able to call delete() method on the File object associated with [main.txt]. Only after calling System.gc() after closing both the stream was I able to delete the ...

How can I read the contents of a file into a list in Lisp?

I want to read in the contents of a file into a list. Some of my attempts so far have been - (defun get-file (filename) (let ((x (open filename))) (when x (loop for line = (read-line x nil) while line do (list line))) (close x))) (defun get-file (filename) (let ((x (open filename :if-does-not-exist nil)) (content...

Regular expression isn't found in line: execution just hangs.

Hello all! I am new to python (and this site); I am trying to write a script that will use a regular expression to search through a given file to find a name. I have to print out the different ways the name was capitalized and how many times the name was found. My current code will just print out my first flag and then hang. I don't know...

How to get the Directory name/path from an opened handle.

On opening a directory via zwopenfile(open directory option), it returns a handle for the directory path. Now I need to get the directory path from the handle. Its my requirement. I could see an example(please see the code below) where file name can be fetched from file handle. But the below example does not help for directory. Is ther...

Delphi 2010: How to save a whole record to a file?

I have defined a record which has lots of fields with different types (integer, real , string, ... plus dynamic arrays in terms of "array of ..."). I want to save it as a whole to a file and then be able to load it back to my program. I don't want to go through saving each field's value individually. The file type (binary or ascii or .....

Performance issues when reading a file from HD that dosen't follow computer byte alignments

I have a file format (.STL, stereo lithography, the structure is standard and can not be changed. Not to be confused with standard template library) that uses a 50 byte data structure. Reading from the HD directly leads to wrong data being read as 50 bytes is not a multiple of 4. Out of the entire 50 byte structure, I only need 36 of th...

Reading a binary file as text and manipulating it... [C#] Versus [VB.NET]

Well guys I am in a bit of a pickle here... I am doing some exercises on encrypting data. One of them are binary files. I am currently using triple DES to encrypt and decrypt the files both in VB.NET and C#... Now the thing is, once it is decrypted in VB.NET and saved, i can execute it again... But for some reason, my C# file is bigge...

size_t or long for the size of a string containing a file?

Suppose I want to read an entire file in memory. I'd open it in binary mode, use fseek to get to the end of the file, then do ftell to get its size. Then I would allocate a string with the same size as the file, and just read it in, right? The problem is that ftell returns a long int, and malloc should receive a size_t argument. Now, si...

Alternative to File.exists() in Java

I never thought it would happen to me, but I ran into my first bug in Java: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5003595 I'm pretty much in the same exact situation as described in the bug (NFS on linux), and I'm seeing that File.exists() is not returning the correct value (at least not right away). So my question is, is...

Writing a string to disk in OPENSTEP (YellowBox)

I'm debugging an old OPENSTEP (YellowBox) app, written in Objective-C, running on Windows 2000, built with Project Builder. The only easy way I can find to write a string to disk in Obj-C is [NSString writeToFile], a Cocoa/iOS-era method which doesn't seem to have been written yet in the version of OPENSTEP that I'm compiling against (us...

assembler write to file problem

dseg segment FileName db "hex.txt$" dseg ends cseg seg.. ... wrFile proc push ax bx cx dx mov ax,3D00h mov dx, offset fileName int 21h mov bx,ax mov cx,10*type scores mov dx,offset highscoresnum mov ah,40h int 21h mov dx,offset highscoresdate mov ah,40h int 21h mov ah,3eh int 21h pop dx cx bx ax ret wrFile endp at the f...

Bash read/write file descriptors -- seek to start of file

I tried to use the read/write file descriptor in bash so that I could delete the file that the file descriptor referred to afterward, as such: F=$(mktemp) exec 3<> "$F" rm -f "$F" echo "Hello world" >&3 cat <&3 but the cat command gives no output. I can achieve what I want if I use separate file descriptors for reading and writing: ...