-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (47 loc) · 1.41 KB
/
main.cpp
File metadata and controls
54 lines (47 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright Pavel Kraynyukhov 2018.
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* $Id: lar:main.cpp Jun 16, 2018 1:04:08 PM $
*
* EMail: pavel.kraynyukhov@gmail.com
*/
#include <cstdlib>
#include <iostream>
#include <TOC.h>
#include <LAR.h>
/*
*
*/
int main(int argc, char** argv)
{
static const std::string usage("\nUsage:\n# lar a directory - to add a content of directory into archive recursively\n||\n# lar e archive_name [target subdir] - to extract all files from archive. Where target subdir is a relative path within working directory\n");
if((argc<3)||(strlen(argv[1]) != 1)||((argv[1][0] != 'e') && (argv[1][0] != 'a')))
{
throw std::system_error(EINVAL,std::system_category(),usage);
}
switch(argv[1][0])
{
case 'a':{
lar::LAR newarch;
std::string dirname(argv[2]);
newarch.add(dirname);
newarch.pack(dirname+".lar");
}
break;
case 'e':{
fs::path target_subdir=fs::current_path();
if(argc==4)
{
target_subdir=target_subdir / std::string(argv[3]);
}
std::string archname(argv[2]);
lar::LAR listarch;
listarch.unpack(archname,target_subdir);
}
}
return 0;
}