diff --git a/dub.sdl b/dub.sdl index f0cdd03..8c4688f 100644 --- a/dub.sdl +++ b/dub.sdl @@ -4,7 +4,7 @@ authors "Sönke Ludwig" copyright "Copyright © 2016-2018, rejectedsoftware e.K." license "MIT" -dependency "eventcore" version="~>0.8.39" +dependency "eventcore" version="~>0.8.40" dependency "stdx-allocator" version="~>2.77.0" targetName "vibe_core" diff --git a/source/vibe/core/file.d b/source/vibe/core/file.d index ac9cdf0..8bc7564 100644 --- a/source/vibe/core/file.d +++ b/source/vibe/core/file.d @@ -1,7 +1,7 @@ /** File handling functions and types. - Copyright: © 2012-2016 RejectedSoftware e.K. + Copyright: © 2012-2018 RejectedSoftware e.K. License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Sönke Ludwig */ @@ -13,7 +13,7 @@ import vibe.core.internal.release; import vibe.core.log; import vibe.core.path; import vibe.core.stream; -import vibe.internal.async : asyncAwait; +import vibe.internal.async : asyncAwait, asyncAwaitUninterruptible; import core.stdc.stdio; import core.sys.posix.unistd; @@ -452,6 +452,15 @@ struct FileStream { ulong tell() nothrow { return ctx.ptr; } + void truncate(ulong size) + { + auto res = asyncAwaitUninterruptible!(FileIOCallback, + cb => eventDriver.files.truncate(m_fd, size, cb) + ); + enforce(res[1] == IOStatus.ok, "Failed to resize file."); + m_ctx.size = size; + } + /// Closes the file handle. void close() {