FileStream: Forbid seek(.) or truncate(.) when appending to a file

Those functions do not work for files opened for appending. Make this clear.
This commit is contained in:
v1ne 2019-07-26 00:27:50 +02:00
parent 3ebb065509
commit ce9faec1c1

View file

@ -472,6 +472,7 @@ struct FileStream {
void seek(ulong offset)
{
enforce(ctx.mode != FileMode.append, "File opened for appending, not random access. Cannot seek.");
ctx.ptr = offset;
}
@ -479,6 +480,8 @@ struct FileStream {
void truncate(ulong size)
{
enforce(ctx.mode != FileMode.append, "File opened for appending, not random access. Cannot truncate.");
auto res = asyncAwaitUninterruptible!(FileIOCallback,
cb => eventDriver.files.truncate(m_fd, size, cb)
);