Question: tucp The second utility you will build is called tucp , a variant of the UNIX tool cp . In this project, this command is

tucp

The second utility you will build is called tucp, a variant of the UNIX tool cp. In this project, this command is used to copy files or a group of files. It creates an exact image (copy) of a file on a disk. The tucp command requires at least two filenames in its arguments.

The following are the possible command usages:

tucp Sourcefile Destinationfile

tucp Sourcefile Directory

tucp Sourcefile-1 Sourcefile-2 Sourcefile-3 Sourcefile-n Directory

Details

  • If the tucp command contains two file names, then it copies the contents of the 1st file to the 2nd file. If the 2nd file doesnt exist, then it first creates a file with the specified name and the content of the first file is copied to it. But if the second file already exists, then it is simply overwritten without any warning.
  • If the tucp command has one or more arguments, specifying source file names and following those arguments, an argument specifying a directory name, then the command copies each source file to the destination directory with the same source file name. The destination file is created if did not exist, or overwritten if it already existed.
  • The Linux function stat() can be used to determine information about a file. The stat struct returned by the function includes a field, st_mode , that can be used to determine if the path evaluated by stat() is a file or a directory. Use man to learn about the functions stat() and inode().

Additional Tips

Testing is critical. As noted above, include sufficient code to test your code to make sure it works is crucial. [This is a good time to learn to use a debugger]. Write tests to see if your code handles all the cases you think it should. Be as comprehensive as you can be. Of course, when grading your projects, we will be. Thus, it is better if you find your bugs first, before we do.

Keep old versions around. Sophisticated developers use version control systems git (e.g.,through GitHub); We will be using GitHub beginning with this part of the project. A repository will be created for your use. That is, we will create a private repository for your use for each project assignment going forward. You are not to use your own personal GitHub account.

Footnotes

1: Unfortunately, there is a lot to learn about the C library, but at some point, you've just got to read documentation to learn what is available. Why not now, when you are young? Or, if you are old, why not now, before it's ... ahem ... too late? We will use C library functions and system calls (including from other libraries) in all of our projects.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!