binaryfiles

Bash Script - Read Binary File

I'm new to scripting, but I have a lot of experience programming in languages such as C# and Java. I have a file that contains binary data. I want to write a Bash script that reads the year, month, and day contained in that file so I can sort the associated MOD files into folders according to the date they were recorded. I'm having trou...

Bit aligned reading and writing from binary files

I would like to read and write n bits from/to binary files. For example, read the next n bits into an integer or the next n bits to a char. I need the data to be bit aligned and not byte aligned. Are there C++ libraries that allow me to do that? When I use ostream/istream, I seem to be restricted to using byte aligned data. This is no...

php: recreate and display an image from binary data

Is it possible to recreate images from binary data (process them if needed) and display them, all in the same script? Something like // get and display image 1: $imagedata1 = file_get_contents('assets/test.png'); $imagedata1 = process_using_gd_or_something($imagedata1); echo "<img src={$imagedata1} >"; // <-- IS THIS (OR EQUIVALENT) PO...

Binary files parsing libraries for .NET

Hi. Recently I had a task to make a binary files parser, however it was the first time of using C#/.NET for this kind of problems. It was really simple to parse and extract data from the required binary files because of their simple structure (though I have to say it was unusual rather than the simple way C/C++; also as far as I digged ...

save string array in binary format

string value1 , value1 ; int length1 , length2 ; System.Collections.BitArray bitValue1 = new System.Collections.BitArray(Length1); System.Collections.BitArray bitValue2 = new System.Collections.BitArray(Length2); I'm looking for the fastest way to covert each string to BitArray with defined length for each string (the string should be ...

Which file converter do I write for education, fun and real-world application ?

I am looking for some real-world application task which singlehandedly will give me some programming experience. I am thinking about file format converter but I am not sure about which pair of formats to chose. I would prefer a binary or mixed formats as more trickier ones. Which of existing file format conversion would you suggest to me...

Binary .dat file question in c++

I wanted to shrink the size of a large text file with float values into a binary .dat file, so I used (in c++): // the text stream std::ifstream fin(sourceFile); // the binary output stream std::ofstream out(destinationFile, std::ios::binary); float val; while(!fin.eof()) { fin >> val; out.write((char *)&val,sizeof(float))...

Creating an editor for binary files

I've got a fairly simple binary file format I wish to create an editor for: Able to load the files Able to save the files Allow the user to change the value of the various fields etc Able to convert a file using an older version of the format to a new version Obviously I could just write the thing in C#, Python, etc. etc...However I ...

Reading a binary file in Python: takes a very long time to read certain bytes.

This is very odd I'm reading some (admittedly very large: ~2GB each) binary files using numpy libraries in Python. I'm using the: thingy = np.fromfile(fileObject, np.int16, 1) method. This is right in the middle of a nested loop - I'm doing this loop 4096 times per 'channel', and this 'channel' loop 9 times for every 'receiver', an...

.NET 4.0 Memory Mapped Files Performance

I'd like to know if anyone tried new .NET 4.0 Memory Mapped Files features? I know that they are as old as OS but native handling in .NET is new. Has anyone been able to test this and say something about performance? I'm quite interested in access time to random parts of binary file, write speed and so on. Also performance comparsion ...

What is "Alignment" field in binary formats? Why is it needed?

In ELF file format we have an Alignment field in Segment Header Table aka Program Header Table. In case of Windows PE file format they take it to next level the Sections have two alignment values, one within the disk file and the other in memory. The PE file header specifies both of these values. I didn't understand a thing about this...

C: Writing and Reading a string to and from a binary file.

I want to store strings in a binary file, along with a lot of other data, im using the code below (when i use it for real the strings will be malloc'd) I can write to the file. Ive looked at it in a hex editor. Im not sure im writing the null terminator correctly (or if i need to). when i read back out i get the same string length that i...

Why use binary files ?

Why all use binary files, if all can use XML ? ...

How can I open a binary file in Perl, change ONLY the first byte, and write it back out?

Very similar to Changing one byte in a file in C, but in Perl instead of C. How can I open a binary file in Perl, change ONLY the first byte, and write it back out? ...

Download binary file From SQL Server 2000

I inserted binary files (images, PDF, videos..) and I want to retrieve this file to download it. I used generic handler page as this public void ProcessRequest (HttpContext context) { using (System.Data.SqlClient.SqlConnection con = Connection.GetConnection()) { String Sql = "Select BinaryData From ProductsDownload Wher...

Git checking out problem [fatal: early EOFs]

Dear all, I'm running a Ubuntu (9.10) server with Git (latest from Ubuntu package manager) installed. Access to the Git is via SSH. On windows machines, I'm using Cygwin to push/pull code. I can push my project code onto the server but when I do a clone or pull, it returns a [fatal: early EOFs] error at about 75-80%. Upon further inv...

Reading Binary file in C

Hi All, I am having following issue with reading binary file in C. I have read the first 8 bytes of a binary file. Now I need to start reading from the 9th byte. Following is the code: fseek(inputFile, 2*sizeof(int), SEEK_SET); However, when I print the contents of the array where I store the retrieved values, it still shows me the ...

Java binary files writeUTF... explain specifications...

I'm studying Java on my own. One of the exercises is the following, however I do not really understand what it is asking to.... any smart java gurus out there that could explain this in more detail and simple words? Thanks Suppose that you have a binary file that contains numbers whos type is either int or double. You dont know the orde...

What's the best way to read/write array contents from/to binary files in C#?

I would like to read and write the contents of large, raw volume files (e.g. MRI scans). These files are just a sequence of e.g. 32 x 32 x 32 floats so they map well to 1D arrays. I would like to be able to read the contents of the binary volume files into 1D arrays of e.g. float or ushort (depending on the data type of the binary file...

editing a file with vim that has no EOL marker on the last line but has CRLF line endings

I often have to edit script files, the interpreter for which treats files that have an EOL marker on the last line of the file as an error (i.e. the file is treating CRLF as "newlines", not as "line endings"). Currently, I open these files in Vim using binary mode (-b on the command line). It autodetects the lack of EOL on the final li...