summaryrefslogtreecommitdiff
path: root/src/AbstractDiskWriter.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-01-11 18:35:54 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-01-11 18:35:54 +0900
commite0ea88ebcf71674ab4f56ae542f0f556cd1f434d (patch)
tree486f43cceb86527e6056c252f5b733b6cb8bbcaa /src/AbstractDiskWriter.cc
parent357e4b1a77132705432345e0f54ec50ab07a73ab (diff)
mingw32: Make NTFS sparse file on --file-allocation=trunc
Diffstat (limited to 'src/AbstractDiskWriter.cc')
-rw-r--r--src/AbstractDiskWriter.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc
index dea6f0ee..578f64e9 100644
--- a/src/AbstractDiskWriter.cc
+++ b/src/AbstractDiskWriter.cc
@@ -463,11 +463,23 @@ void AbstractDiskWriter::truncate(int64_t length)
}
}
-void AbstractDiskWriter::allocate(int64_t offset, int64_t length)
+void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
{
if(fd_ == A2_BAD_FD) {
throw DL_ABORT_EX("File not yet opened.");
}
+ if(sparse) {
+#ifdef __MINGW32__
+ DWORD bytesReturned;
+ if(!DeviceIoControl(fd_, FSCTL_SET_SPARSE, 0, 0, 0, 0,
+ &bytesReturned, 0)) {
+ A2_LOG_WARN(fmt("Making file sparse failed or pending: %s",
+ fileStrerror(GetLastError()).c_str()));
+ }
+#endif // __MINGW32__
+ truncate(offset+length);
+ return;
+ }
#ifdef HAVE_SOME_FALLOCATE
# ifdef __MINGW32__
truncate(offset+length);