import std.stdio: File;
void truncate(File file, long offset) {
version (Windows) {
import core.sys.windows.windows: SetEndOfFile;
file.seek(offset);
SetEndOfFile(file.windowsHandle());
}
version (Posix) {
import core.sys.posix.unistd: ftruncate;
ftruncate(file.fileno(), offset);
}
}
I needed a truncate function on the `std.stdio.File` object, so I
made this function. Does it look okay? Are there any
cross-platform improvements you can think of that should be added?
- Truncate is missing from std.stdio.File... spikespaz via Digitalmars-d
- Re: Truncate is missing from std.s... Patrick Schluter via Digitalmars-d
