Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 6 Write a Java or C/Ct+ (the choice is yours) program for file/directory processing according to the following rules. The program requested for this

image text in transcribed

image text in transcribed

image text in transcribed

Homework 6 Write a Java or C/Ct+ (the choice is yours) program for file/directory processing according to the following rules. The program requested for this homework must have a text menu like this: 0 - Exit 1 - Select directory 2 - List directory content 3 - Display file (hexadecimal view) 4 - Delete file 5 - Mirror reflect file (byte level) Select option: The menu is displayed and the user must select an option (a number between 0 and 5). The action corresponding to the selection is performed, then the menu is displayed again and the user can choose another option. This cycle is repeated until the user selects 0 , which exits the loop and ends the program execution. The options are: 0 - Exit This options ends the programexecution. This option should always work. 1 - Select directory The user is prompted for an [absolute] directory name (path). This is the first options that must be selected by the user. All the options below are working on the directory selected here. The directory name (path) must be correctly formatted and the directory must exist (the program must check for this and issue error messages if necessary). After performing several operations on the selected directory, the user can select another directory and work with it. If a user (by mistake or otherwise) selects any other option from the menu before selecting this one, an error message must be displayed instructing the user to select a directory first. 2 - List directory content This option displays the content of the directory (previously selected by option 1) on the screen. All the files and sub-directories from the first level ONLY must be displayed (files and directories should be listed separately one item per line, directories first). For each file, its size must also be displayed, in bytes. If no directory was selected an error message must be displayed. 3 - Display file (hexadecimal view) This option prompts the user for a filename (from the directory selected by option 1) and displays the content of that file on the screen, in hexadecimal view. If no directory was selected an error message must be displayed. If the directory does not contain the file specified by the user, another error message must be displayed. The filename does not include any path, it's just the name of the file. Note: The hexadecimal view displays each byte of the file in hexadecimal, 16 bytes per line, separated by one white space; each byte must occupy two characters on the screen. It should look something like this (please note that the letters A to F must be in upper case !!!): 4- Delete file This option prompts the user for a filename and deletes that file from the selected directory. If no directory was selected an error message must be displayed. If the directory does not contain the file specified by the user, another error message must be displayed. The filename does not include any path, it's just the name of the file. 5 - Mirror reflect file (byte level) This option prompts the user for a filename (from the selected directory) and performs an operation we will call "mirror reflection" for every byte of that file. If no directory was selected an error message must be displayed. If the directory does not contain the file specified by the user, another error message must be displayed. The filename does not include any path, it's just the name of the file. Note: Mirror reflection for a certain byte (which, as we know, is a string of 8 bits) changes the order of its bits just like a real world mirror does for any image: what was on the left side will appear on the right side and vice versa. More concretely, let's denote the bits of a byte as b1b2b3b4b5b6b7b8. After the mirror reflection operation, they will be rearranged as b8b7b6b5b4b3b2b1. Hints: The required actions are: read the whole file into a memory buffer (we assume the file is small enough), then perform the mirror reflection for every byte of the memory buffer, then we write back the buffer into the file (we overwrite the file) resulting a file with the same size in bytes. No additional file must or should be used, as the initial file must be overwritten. Clearly if we apply this operation twice, we must obtain again the initial file content. Testing procedure: 0. Option 0 requires just one screenshot, for successful exit. 1. Option 1 requires one screenshot for a correct directory name (path) and one screenshot for an incorrect directory name (path). 2. Option 2 requires one screenshot showing the error (no directory was selected yet) and another one showing the content of the selected directory; make sure the directory you use contains at least three files and three subdirectories. 3. Option 3 requires screenshots showing the errors (no directory was selected yet, file does not exist) and another one showing the content of the selected file; make sure the display follows the required formatting. 4. Option 4 requires screenshots showing the errors (no directory was selected yet, file does not exist) and another one/two showing the content of the selected directory before and after deleting the file. 5. Option 5 requires screenshots showing the errors (no directory was selected yet, file does not exist) and others showing the hex view of the file before and after mirroring (also, make sure the file size remains the same). Deliverables: 1. Source code (zipped) 2. A Test Report showing the program performing each of the menu actions correctly (use the testing procedure described above, include all the required screenshots). Use this file (Homework 6 .pdf) as the input file for options 3 and 5

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_2

Step: 3

blur-text-image_3

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Explain how to build high-performance service delivery teams.

Answered: 1 week ago

Question

Understand what a service-oriented culture is.

Answered: 1 week ago