Archiving help

This is a discussion on Archiving help within the C Programming forums, part of the General Programming Boards category; I need to write a simple archiving program in C. It must be able to read in one or more ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    2

    Archiving help

    I need to write a simple archiving program in C. It must be able to read in one or more files and output them in a single file. I must then be able to extract the files to the same directory as they were in before. I am able to read files using 'read' and 'fread' and also write files, but i can only do these things with one file at a time.

    Any help would be greatly appreciated

    Thank you

  2. #2
    Registered User \007's Avatar
    Join Date
    Dec 2010
    Posts
    179
    Have you checked out zlib? zlib Home Site

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    Perhaps you need help with reading the command line
    Cprogramming.com FAQ > Accessing command line parameters/arguments

    So you can do say
    myprog myarchive file1 file2 file3
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by smoothjammy1 View Post
    I need to write a simple archiving program in C. It must be able to read in one or more files and output them in a single file. I must then be able to extract the files to the same directory as they were in before. I am able to read files using 'read' and 'fread' and also write files, but i can only do these things with one file at a time.

    Any help would be greatly appreciated

    Thank you
    First off, you should give this your best shot on your own... Get it as far as you can then when you get stuck post up your code and we'll see what we can accomplish....

    Basically an archive is just a big file that, in this case, contains the contents of other files. To do this you will need to design a header system, essentially a linked list just like in memory except using the file position instead of memory pointers as your linking reference. The headers can be a simple struct... previous header, file path, file size, next header. In the archive file itself you write a header, the file contents, the next header, file contents, header, contents etc. From there it's just like adding, reading, etc. with a linked list.

  5. #5
    Registered User
    Join Date
    Jan 2011
    Posts
    2

    C Archiving help

    Thanks for the speedy reply, will give it my best shot...

    SJ1

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. open-source or free archiving library
    By silos1985 in forum C++ Programming
    Replies: 2
    Last Post: 01-27-2010, 07:07 AM
  2. Testers wanted - archiving tool.
    By cboard_member in forum Game Programming
    Replies: 25
    Last Post: 08-31-2006, 06:12 AM
  3. Looking for some archiving utility
    By lobo in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-29-2003, 03:28 AM
  4. Archiving My Copies Of Linux
    By Troll_King in forum Linux Programming
    Replies: 11
    Last Post: 08-22-2002, 10:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21