Hello all, recently got a piece of coursework I completely know nothing of. It is shown below:

Your task is to write a file archive utility similar to that of the Unix tar program. This program will be a command line
program (i.e. there will be no graphical user interface). The purpose of this file archive utility is to allow users and
system administrators alike to back up specific parts of their Linux file system into a single file. Backing up file
systems in this way is common practice and especially useful in disaster/recovery scenarios where the resulting file can
be taken away on a removable media (typically a magnetic tape).
The implementation of this software, at every stage, must include methods for checking and handling errors.

Write a file archive utility which can:
1. Archive one or more files (each specified at the commend line) into a file.
2. Extract all of the files contained in the archive (specified on the command line) in to the current working
directory.

Would anybody be able to assist me?

How would you do this on paper? Let's say that I give you two numbers (in decimal or hex, whichever you prefer to think about), and I ask you to write them down as ONE number, in such a way that you'd also be able to separate them out again when I ask you to, and all you can write down as the single number is numbers (no colours or squiggly lines - just numbers, all together).

Welcome to programming. All that other stuff is just memorising syntax. Programing is the art and craft of thinking about problems in such a way that the solution lends itself to a programmatic implementation. Programming is thinking about problems, so think about this one.

Edited 3 Years Ago by Moschops

I would suggest that you break the problem down into smaller pieces.

  • have part of the program identify the files you will archive. The assignment states that they will be given on the command line.
  • read the names from the command line and put them into some sort of directory in the archive file.
  • some check that proves that each command argument actually is a file (say open/fopen) that you can read.
  • some way to tell files in the archive apart (length of the files)
  • somehow you need to copy the files into the archive

To copy the files out of the archive, you need to perform the above in reverse. You won't use the command line to get the files names, you must use data from the the archive. You will need 'switches' like tar uses to decide whether you are creating an archive or reading from one. You won't need to recurse directory trees or manages file attributes unless the assignment says to do so or your course discussed this.

We won't do the assignment for you but provide outlines (clues) for you to find out how to do this. The reading and lectures in any course will have touched on the library functions that do what you need. For example, someone must have mentioned how arguments are passed to a C program (C++ and Java have the same mechanism with minor syntax changes).

Read the man pages for 'tar' (you can google 'man tar' from anywhere). Ignore functionality you don't need.

Edited 3 Years Ago by john.w.austin.39

As saddening as it may be. The user Dolby779 is a student asking for help with his coursework in which it is specifically stated that you should not seek help from others. It's unfair to other members of the class who try to solve this off their own back. Especially as this is a graded piece of work which counts towards a final grade.

Please refrain from asking on any more forums. Thnx :)

As saddening as it may be. The user Dolby779 is a student asking for help with his coursework in which it is specifically stated that you should not seek help from others. It's unfair to other members of the class who try to solve this off their own back. Especially as this is a graded piece of work which counts towards a final grade.

So your not allowed to ask help? What a strange rule.. If he was asking for the complete code I would agree, but since he's asking for help I see no harm in giving him a few pointers. I was a professional programmer for years and we were always encouraged to ask colleagues for help when struggling with a problem. It saves time in the long run and the insights of others often lead to better quality code in my opinion.

And so instead of helping your student (I assume), you rather create a profile on a forum to let them know that big brother is watching? That's a bit strange, now is it..

Edited 3 Years Ago by Nick Evan

This article has been dead for over six months. Start a new discussion instead.