Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/archive/misc.ts
1691 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
interface Entry {
7
list: { command: string; args: ReadonlyArray<string> };
8
extract: { command: string; args: ReadonlyArray<string> };
9
}
10
11
const bz2: Entry = {
12
list: { command: "ls", args: ["-l"] },
13
extract: { command: "bunzip2", args: ["-vf"] },
14
};
15
16
const tbz2: Entry = {
17
list: { command: "tar", args: ["-jtvf"] },
18
extract: { command: "tar", args: ["-xjf"] },
19
};
20
21
const tgz: Entry = {
22
list: { command: "tar", args: ["-tzf"] },
23
extract: { command: "tar", args: ["-xvzf"] },
24
};
25
26
export const COMMANDS: { [type: string]: Entry } = {
27
"tar.bz2": tbz2,
28
tbz2: tbz2,
29
zip: {
30
list: { command: "unzip", args: ["-l"] },
31
extract: { command: "unzip", args: ["-B"] },
32
},
33
tar: {
34
list: { command: "tar", args: ["-tf"] },
35
extract: { command: "tar", args: ["-xvf"] },
36
},
37
tgz,
38
"tar.gz": tgz,
39
gz: {
40
list: { command: "gzip", args: ["-l"] },
41
extract: { command: "gunzip", args: ["-vf"] },
42
},
43
bz2,
44
bzip2: bz2,
45
lzip: {
46
list: { command: "ls", args: ["-l"] },
47
extract: { command: "lzip", args: ["-vfd"] },
48
},
49
xz: {
50
list: { command: "xz", args: ["-l"] },
51
extract: { command: "xz", args: ["-vfd"] },
52
},
53
} as const;
54
55
// all keys of COMMANDS, that have at least one "." in their name
56
export const DOUBLE_EXT = Object.keys(COMMANDS).filter(
57
(key) => key.indexOf(".") >= 0
58
);
59
60