File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
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 " )
You can’t perform that action at this time.
0 commit comments