diff options
author | Juerg Billeter <j@bitron.ch> | 2008-05-11 13:57:44 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2008-05-11 13:57:44 +0000 |
commit | bc490edf52f9b3a8dfe14d949d44e1d8fc6b441d (patch) | |
tree | 6179e14e9a1f1080b63af742fa03db5aa291ac8c /ccode/valaccodewriter.vala | |
parent | a2ceedc1a5afe9b3f12c36f245b18bed051032e0 (diff) | |
download | vala-bc490edf52f9b3a8dfe14d949d44e1d8fc6b441d.tar.gz |
Fix crash when opening output file fails, fixes bug 466573
2008-05-11 Juerg Billeter <j@bitron.ch>
* ccode/valaccodewriter.vala:
* gobject/valaccodegeneratorsourcefile.vala:
Fix crash when opening output file fails, fixes bug 466573
svn path=/trunk/; revision=1370
Diffstat (limited to 'ccode/valaccodewriter.vala')
-rw-r--r-- | ccode/valaccodewriter.vala | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala index c011c8106..4330e7a48 100644 --- a/ccode/valaccodewriter.vala +++ b/ccode/valaccodewriter.vala @@ -35,13 +35,6 @@ public class Vala.CCodeWriter : Object { } construct { _filename = value; - file_exists = FileUtils.test (_filename, FileTest.EXISTS); - if (file_exists) { - temp_filename = "%s.valatmp".printf (_filename); - stream = FileStream.open (temp_filename, "w"); - } else { - stream = FileStream.open (_filename, "w"); - } } } @@ -71,7 +64,25 @@ public class Vala.CCodeWriter : Object { public CCodeWriter (string _filename) { filename = _filename; } - + + /** + * Opens the file. + * + * @return true if the file has been opened successfully, + * false otherwise + */ + public bool open () { + file_exists = FileUtils.test (_filename, FileTest.EXISTS); + if (file_exists) { + temp_filename = "%s.valatmp".printf (_filename); + stream = FileStream.open (temp_filename, "w"); + } else { + stream = FileStream.open (_filename, "w"); + } + + return (stream != null); + } + /** * Closes the file. */ |