Question: PLEASE IMPLEMENT THE FOLLOWING FUNCTION USING THIS GIVEN INFO AND SCREENSHOT OF FORMAT. FUNCTION IS CALLED void list _ galaxy ( char * galaxy _

PLEASE IMPLEMENT THE FOLLOWING FUNCTION USING THIS GIVEN INFO AND SCREENSHOT OF FORMAT. FUNCTION IS CALLED void list_galaxy(char *galaxy_pathname, int long_listing). Subset 0
To complete subset 0, you need to implement code that can
print a list of the contents of a galaxy, and
print a detailed list of the contents of a galaxy.
Subset 0: Print a list of the contents of a galaxy
Given the -l command-line argument, space should print the path names of the files/directories in a galaxy.
For example:
List each item in the galaxy called text_file.galaxy, which is in the examples directory
./space -l examples/text_file.galaxy
hello.txt
List each item in the galaxy called 4_files.galaxy, which is in the examples directory
./space -l examples/4_files.galaxy
256.bin
hello.txt
last_goodbye.txt
these_days.txt
List each item in the galaxy called hello_world.galaxy, which is in the examples directory
./space -l examples/hello_world.galaxy
hello.c
hello.cpp
hello.d
hello.go
hello.hs
hello.java
hello.js
hello.pl
hello.py
hello.rs
hello.s
hello.sh
hello.sql
Subset 0: Print a detailed list of the contents of a galaxy
Given the -L command-line argument, space should, for each file in the specified galaxy, print:
the file/directory permissions,
the star format which will be one of 6,7 or 8(the default),
the file/directory size in bytes, and
the file/directory path name.
./space -L examples/text_file.galaxy
-rw-r--r--856 hello.txt
List the details of each item in the galaxy called 4_files.galaxy, which is in the examples directory
./space -L examples/4_files.galaxy
-rw-r--r--8256256.bin
-rw-r--r--856 hello.txt
-r--r--r--8166 last_goodbye.txt
-r--rw-r--8148 these_days.txt
List the details of each item in the galaxy called hello_world.galaxy, which is in the examples directory
./space -L examples/hello_world.galaxy
-rw-r--r--893 hello.c
-rw-r--r--882 hello.cpp
-rw-r--r--865 hello.d
-rw-r--r--877 hello.go
-rw-r--r--832 hello.hs
-rw-r--r--8117 hello.java
-rw-r--r--830 hello.js
-rwxr-xr-x 847 hello.pl
-rwxr-xr-x 8103 hello.py
-rw-r--r--845 hello.rs
-rw-r--r--8123 hello.s
-rwxr-xr-x 841 hello.sh
-rw-r--r--824 hello.sql
space_main.c calls the function list_galaxy in space.c when either of the -l or -L options are specified on the command line.
Add code to list_galaxy in space.c.
Use fopen to open the galaxy file.
Use fgetc to read bytes.
Make sure you understand the star format specification below
Use C bitwise operations such as & and | to combine bytes into integers.
Think carefully about the functions you can construct to avoid repeated code.
Review print_bytes.c from our week 8 lab.
fseek can be used to skip over parts of the galaxy file, but you can also use a loop and fgetc
The order you list files is the order they appear in the galaxy.
galaxy files do not necessarily end with .galaxy. This has been done with the provided example files purely as a convenience.
Hint: use a format like "%5lu" to print the file size. IMPLEMENT "void list_galaxy(char *galaxy_pathname, int long_listing)" don't use fgets but use fgetc.The galaxy and star format
galaxies must follow exactly the format produced by the reference implementation.
A galaxy consists of a sequence of one or more stars. Each star contains the information about one file or directory.
The first byte of a galaxy file is the first byte of the first star. That star is immediately followed by either another star, or by
the end of the galaxy file.
PLEASE IMPLEMENT THE FOLLOWING FUNCTION USING

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 Programming Questions!