程序代写 COMP1521 24T1 — Assignment 2: a file archiver

2024/3/29 09:43 COMP1521 24T1 — Assignment 2: a file archiver
https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html
.trats ot ecalp lufesu a eb ot oediv weivrevo tnemngissa eht dnif yam uoY
;)2 tesbus( selif fo tsil a morf yxalag a etaerc

Copyright By PowCoder代写 加微信 powcoder

;)1 tesbus( yxalag a morf detcartxe selif fo snoissimrep elif eht tes
;)1 tesbus( ;sehsah rats gnikcehc yb ,ytirgetni rof yxalag a kcehc
;)1 tesbus( yxalag a morf selif tcartxe
;)0 tesbus( rebmun cigam rats eht kcehc
;)0 tesbus( yxalag a ni selif fo )setyb fo rebmun( ezis eht tsil
;)0 tesbus( yxalag a ni tcejbo hcae fo snoissimrep eht tsil
;)0 tesbus( yxalag a ni tcejbo hcae fo seman htap eht tsil
nac ecaps fo noitatnemelpmi etelpmoc A
liated erom ni debircsed si tamrof sihT ;tcejbo metsys elif eno sdrocer rats a erehw ;srats erom ro eno fo pu edam si tamrof yxalag ehT
.tamrof yxalag eht rof revihcra elif a ,ecaps gnitnemelpmi eb lliw uoy ,tnemngissa siht nI
.erolpxe ot eloh-tibbar suollevram a si stamrof evihcra
fo tsil s’aidepikiW .nommoc si piZ ,swodniW no saerehw ;nommoc si rat ,smetsys ekil-xin* no :stamrof evihcra fo rebmun tsav a era erehT
.srevihcra elif sa eseht
etalupinam ro etaerc nac taht sloot ot refer netfo eW .tneiciffe erom noisserpmoc ekam netfo nac dna ,tneinevnoc erom selif fo tropsnart
d n a p u k c a b e k a m n a c e s e h T . s e l i f e l p i t l u m f o a t a d a t e m r e h t o d n a s e m a n , s t n e t n o c e h t n i a t n o c n a c h c i h w e l i f e l g n i s ak s is ea v i hT c r ae e l ih f T A
atad yranib no snoitarepo tuptuo-tupni gnidulcni ,snoitarepo elif gnidnatsrednu
;gnildnah rorre tsubor dna snoitarepo level-etyb gnidulcni ,C gnisitcarp
;stcejbo metsys elif fo gnidnatsrednu etercnoc a gnidlisubmiA
goL egnahC
snoitidnoC tnemngissA
kroW fo snoisreV etaidemretnI
emehcS tnemssessA
noissimbuS
tnemssessA
snoitacifiralC dna snoitpmussA
hsah rats ehT
tamrof rats dna yxalag ehT
noitatnemelpmi ecnerefeR
srorrE gnildnaH
detratS gnitteG
revihcra elif a :2 tnemngissA

2024/3/29 09:43 COMP1521 24T1 — Assignment 2: a file archiver
https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html
$ mkdir -m 700 space $ cd space
$ 1521 fetch space
space_main.c
space_hash.c
space_6_bit.c
dcc -c -o space.o space.c
dcc -c -o space_main.o space_main.c
dcc -c -o space_hash.o space_hash.c
dcc -c -o space_6_bit.o space_6_bit.c
dcc space.o space_main.o space_hash.o space_6_bit.o -o space $ ./space -l a.galaxy
list_galaxy called to list galaxy: ‘a.galaxy’
$ dcc space.c space_main.c space_hash.c space_6_bit.c -o space $ ./space -C b.galaxy
check_galaxy called to check galaxy: ‘a.galaxy’
$ unzip examples.zip
:elpmaxe roF
.yxalag a ni seirotcerid/selif eht fo seman htap eht tnirp dluohs ecaps ,tnemugra enil-dnammoc eht neviG
yxalag a fo stnetnoc eht fo tsil a tnirP :0 tesbuS
.yxalag a fo stnetnoc eht fo tsil deliated a tnirp
dna ,yxalag a fo stnetnoc eht fo tsil a tnirp
nac taht edoc tnemelpmi ot deen uoy ,0 tesbus etelpmoc oT
.tsniaga margorp ruoy tset ot selif yxalag. fo lluf dellac yrotcerid a teg ot piznu nur dluohs uoY
.selif ro artxe etaerc yllanoitpo yam uoY
:siht ekil elipmoc nac uoy elbaliava ekam evah t’nod uoy fI
.tluser eht nur ot elba eb dluohs uoy dna ;edoc dedivorp eht elipmoc ot ekam nur nac uoY
.ecaps rof tnemgarf elifekaM a sniatnoc
.elif siht egnahc ton oD .3 tesbus rof tamrof
tib-6 eht tnemelpmi ot eseht llac dluohs uoY .snoitcnuf tib_6_morf_rats dna tib_6_ot_rats eht sniatnoc
.elif siht egnahc
ton oD .1 tesbus rof sehsah etaluclac ot noitcnuf siht llac dluohs uoy ;noitcnuf hsah_rats eht sniatnoc
.elif siht egnahc ton oD .snoitinifed tnatsnoc lufesu emos dna snoitaralced noitcnuf derahs sniatnoc
.elif siht egnahc ton oD .ecaps ot nevig
stnemugra enil dnammoc eht no gnidneped ,yxalag_kcehc ro ,yxalag_etaerc ,yxalag_tcartxe ,yxalag_tsil
fo eno sllac neht hcihw dna ,stnemugra enil dnammoc eht esrap ot edoc sah hcihw ,niam a sniatnoc
.elif siht ot snoitcnuf nwo ruoy dda osla nac uoY .tnemngissa
eht etelpmoc ot edoc dda ot deen uoy hcihw ot ,yxalag_etaerc dna ,yxalag_tcartxe ,yxalag_kcehc
,yxalag_tsil ,snoitcnuf ruof fo snoitinifed laitrap sniatnoc ti :egnahc ot deen uoy elif ylno eht si
:selif gniwollof eht uoy evig lliw sihT
.elif rat a ro elif piz a sa selif dedivorp eht daolnwod nac uoy ,ESC ta gnikrow ton er’uoy fI
gninnur yb edoc dedivorp eht hctef dna ,yrotcerid siht ot egnahc ,tnemngissa siht rof yrotcerid wen a etaerC
detratS gnitteG
.)3 tesbus( stamrof tib-6 dna tib-7 ni seixalag etaerc dna ,tcartxe
dna ;)3 tesbus( seirotcerid edulcni taht seixalag etaerc dna ,tcartxe ,tsil

2024/3/29 09:43
COMP1521 24T1 — Assignment 2: a file archiver
https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html
# List each item in the galaxy called text_file.galaxy, which is in the examples directory $ ./space -l examples/text_file.galaxy
# List each item in the galaxy called 4_files.galaxy, which is in the examples directory $ ./space -l examples/4_files.galaxy
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.java
$ ./space -L examples/text_file.galaxy
-rw-r–r– 8 56 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– 8 256 256.bin
-rw-r–r– 8 56 hello.txt
-r–r–r– 8 166 last_goodbye.txt
-r–rw-r– 8 148 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– 8
-rw-r–r– 8
-rw-r–r– 8
-rw-r–r– 8
-rw-r–r– 8
-rw-r–r– 8 117 hello.java
-rw-r–r– 8 30 hello.js
-rwxr-xr-x 8 47 hello.pl
-rwxr-xr-x 8 103 hello.py
-rw-r–r– 8 45 hello.rs
-rw-r–r– 8 123 hello.s
-rwxr-xr-x 8 41 hello.sh
-rw-r–r– 8 24 hello.sql
93 hello.c
82 hello.cpp
65 hello.d
77 hello.go
32 hello.hs
space_main.c
print_bytes.c
.enil dnammoc eht no deificeps era snoitpo
ro eht fo rehtie nehw
ni yxalag_tsil noitcnuf eht sllac
.bal 8 keew ruo morf weiveR
.edoc detaeper diova ot tcurtsnoc nac uoy snoitcnuf eht tuoba ylluferac knihT
.sregetni otni setyb enibmoc ot dna sa hcus snoitarepo esiwtib C esU
woleb noitacificeps tamrof rats eht dnatsrednu uoy erus ekaM
.setyb daer ot ctegf esU
.elif yxalag eht nepo ot nepof esU
. ni yxalag_tsil ot edoc ddA
.eman htap yrotcerid/elif eht .
dna ,setyb ni ezis yrotcerid/elif eht .
,)tluafed eht( 8 ro 7 ,6 fo eno eb lliw hcihw tamrof rats eht .
,snoissimrep yrotcerid/elif eht .
:tnirp ,yxalag deificeps eht ni elif hcae rof ,dluohs ecaps ,tnemugra enil-dnammoc eht neviG
yxalag a fo stnetnoc eht fo tsil deliated a tnirP :0 tesbuS

2024/3/29 09:43 COMP1521 24T1 — Assignment 2: a file archiver
https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html
ctegf dna pool a esu osla nac uoy tub ,elif yxalag eht fo strap revo piks ot desu eb nac keesf
.ezis elif eht tnirp ot ekil tamrof a esu :tniH
.ecneinevnoc a sa ylerup selif elpmaxe dedivorp eht htiw enod neeb sah sihT .yxalag. htiw dne ylirassecen ton od selif yxalag
.yxalag eht ni raeppa yeht redro eht si selif tsil uoy redro ehT
# Check the galaxy called 4_files.galaxy, which is in the examples directory $ ./space -C examples/4_files.galaxy
256.bin – correct hash
hello.txt – correct hash
last_goodbye.txt – correct hash
these_days.txt – correct hash
# Check the galaxy called examples/hello_world.bad_hash.galaxy, which is in the examples directory $ ./space -C examples/hello_world.bad_hash.galaxy
hello.c – correct hash
hello.cpp – correct hash
hello.d – correct hash
hello.go – correct hash
hello.hs – correct hash
hello.java – correct hash
hello.js – correct hash
hello.pl – correct hash
hello.py – correct hash
hello.rs – correct hash
hello.s – correct hash
hello.sh – correct hash
hello.sql – incorrect hash 0x19 should be 0x43
# Check the galaxy called text_file.bad_magic.galaxy, which is in the examples directory $ ./space -C examples/text_file.bad_magic.galaxy
error: incorrect first star byte: 0x39 should be 0x63
space_main.c space.c check_galaxy space.c
.etadpu nac ti hcihw eulav hsah a ot retniop a ekat noitcnuf eht evah :tniH .htob seod taht
noitcnuf a etirw os ,eulav hsah wen a etaluclac ot llac ot deen uoy htiw daer uoy etyb yreve rof ,elpmaxe roF
.edoc detaeper diova ot tcurtsnoc nac uoy snoitcnuf eht tuoba ylluferac knihT
.seulav hsah etaluclac ot llaC
. ni ot edoc ddA
.enil dnammoc eht no deificeps si noitpo eht nehw ni yxalag_kcehc noitcnuf eht sllac
.yxalag eht ni deificeps snoissimrep eht ot selif detcartxe rof snoissimrep elif tes dluohs tI
.yxalag deificeps eht ni selif eht tcartxe dluohs ecaps ,tnemugra enil-dnammoc eht neviG
yxalag a morf selif tcartxE :1 tesbuS
.tcerrocni si ti fi rorre na time dna ,rats hcae fo )etyb tsrif( rebmun cigam rats eht kcehc osla dluohs tI
:elpmaxe roF .yxalag deificeps eht ni sehsah eht kcehc dluohs ecaps ,tnemugra enil-dnammoc eht neviG
yxalag a fo stnetnoc eht kcehC :1 tesbuS
.yxalag a morf selif tcartxe
dna ,yxalag a fo stnetnoc eht kcehc
nac taht edoc tnemelpmi ot deen uoy ,1 tesbus etelpmoc oT

2024/3/29 09:43 COMP1521 24T1 — Assignment 2: a file archiver
# space will extract files into the current working directory.
# So as not to clutter your assignment directory, you should create a # temporary directory, ‘tmp’, and change to it. Once in that directory, # both your space program and ‘examples/’ will be in its parent
# directory — hence the use of ‘..’ in these path names.
# Make a directory called tmp. $ mkdir -p tmp/
# Change into the tmp directory. $ cd tmp/
# Forcibly remove all files inside the tmp directory.
$ rm -f * .*
# Use your program to extract the contents of text_file.galaxy.
$ ../space -x ../examples/text_file.galaxy
Extracting: hello.txt
# Show the contents of hello.txt in the terminal.
# You can manually open it in your text editor too, if you like.
$ cat hello.txt
Hello COMP1521
I hope you are enjoying this assignment.
# Forcibly remove all files inside the tmp directory.
$ rm -f * .*
# Use your program to extract the contents of hello_world.galaxy.
$ ../space -x ../examples/hello_world.galaxy
Extracting: hello.c
Extracting: hello.cpp
Extracting: hello.d
Extracting: hello.go
Extracting: hello.hs
Extracting: hello.java
Extracting: hello.js
Extracting: hello.pl
Extracting: hello.py
Extracting: hello.rs
Extracting: hello.s
Extracting: hello.sh
Extracting: hello.sql
# Show the first 25 lines from the extracted files to confirm the extraction was successful. $ cat $(echo * | sort) | head -n 25
extern int puts(const char *s);
int main(void)
puts(“Hello, World!”);
return 0; }
#include
int main () {
std::cout << "Hello, world!" << std::endl; import std.stdio; void main() { writeln("Hello, world!"); package main import "fmt" func main() { fmt.Println("Hello, World!") main = putStrLn "Hello, World!" # Forcibly remove all files inside the tmp directory $ rm -f * .* # Use your program to extract the contents of meta.galaxy. $ ../space -x ../examples/meta.galaxy Extracting: 1_file.subdirectory.7-bit.galaxy Extracting: 1_file.subdirectory.galaxy Extracting: 2_files.7-bit.galaxy https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html 5/17 2024/3/29 09:43 COMP1521 24T1 — Assignment 2: a file archiver Extracting: 2_files.galaxy Extracting: 3_files.7-bit.galaxy Extracting: 3_files.bad_hash.galaxy Extracting: 3_files.bad_magic.galaxy Extracting: 3_files.galaxy Extracting: 3_files.subdirectory.7-bit.galaxy Extracting: 3_files.subdirectory.bad_hash.galaxy Extracting: 3_files.subdirectory.bad_magic.galaxy Extracting: 3_files.subdirectory.galaxy Extracting: 4_files.galaxy Extracting: all_the_modes.subdirectory.7-bit.galaxy Extracting: all_the_modes.subdirectory.galaxy Extracting: all_three_formats.6-bit.galaxy Extracting: binary_file.galaxy Extracting: hello_world.7-bit.galaxy Extracting: hello_world.bad_hash.galaxy Extracting: hello_world.bad_magic.galaxy Extracting: hello_world.galaxy Extracting: lecture_code.subdirectory.7-bit.galaxy Extracting: lecture_code.subdirectory.galaxy Extracting: small.6-bit.galaxy Extracting: small.7-bit.galaxy Extracting: small.galaxy Extracting: text_file.7-bit.galaxy Extracting: text_file.bad_hash.galaxy Extracting: text_file.bad_magic.galaxy Extracting: text_file.galaxy Extracting: tiny.6-bit.galaxy Extracting: tiny.7-bit.galaxy Extracting: tiny.galaxy # Show the first 10 items in this directory alphabetically to check extraction was successful. $ ls -1 $(echo * | sort) | head 1_file.subdirectory.galaxy 1_file.subdirectory.compressed.galaxy 2_files.galaxy 2_files.compressed.galaxy 3_files.bad_hash.galaxy 3_files.bad_magic.galaxy 3_files.galaxy 3_files.compressed.galaxy 3_files.subdirectory.bad_hash.galaxy 3_files.subdirectory.bad_magic.galaxy # Go back into the directory with your code. # Remove the tmp directory and everything inside it. $ rm -rf tmp/ https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html 6/17 space_main.c .elpmaxe c.domhc eht ni elif a fo snoissimrep eht gnittes dna elpmaxe c.ctegf_pc eht ni elif a ot setyb gniypoc derevoc ew selif no serutcel ruo nI .elif hcae ot setyb etirw ot ctupf esU .gnitcartxe era uoy elif hcae nepo ot nepof esU . ni yxalag_tcartxe ot edoc ddA .enil dnammoc eht no deificeps si noitpo eht nehw ni yxalag_tcartxe noitcnuf eht sllac .rorre na fo tneve eht ni selif detcartxe yllaitrap/detcartxe ydaerla evael nac ecaps .tsixe ydaerla taht selif na etirwrevo dluohs ecaps .selif fo tsil a morf yxalag a etaerc nac taht edoc tnemelpmi ot deen uoy ,2 tesbus etelpmoc oT 2024/3/29 09:43 COMP1521 24T1 — Assignment 2: a file archiver https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html # These "echo" lines show you how to create these test files and what their contents are. # Create a file called hello.txt with the contents "hello". $ echo hello >hello.txt
# Create a file called hola.txt with the contents “hola”. $ echo hola >hola.txt
# Create a file called hi.txt with the contents “hi”.
$ echo hi >hi.txt
# Set the permissions of these files to 644 (octal permission string (equivalent to rw-r–r–)). # When you list the contents of the galaxy, the permissions should match this.
$ chmod 644 hello.txt hola.txt hi.txt
# Create a galaxy called selamat.galaxy with the files hello.txt, hola.txt, and hi.txt.
$ ./space -c selamat.galaxy hello.txt hola.txt hi.txt
Adding: hello.txt
Adding: hola.txt
Adding: hi.txt
# List the contents of selamat.galaxy.
$ ./space -L selamat.galaxy
-rw-r–r– 8 6 hello.txt
-rw-r–r– 8 5 hola.txt
-rw-r–r– 8 3 hi.txt
# Make a directory called tmp.
$ mkdir -p tmp/
# Change into the tmp directory.
# Forcibly remove all files inside the tmp directory.
$ rm -f * .*
# Use your program to extract the contents of selamat.galaxy.
$ ../space -x ../selamat.galaxy
Extracting: hello.txt
Extracting: hola.txt
Extracting: hi.txt
# Check that the extracted file hello.txt is the same as the source file ../hello.txt.
$ diff -s ../hello.txt hello.txt
Files ../hello.txt and hello.txt are identical
# Check that the extracted file hola.txt is the same as the source file ../hola.txt.
$ diff -s ../hola.txt hola.txt
Files ../hola.txt and hola.txt are identical
# Check that the extracted file hi.txt is the same as the source file ../hi.txt.
$ diff -s ../hi.txt hi.txt
Files ../hi.txt and hi.txt are identical
# Go back into the directory with your code.
# Remove the tmp directory and everything inside it.
$ rm -rf tmp/
$ ./space -a bonjour.galaxy hello.txt Adding: hello.txt
$ ./space -L bonjour.galaxy -rw-r–r– 8 6 hello.txt
$ ./space -a bonjour.galaxy hola.txt hi.txt Adding: hola.txt
Adding: hi.txt
$ ./space -L bonjour.galaxy
-rw-r–r– 8
-rw-r–r– 8
-rw-r–r– 8
6 hello.txt
5 hola.txt
.yxalag wen eht etaerc ot ctupf dna nepof esU
. ni yxalag_etaerc ot edoc ddA
dnammoc eht no deificeps era snoitpo ro eht fo rehtie nehw ni yxalag_etaerc noitcnuf eht sllac
:elpmaxe roF .noitpo enil-dnammoc eht gnisu elif yxalag gnitsixe na ot srats dneppa ot elbissop osla si tI
.selif deificeps eht gniniatnoc yxalag a etaerc dluohs ecaps ,tnemugra enil-dnammoc eht neviG
selif fo tsil a morf yxalag a etaerC :2 tesbuS
space_main.c

2024/3/29 09:43 COMP1521 24T1 — Assignment 2: a file archiver
https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html
.elpmaxe c.tats eht ni )snoissimrep( edom dna ezis sti gnidulcni atadatem elif gniniatbo derevoc ew selif no serutcel ruo nI
.nevig era yeht redro eht ni selif erots/dda tsum uoY
# Create a galaxy called a.galaxy with the file “hello.txt” that is contained within 2 levels of directories. $ ./space -c a.galaxy examples/2_files.d/hello.txt
Adding: examples
Adding: examples/2_files.d
Adding: examples/2_files.d/hello.txt
# Create a galaxy called a.galaxy with *all* the contents within the directory “3_files.subdirectory.d” # which is in the “examples” directory.
$ ./space -c a.galaxy examples/3_files.subdirectory.d
Adding: examples
Adding: examples/3_files.subdirectory.d
Adding: examples/3_files.subdirectory.d/goodbye
Adding: examples/3_files.subdirectory.d/goodbye/last_goodbye.txt
Adding: examples/3_files.subdirectory.d/hello
Adding: examples/3_files.subdirectory.d/hello/hello.txt
Adding: examples/3_files.subdirectory.d/these_days.txt
$ ./space -L examples/1_file.subdirectory.galaxy drwxr-xr-x 8 0 hello
-rw-r–r– 8 56 hello/hello.txt
.syaw lareves ni enod eb nac dna gnignellahc si eert yrotcerid a gnisrevarT
.elpmaxe c.yrotcerid_tsil eht ni stnetnoc s’yrotcerid a gnitsil derevoc ew selif no serutcel ruo nI
.yxalag eht ot dedda eb ot deen htap eht ni seirotcerid eht neht ,yxalag a ot dedda si yrotcerid tnereffid a ni elif a fI
.redro yna ni seirotceridbus dda nac noitatnemelpmi
ruoy :ruoivaheb siht hctam ot deen ton od uoY .redro lacitebahpla ni seirotceridbus dda lliw noitatnemelpmi ecnerefer ecaps ehT
$ ./space -x examples/3_files.subdirectory.galaxy Creating directory: goodbye
Extracting: goodbye/last_goodbye.txt
Creating directory: hello
Extracting: hello/hello.txt
Extracting: these_days.txt
roF .seirotcerid dna selif tcartxe ot elba eb dluohs ecaps ,seirotcerid gniniatnoc yxalag a dna ,tnemugra enil-dnammoc eht neviG
yxalag a morf seirotcerid tcartxE :3 tesbuS
:elpmaxe roF .seirotcerid dna selif tsil ot elba eb dluohs ecaps ,seirotcerid gniniatnoc yxalag a dna tnemugra enil-dnammoc eht neviG
.yxalag eht ot eert yrotcerid eritne eht dda dluohs ecaps ,yxalag a gnitaerc nehw deificeps si yrotcerid a fI
:elpmaxe roF .seirotcerid-bus ni selif dda ot elba eb dluohs ecaps ,tnemugra enil-dnammoc eht neviG
seirotcerid dna selif fo tsil a morf yxalag a etaerC :3 tesbuS
.stamrof egarots tib-7 dna tib-6 etalupinam
dna ,yxalag a morf seirotcerid tcartxe
,seirotcerid dna selif fo tsil a morf yxalag a etaerc
nac taht edoc tnemelpmi ot deen uoy ,3 tesbus etelpmoc oT

2024/3/29 09:43
COMP1521 24T1 — Assignment 2: a file archiver
https://cgi.cse.unsw.edu.au/~cs1521/24T1/assignments/ass2/index.html
elpmaxe c.ridkm eht ni yrotcerid a gnitaerc derevoc ew selif no serutcel ruo nI
.yxalag eht ni deificeps esoht ot tes eb
ot deen snoissimrep sti dna ,tsixe ydaerla ton seod ti fi detaerc eb ot sdeen yrotcerid eht ,seirotcerid htiw yxalag a gnitcartxe nehW
$ ./space -7

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com