Introduce a Truncate() function that works on POSIX and Windows.

Hopefully fixes the build on Windows.
Merge pull request #558 from nico/buildfix

Introduce a Truncate() function that works on POSIX and Windows.