1
# Copyright (C) 2011 David Manzanares <manxi.david@gmail.com>
2
#This file is part of PyEffect.
4
# PyEffect is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
9
# PyEffect is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with PyEffect. If not, see <http://www.gnu.org/licenses/>.
17
#This is the PyEffect file manager, this module contains all the functions that reads, writes and delete external files
20
#Read the source (.3) and write the output of the stages in .3p, and .s
22
#Third party libraries:
32
"""Open and read the source code in .3 format"""
34
if tg[len(tg) - 2:len(tg)] != ".3":
35
out.error("Source file <<"+tg+">> must have .3 extension")
36
inputFile = open(tg, "r")
37
source = inputFile.read()
41
"""Write the STAGE1 into the .3p file"""
42
outputFileS1 = open(args.target[0:(len(args.target) - 1)] + "3p", "w")
43
outputFileS1.write(s1.all)
47
"""Write the STAGE3 into the .3s file"""
48
outputFileS1 = open(args.target[0:(len(args.target) - 1)] + "3s", "w")
49
outputFileS1.write(s3.lns.getStrVerbose())
53
"""Write the STAGE3 into the .s file"""
55
outputFileS3 = open(args.target[0:(len(args.target) - 1)] + "s", "w")
56
outputFileS3.write(s4.asm)
60
"""Clean the directory, remove all *.s *.3p and *.o files"""
61
os.system("rm -f " + Dir + "*.s " + Dir + "*.3p " + Dir + "*.3s " + Dir + "*.o " + Dir + "*.log")
64
"""Clean the directory wich contains the args.target if args.keep ==False"""
65
if args.keep == False:
66
i = len(args.target) - 1
67
while args.target[i] != "/" and i > 0:
70
cleanDir(args.target[:i + 1])