-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmctosfs.py
executable file
·59 lines (52 loc) · 1.36 KB
/
mctosfs.py
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
54
55
56
57
58
59
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Program pomocniczy do mc wyświetlający zawartość obrazów dysków TOSa.
"""
import array
import errno # for error number codes (ENOENT, etc)
# - note: these must be returned as negatives
import os
import stat # for file properties
import sys
from TOSDSK import *
def show_list(path):
dsk = DSK(path)
tos = TOS(dsk)
links = 1
gid = "77"
uid = "77"
t = "Jan 1 1970"
#print tos.entries
lista = []
for i in tos.entries:
if i[NO] != 0:
continue
if i[NR_OF_DIR] == 255:
continue
#print i
#continue
if i[NAME].endswith('.DIR'):
typ = "drwxrwxrwx"
else:
typ = "-rw-rw-rw-"
size = tos.get_size(i)
lista.append((typ, links, uid, gid, size, t, tos.get_name(i)))
lista.sort(key = lambda x: x[-1])
for i in lista:
print "%s %4d %s %s %14d %s %s" % \
(i[0], i[1], i[2], i[3], i[4], i[5], i[6])
def copyout(diskname, name, out):
dsk = DSK(diskname)
tos = TOS(dsk)
data = tos.read_file(name)
f = open(out, "wb")
data.tofile(f)
f.close()
if __name__ == "__main__":
cmd = sys.argv[1]
args = sys.argv[2:]
if cmd == "list":
show_list(args[0])
elif cmd == "copyout":
copyout(args[0], args[1], args[2])