Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Directory maintenance simulator Description: The goal of this assignment is to m

ID: 3742081 • Letter: D

Question

Directory maintenance simulator

Description:

The goal of this assignment is to make a c program of a basic directory maintenance simulator that processes basic UNIX/Linux commands.

mv <fname1> <fname2> // change the name of the file or directory to the new name

cp <fname1> <fname2> // copy file or folder to the new name

rm <filename>   // locate and remove the file or directory
bye // ends the session

whereis <filename>   // show path to first occurrence of file or directory if it exists

A technical note:
Think of your structure for a Node in this system. The cd .. command suggests that it will be really critical to be able to navigate from a given node to that node's parent. Does it appear that the second picture above would make such a process efficient? One other thought. You will REALLY want to practice drawing how your pointers get set as you develop this program!!

Program execution:
This assignment will simulate an interactive program by reading the commands from a file. Commands will be in the file, one per line. You will NOT have to construct commands from multiple lines and SHOULD NOT code your progam to work that way. We will adopt the approach of running an interactive program non-interactively for two reasons:

It will illustrate that you can test interactive programs without having to do all the typing (most important)

It will simplify life for the person grading the assignment (me in this case)

Explanation / Answer

c program of a basic directory maintenance simulator that processes basic UNIX/Linux commands.

#include <directory.h>

#include <stdio.h>

int main(void)

{

//listing of files in directory content

    DIRECTORY *d;

    struct directory *dir;

    d = opendirsctory(".");

    if (d)

    {

        while ((dir = readdirectory(d)) != NULL)

        {

                adddirectory(file%n); //addition of directory

                addfiles(directory%d);//addition of files

            printf("%s ", dir->d_name);

        }

        closedirectory(d);

//adds complexity for traversals, add and delete,

struct node *newNode(int item)

{

    struct node *temp = (struct node *)malloc(sizeof(struct node));

    temp->key = item;

    temp->left = temp->right = NULL;

    return temp;

struct node* addNode(struct node* root, int key)

            if (root == NULL) return root; //addition of complexity traversals

if (key < root->key)

        root->left = deleteNode(root->left, key); //deletion of complexity traversals

{

}

    }//creates a new directory if it does not already exist

            if (!file.exists("../calculatingdata/")) dir.create(mkdir <directoryname>)

    else

            changedirectory(const char*path); //changes into specified directory if it exists

            }

{

system("directory Users (parentdirectory(new.change) test.txt") //changes the parent directory

}

{

int bytes = GetSpecifiedName(NULL, pBuffer, length); //specifies the current directory

if(bytes == 0) //refers name,root directory

specify.password==0(show)

    return -1;

else

   return bytes;

//addition of file to the current directory

int main(int argc, char **argv)

{

    int parentid = getparentid //declaration of parent nodes

    char directoryName[NAME_MAX+1];

    char *prefix = "that.space.";

    add filename;

    snprintf(directoryName, NAME_MAX + 1,"%s%d", prefix, parentid);

    printf("%s ",dirName); //printing the file added

    struct stat st = {0};

    change name (const char *old_name, const(mv) char *new_name);//change the name of the file or directory to the new name

    mv source_file.new_file;

    if (stat(directoryName, &st) == -1) {

        if(mkdir(directoryName,) != -1){

            snprintf(libraryPath, PATH_MAX + 1, "%s/library.txt", directoryName);

//to copy file or folder to new names

   char ch, source_file[name1], new_file[name2];

   FILE *source, *new;

   printf("Enter name of file to copy ");

   cp source_file;new_file;

   gets(source_file);

   source = fopen(source_file, "r");

//locate and remove file or directory

locateDIRECTORY();

            printf(" SELECT the name of the file to remove: ");

            rm_filename;

    scanf("%s", filetoremove);

DIRECTORY* dir = opendirectory("mydirectory");

if (dir)

{//path to first occurrence of file or Directory exists

    closedirectory(dir);

return(0);

}

Hope you understand and this helps you.All the best.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote