From 1eb578796c98f457546059b66eb98fd0efc8e690 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 30 Jan 2013 04:17:33 +0100 Subject: Drop padding in blk* when finalizing file --- src/util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/util.cpp') diff --git a/src/util.cpp b/src/util.cpp index 6ea5e1d83..4ac66d466 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1161,6 +1161,14 @@ int GetFilesize(FILE* file) return nFilesize; } +bool TruncateFile(FILE *file, unsigned int length) { +#if defined(WIN32) + return _chsize(_fileno(file), length) == 0; +#else + return ftruncate(fileno(file), length) == 0; +#endif +} + // this function tries to make a particular range of a file allocated (corresponding to disk space) // it is advisory, and the range specified in the arguments will never contain live data void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) { -- cgit v1.2.3