Skip to content

Commit c67a502

Browse files
authored
Create pcap.py
1 parent ca49b55 commit c67a502

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pcap.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from os import walk
2+
import os
3+
4+
5+
path = "/home/lmezard/ft_fun/"
6+
f = []
7+
for (dirpath, dirnames, filenames) in walk(path):
8+
f.extend(filenames)
9+
break
10+
11+
files = []
12+
for file_ in f:
13+
with open(path + file_, "r") as fd:
14+
number = fd.read().split("//file")[1]
15+
files.append({'key' : int(number), 'name' : file_})
16+
files.sort()
17+
print("All files are sorted !")
18+
19+
code = ""
20+
for fil in files:
21+
with open(path + fil['name']) as f:
22+
data = f.read().split("//file")
23+
code += data[0] + "//" + fil['name'] + "\n"
24+
print("Code recovered !")
25+
26+
with open("main.c", "w") as main:
27+
main.write(code)
28+
print("'main.c' file was created !")
29+
30+
os.system("gcc main.c && ./a.out")
31+
print("\n")

0 commit comments

Comments
 (0)