From 505427ce2076e8e253e8b71a346b2d818acfdbb8 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 3 May 2011 19:30:49 +0100 Subject: Add mksparse. --- mksparse | 26 ++++++++++++++++++++++++++ mksparse.1 | 31 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 mksparse create mode 100644 mksparse.1 diff --git a/mksparse b/mksparse new file mode 100755 index 0000000..8d88399 --- /dev/null +++ b/mksparse @@ -0,0 +1,26 @@ +#!/usr/bin/python + +import cliapp + + +class MakeSparseFile(cliapp.Application): + + def add_settings(self): + self.settings.add_bytesize_setting(['size'], + 'size of whole to append to file') + + def process_args(self, filenames): + if self.settings['size'] > 0: + for filename in filenames: + self.append_hole(filename, self.settings['size']) + + def append_hole(self, filename, size): + f = open(filename, 'r+b') + f.seek(size - 1, 2) + print 'pos:', f.tell() + f.write('\0') + f.close() + + +if __name__ == '__main__': + MakeSparseFile().run() diff --git a/mksparse.1 b/mksparse.1 new file mode 100644 index 0000000..e7b54e4 --- /dev/null +++ b/mksparse.1 @@ -0,0 +1,31 @@ +.\" Copyright 2011 Lars Wirzenius +.\" +.\" This program is free software: you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation, either version 3 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program. If not, see . +.\" +.TH MKSPARSE 1 +.SH NAME +mksparse \- add a hole to the end of a file +.SH SYNOPSIS +.B mksparse +.RB [ \-\-size =\fISIZE\fR] +.SH DESCRIPTION +.B mksparse +appends a "whole" to the end of an existing file. +It appends one real NUL byte at the end of the whole. +.SH OPTIONS +.TP +.BR \-\-size "=\fISIZE" +Size of the whole to append. +The actual size is one byte less. + -- cgit v1.2.1