Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
arch: [x86_64]
include:
- { os: ubuntu-latest, dc: dmd-2.096.1, arch: x86_64 }
- { os: windows-latest, dc: dmd-2.092.0, arch: x86_64 }
- { os: windows-latest, dc: dmd-2.092.0, arch: x86_mscoff }
- { os: windows-latest, dc: dmd-2.096.0, arch: x86_64 }
- { os: windows-latest, dc: dmd-2.096.0, arch: x86_mscoff }
- { os: windows-latest, dc: dmd-2.091.1, arch: x86_64 }
- { os: windows-latest, dc: ldc-1.20.1, arch: x86_64 }

Expand Down
8 changes: 8 additions & 0 deletions source/vibe/core/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ scope:

void seek(ulong offset)
{
enforce(isOpen, "Seeking in closed file stream");
enforce(m_ctx.mode != FileMode.append, "File opened for appending, not random access. Cannot seek.");
m_ctx.ptr = offset;
}
Expand All @@ -756,6 +757,7 @@ scope:

void truncate(ulong size)
{
enforce(isOpen, "Truncating closed file stream");
enforce(m_ctx.mode != FileMode.append, "File opened for appending, not random access. Cannot truncate.");

auto res = asyncAwaitUninterruptible!(FileIOCallback,
Expand Down Expand Up @@ -785,6 +787,7 @@ scope:
@property bool empty() const { assert(this.readable); return m_ctx.ptr >= m_ctx.size; }
@property ulong leastSize()
const {
enforce(isOpen, "Reading from closed file stream");
assert(this.readable);
return m_ctx.ptr < m_ctx.size ? m_ctx.size - m_ctx.ptr : 0;
}
Expand All @@ -797,6 +800,8 @@ scope:

size_t read(scope ubyte[] dst, IOMode mode)
{
enforce(isOpen, "Reading from closed file stream");

// NOTE: cancelRead is currently not behaving as specified and cannot
// be relied upon. For this reason, we MUST use the uninterruptible
// version of asyncAwait here!
Expand All @@ -816,6 +821,8 @@ scope:

size_t write(scope const(ubyte)[] bytes, IOMode mode)
{
enforce(isOpen, "Writing to closed file stream");

// NOTE: cancelWrite is currently not behaving as specified and cannot
// be relied upon. For this reason, we MUST use the uninterruptible
// version of asyncAwait here!
Expand Down Expand Up @@ -846,6 +853,7 @@ scope:

void flush()
{
enforce(isOpen, "Flushing closed file stream");
assert(this.writable);
}

Expand Down