This commit is contained in:
Vadim Lopatin 2016-10-11 15:12:31 +03:00
parent fc57073d1a
commit 324dabb7be
2 changed files with 6 additions and 3 deletions

View File

@ -1420,9 +1420,11 @@ class EditableContent {
bool load(string filename) { bool load(string filename) {
clear(); clear();
try { try {
InputStream f = new FileInputStream(filename); InputStream f;
f = new FileInputStream(filename);
scope(exit) { f.close(); } scope(exit) { f.close(); }
return load(f, filename); bool res = load(f, filename);
return res;
} catch (Exception e) { } catch (Exception e) {
Log.e("Exception while trying to read file ", filename, " ", e.toString); Log.e("Exception while trying to read file ", filename, " ", e.toString);
clear(); clear();

View File

@ -22,7 +22,8 @@ class FileInputStream : InputStream {
_file = std.stdio.File(filename, "rb"); _file = std.stdio.File(filename, "rb");
} }
void close() { void close() {
_file.close(); if (isOpen)
_file.close();
} }
size_t read(ubyte[] buffer) { size_t read(ubyte[] buffer) {
ubyte[] res = _file.rawRead(buffer); ubyte[] res = _file.rawRead(buffer);