473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Insert EOF marker into file

Hi

I have decompression function which opens compressed input file,
grabs the header containing the original file size and the date compressed
and
starts decompressing data into output file....
Because of the padding, decompessed file may be larger than original by up
to 7 bytes....
What I want to do is to insert EOF at the position == original file size
into output file...
So after processing I want to do

// set the position in output file to original file size
fseek(out_file, orig_size, SEEK_SET);
// write EOF in that position
// ???????????????????????????????? fwrite maybe???
// close output file
fclose(out_file);
Question is how do I "inject" EOF at the position i want....What is the code
for it???

Thanks
zambak
Nov 13 '05 #1
2 5877
zambak wrote:
Hi

I have decompression function which opens compressed input file,
grabs the header containing the original file size and the date compressed
and
starts decompressing data into output file....
Because of the padding, decompessed file may be larger than original by up
to 7 bytes....
What I want to do is to insert EOF at the position == original file size
into output file...
So after processing I want to do


Some systems may have ftruncate(), but it is not standard C.

Best bet is to not write more than the length of file that you want.

-- glen

Nov 13 '05 #2
# Question is how do I "inject" EOF at the position i want....What is the code
# for it???

There is no C standard for reducing the size of an existing file. If you
create a new file, the operating system of any quality will not allocate
much more space than the highest offset you write.

Why are you decompressing into a file? You're going to destroy whatever
is in the file from where you start writing. You can accomplish the same
in standard C by openning what was the output as input, open a new output file,
copy the initial portion. (If the decompression write starts at the beginning,
you actually don't even have an initial portion to copy.)

--
Derk Gwen http://derkgwen.250free.com/html/index.html
You face forward, or you face the possibility of shock and damage.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Haines Brown | last post by:
I have a table with three columns, and I want the data in the first column to align left, while that in the remaining columns to align right: #testTable { text-align: right; } #leftcol {...
24
by: pristo | last post by:
hello All, how can i insert unique ID into binary file (that created by compiler)? (so after compiling i can to identify the src that i use) thx
1
by: Wannabe_Geek | last post by:
Do we have something in ASP.net like freemarker for java.(freemarker.sourceforge.net) The idea is to use simple HTML file as template for the site and replace the Marker tags with appropriate...
7
by: Kevin Lawrence | last post by:
Hi all I want to do "INSERT INTO Table (Blob) Values('blobdataasstring')". ...rather than using the parameter driven method, is it possible? And if so what encoder do I use to convert the...
0
by: geniet | last post by:
Hello all of you, I am looking for a program where I can add and edit the APP3 marker according to jps format (if needed Python/PIL can be used). The setup of the APP3 marker comes from this...
7
by: james | last post by:
Hi, I am trying to insert a record into a database table, one field of which is a byte array. Using the below: Byte imgArr; .... <code to put image into imgArr>
17
by: beginner | last post by:
Hi All, This is just a very simple question about a python trick. In perl, I can write __END__ in a file and the perl interpreter will ignore everything below that line. This is very handy...
2
by: philmasterplus | last post by:
I am trying to create a simple file encoder (obfuscator) class using the XOR(^) operator. I am using objects of the class ifstream and ofstream to input/output to the file. Right now, I am...
2
by: flymo | last post by:
Hello All, Hopefully this is the correct forum... I have some code that creates a text (dat) for a billing process created in Access2000, I add an Eof of Line marker to each line item and then...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.