Fix FileStream.close and let the file test clean up after itself.

This commit is contained in:
Sönke Ludwig 2016-10-06 22:15:25 +02:00
parent cf75d968d5
commit 5bbf07beb8
2 changed files with 14 additions and 2 deletions

View file

@ -393,8 +393,17 @@ struct FileStream {
m_size = eventDriver.files.getSize(fd);
}
this(this) { eventDriver.files.addRef(m_fd); }
~this() { eventDriver.files.releaseRef(m_fd); }
this(this)
{
if (m_fd != FileFD.init)
eventDriver.files.addRef(m_fd);
}
~this()
{
if (m_fd != FileFD.init)
eventDriver.files.releaseRef(m_fd);
}
@property int fd() { return m_fd; }

View file

@ -21,4 +21,7 @@ void main()
f.seek(2);
f.read(dst);
assert(dst[] == [3, 4, 5, 6, 7]);
f.close();
removeFile("test.dat");
}