Advertising (This ad goes away for registered users. You can Login or Register)

How can one "create" a file format?

Programming on your favorite platform, for your favorite platform? Post here
Locked
Nickolas
Posts: 174
Joined: Sat Jan 22, 2011 3:14 pm
Location: In a black hole...

How can one "create" a file format?

Post by Nickolas »

How can one create a file format? I am currently writing a mini programming language and my own tiny VM for learning purposes. I am interested in creating my own file format for the executables. Up to now, I have been using the BinaryWriter class and I would first create a new file, write a magic number to recognize the executable and then the instructions. Then I would use BinaryReader in the VM and instead of write, I read stuff. Now, I am interested in creating a completely new file format... How would you approach that?

P.S. This isn't really a programming question, but I found no other suitable section. Feel free to move it.
Advertising
Image
Image
Image
Image
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: How can one "create" a file format?

Post by m0skit0 »

Well you kind of can think about it as a programming question, but I don't understand what you mean exactly... To create a file format, you define its format first, then you might also want to generate some examples to process.
Advertising
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
Nickolas
Posts: 174
Joined: Sat Jan 22, 2011 3:14 pm
Location: In a black hole...

Re: How can one "create" a file format?

Post by Nickolas »

m0skit0 wrote:Well you kind of can think about it as a programming question, but I don't understand what you mean exactly... To create a file format, you define its format first, then you might also want to generate some examples to process.
That's what I meant. How can I define it? XML? Or just have the assembler write the code according to a definition?
Image
Image
Image
Image
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: How can one "create" a file format?

Post by m0skit0 »

I still don't understand. If it's your own file format, then it cannot be XML because XML already exists as a file format... Maybe what you mean is what format would be more suitable to your needs?
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
Nickolas
Posts: 174
Joined: Sat Jan 22, 2011 3:14 pm
Location: In a black hole...

Re: How can one "create" a file format?

Post by Nickolas »

m0skit0 wrote:I still don't understand. If it's your own file format, then it cannot be XML because XML already exists as a file format... Maybe what you mean is what format would be more suitable to your needs?
Know, I meant how can I define it, so that my program can write instructions in order, according to the format. Should I use XML for defining it? I really have no idea. I could to it on a piece of paper and then tell my program to write the instructions accordingly, but I want it to automatically recognize the order so that I can change it later on.
Image
Image
Image
Image
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: How can one "create" a file format?

Post by m0skit0 »

Oh yes, XML could be a good idea. Just keep in mind XML has no defined order, that is:

Code: Select all

<this>
    <is />
    <an />
    <example/>
</this>
is the same XML as

Code: Select all

<this>
    <example />
    <an />
    <is/>
</this>
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
Nickolas
Posts: 174
Joined: Sat Jan 22, 2011 3:14 pm
Location: In a black hole...

Re: How can one "create" a file format?

Post by Nickolas »

Nice I can use that. :) I'll look it up a bit. Thanks.
Image
Image
Image
Image
Locked

Return to “Programming”