Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 (APUE Ch03-Ch04) C/C++ program to create directories and files. First, create a directory named cs337, and change current working directory to cs3377. Note.

Part 1 (APUE Ch03-Ch04)

C/C++ program to create directories and files.

First, create a directory named cs337, and change current working directory to cs3377.

Note. Your program should not use any of "system( )" calls for this part.

Task#1. Design and implement C/C++ program (a2part1.c or a2part1.cpp, and its executable named a2part1) to create directories and files, and/or to navigate the directories as shown below.

image text in transcribed

Before and after each call (e.g., to create a file or to create a directory), your program should print a message with a time-stamp (e.g., " ** created dir1 at 2018.09.29 13:59 **").

Task#2. After completing Task#1, your program should change its current working directory (to "a2part1"), to display each directory entry information of this directory and its all subdirectories. You should use "readdir" in APUE 4.22 and "stat" in APUE4.2 to display each directory entry information (similar to what "ls -l" command displays).

Task#3. Change the access-attribute of "file2.txt" to "rw- rw- r--" using "chmod" call (in APUE 4.9).

Task#4. Open the file "file1.txt" in dir1 for "write" and output the list of directory entries of this directory ("dir1"), and then close the file.

The execution of your program is now terminated.

Task#5. Use "ls -lR" command to show all the directories and files (with detailed file information) of the directory "a2part1" to show that your program ran successfully.

{cslinux1:~/cs3377/a2part1} ls -lR

.:

total 8

drwx--x--x 2 rkm010300 cs 4096 Jan 8 2018 dir1

drwx--x--x 2 rkm010300 cs 4096 Jan 8 2018 dir2

-rw------- 1 rkm010300 cs 0 Jan 8 2018 file1

-rw------- 2 rkm010300 cs 0 Jan 8 2018 link1

./dir1:

total 0

-rw------- 1 rkm010300 cs 0 Jan 8 2018 dir1file1

./dir2:

total 0

-rw------- 2 rkm010300 cs 0 Jan 8 2018 dir2file1

Task#6. Provide Makefile to compile the program to generate its executable, and its session log of the execution.

Part1 Solution

1. List of your program

2. List of Makefile

3. List of your program run (session log/history)

4. List of your validation with "ls -lR" command to be run in a2part1 to list all its files and directories.

This is your current directory which is a2partl (in cs3377) dir2 file3.txt link1 dirl file1.txt dirl1 file2.txt file11.txt This is your current directory which is a2partl (in cs3377) dir2 file3.txt link1 dirl file1.txt dirl1 file2.txt file11.txt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

Ty e2y Evaluate the integral dy

Answered: 1 week ago