首页 > 其他分享 >CSSE2310 Command Line Arguments

CSSE2310 Command Line Arguments

时间:2024-09-26 17:45:35浏览次数:1  
标签:-- line filename Command file Line CSSE2310 archive uqzip

CSSE2310 – Semester 2, 2024

Assignment 3

Introduction

The goal of this assignment is to demonstrate your skills and ability in fundamental process management and communication concepts (pipes and signals), and to further develop your C programming skills with a moderately complex program.

You are to create a program (called uqzip) which allows users to compress a file (or set of files) using any one of a set of external compression programs (zip, gzip, xz or bzip2). This will create a .uqz archive file. The program will also allow decompression of the files that it creates.

The assignment will also test your ability to code to a particular programming style. guide, and to use a revision control system appropriately.

Specification

The uqzip program will allow a user to create a .uqz archive file that will hold a compressed file (or files) that can later be extracted from the archive (decompressed) using uqzip. uqzip won’t actually do the compression itself – it will rely on external programs (such as zip, gzip, xz or bzip2 available on moss) to do the compression and will package up the resulting data into a .uqz archive. The .uqz archive file will also store the method of compression used and the filename for each compressed file stored in the archive.

When used for decompression, uqzip will extract each compressed data stream from the .uqz archive file and pipe it to an external decompression program whose output will be saved to a file in the current directory with the original filename. uqzip is to support both sequential and parallel compression and decompression. Sequential processing means files are compressed (or decompressed) one after the other. Parallel processing means files are compressed (or decompressed) in parallel – each using a separate child process of uqzip (or two child processes per file in the case of parallel decompression).

Command Line Arguments

Your uqzip program is to accept command line arguments as follows when doing file compression, i.e. creating a .uqz archive file:

./uqzip [--nozip|--gz|--zip|--xz|--bzip2] [--parallel] [--output outFilename ] filename ...

and as follows when doing decompression (archive extraction):

./uqzip [--parallel] --extract uqz-file

The square brackets ([]) indicate optional arguments or groups of arguments. The pipe symbol (|) indicates a choice. The italics indicate placeholders for user-supplied value arguments. An ellipsis (. . . ) indicates the previous argument can be repeated. Note that the option arguments (those beginning with “--” and their associated value, if any) can be in any order.

When used for compression, uqzip will accept an optional argument specifying the compression method. When none of --bzip2, --gz, --zip, --xz or --nozip are specified then the program is to act as if --nozip is specified – i.e. no compression is used when creating the archive file.

When used for compression, an optional output file name (outFilename ) can be specified by using the --output option argument. If this argument pair is not specified, then the default filename out.uqz is to be used. It can be assumed that (i.e. we will not test a situation when) the outFilename (or default output filename) is given as a filename argument on the command line.

When used for compression, one or more existing filenames to be compressed into the .uqz archive must also be specified after any option arguments. It can be assumed that the first (or only) file name argument does not start with the characters “--”. (If the user wants to specify a file whose name does start with “--” then they should prefix the name with “./”. Any 代 写CSSE2310   Command Line Arguments arguments after the first file name are also assumed to be file names, even if they begin with “--”.)

When used for decompression (with the --extract option argument specified), uqzip expects a filename argument to be present (uqz-file , which must be the last argument). This is the name of the .uqz archive file to be decompressed.

If the --parallel option argument is present, then uqzip is to use child processes running in parallel to do the compression or decompression. If this argument is not present, then uqzip will use child processes running sequentially. Full details of the required functionality are provided later in this document.

Some examples of how the program might be run include the following:

./uqzip /usr/dict/share/words

./uqzip --parallel --bzip2 one.txt two.txt three.txt

./uqzip --zip --output lists.uqz --parallel list1 list2 list3 list4 list5 list6

./uqzip --output archive --xz /usr/share/dict/words local/dictionary

./uqzip --extract archive.abc

./uqzip --parallel --extract out.uqz

More details on the expected behaviour of the program are provided later in this document.

Prior to doing anything else, your program must check the command line arguments for validity. If the program receives an invalid command line then it must print the following (two line) message:

Usage: ./uqzip [--nozip|--gz|--zip|--xz|--bzip2] [--parallel] [--output outFilename] filename ...

Or: ./uqzip [--parallel] --extract uqz-file

to standard error (with a newline at the end of each line), and exit with an exit status of 14. Note that the colon (:) symbols on each line are aligned, i.e. three spaces precede “Or:”.

Invalid command lines include (but may not be limited to) any of the following:

• More than one of the option arguments --bzip2, --gz, --zip, --xz, --nozip or --extract is given on the command line

• Any of the option arguments is listed more than once.

• The --output option argument is given but it is not followed by a filename argument

• No filenames are given on the command line.

• --extract is given on the command line along with --output

• --extract is given on the command line along with more than one filename

• An unexpected argument is present.

• Any argument is the empty string.

Checking whether files exist or can be opened is not part of the usage checking (other than checking that filename values are not empty). This is checked after command line validity as described below.

File Checking

Compression

If uqzip is creating an archive file (i.e. --extract is NOT specified on the command line) then it must attempt to open the output file (the given outFilename from the command line, or, if none is present, then the default output filename – out.uqz) for writing. If the file already exists, it must be truncated and overwitten. If the file is unable to be opened for writing then uqzip must print the message:

uqzip: can’t write to file "filename "

to standard error (with a following newline) where filename is replaced by the name of the file that could not be opened for writing. uqzip must then exit with status 17.

The files to be compressed are not checked for existence.

Decompression

If --extract is specified on the command line and uqzip is unable to open the given archive filename (uqz-file argument) for reading, then your program must print the message:

uqzip: unable to read from file "filename "

to standard error (with a following newline) where filename is replaced by the name of the .uqz archive file from the command line. The double quotes must be present. uqzip must then exit with status 6.

Program Behaviour – Compression (Archive Creation)

If the command line and file checks described above are successful and an archive file is to be created (the argument --extract is NOT specified on the command line) then uqzip is to behave as described below.

First, uqzip must write out the header section for the archive file. (See Table 1 for details of the file format, including the header section.) Placeholders should initially be used for the file record offsets because these aren’t known yet. These will need to updated in the file after the compressed files are added to the archive.

 

标签:--,line,filename,Command,file,Line,CSSE2310,archive,uqzip
From: https://www.cnblogs.com/wx--codinghelp/p/18433970

相关文章

  • WPF canvas Draw line , ellipse and rectangle, save canvas and contents as pictu
    //xaml<Windowx:Class="WpfApp417.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.mi......
  • The 2024 ICPC Asia East Continent Online Contest (II)
    C.PrefixofSuffixes比赛的时候调E,调的心态爆炸,最后一点时间写C,又没冲出来题目大意给三个数组\(\{S_n\},\{a_n\},\{b_n\}\),对于每个\(i\)求\(\sum_{j=1}^i\sum_{k=j}^{j+z_j-1}A_kB_j\),其中\(z_i\)表示\(S_{[1,i]}\)和\(S_{[j,i]}\)的最长公共前缀的长度,\(S\)数组强制在线\[......
  • The 2024 ICPC Asia EC Regionals Online Contest (II)
    A-GamblingonChoosingRegionals题意\(k\)场比赛,每场比赛每个大学至多\(c_i\)个队;总\(n\)个队伍,每队有分数与所属大学两个属性,每只队伍至多参加\(2\)场比赛。求各个队在最坏情况下的最优排名。思路最坏情况就是你打哪场,强队都去哪场,就选\(c_i\)小的场次,能让排名更靠......
  • MySQL 5.7 Command Line Client 闪屏退出
    MySQL5.7CommandLineClient 闪屏退出 解释:MySQL5.7CommandLineClient闪屏退出可能是因为缺少某些环境变量配置,或者是MySQL安装过程中出现了问题。解决方法:   检查环境变量:确保PATH环境变量中包含了MySQL的bin目录路径。在Windows系统中,可以在系统属性的“高级”......
  • Mac vscode 每次打开的终端,执行node命令都报command not found: node
    先说问题,答案放在后面自从上次升级node后,每次vscode打开终端都会报npmwarnclinpmv10.8.2doesnotsupportNode.jsv18.14.2.Thisversionofnpmsupportsthefollowingnodeversions:`^18.17.0||>=20.5.0`.Youcanfindthelatestversionathttps://nodejs.or......
  • The 2024 ICPC Asia East Continent Online Contest (II)
    Preface被徐神带飞咯,全程睡觉看队友卡卡过题,最变态的是K我上去乱写了个假做法就下机睡觉了,后面徐神反手就改了个正解出来这场主要是周五晚上无来由地发烧了,第二天比赛的时候头痛的一批,几乎没法集中精力想代码和写题但没想到这场最后打的还挺好,开局1h不到就把6个签过了,然......
  • The 2024 ICPC Asia East Continent Online Contest (I)
    Preface打的一坨,直接被Div.2学弟吊起来打这场主要是中期的Easy~mid写的太慢,导致中后期题没时间写同时封榜后的决策也有点问题,没有全队All-in一个题而是让徐神去写当时1/27的K,虽然可能徐神来想H我们也出不来但感觉还是跟榜适合我们队的level赛后发现H反着填右括......
  • WPF ContextMenu MenuItem CommandParameter pass whole control or SelectedItem
    CommandParameterpassSelectedItemofcontrol<ListBox.ContextMenu><ContextMenu><MenuItemHeader="SaveImage"Command="{BindingSaveImgCommand}"CommandParameter=&q......
  • CentOS7使用yum时File contains no section headers. file: file:///etc/yum.repos.d/
    CentOS7使用yum时Filecontainsnosectionheaders.file:file:///etc/yum.repos.d/CentOS-Base.repo,line:1'--2024-09-2221:08:17--http://mirrors.aliyun.com/repo/Centos-7.repo\n'安装好CenOS7后,自带的yum不能直接使用,使用会出现如下问题:原因是没有配置yum源,修改/e......
  • yt to wav tools online
    yttowavtoolsonlineHereisadetailedintroductiontothewebsiteyttowav.ccyttowav.ccisanexceptionalonlinetoolthatenablesuserstodownloadshortvideosoranyvideosfromtheYouTubeclientorwebpageeffortlessly.Itprovidesaseamlessand......