diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-05-03 19:30:49 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-05-03 19:30:49 +0100 |
commit | 505427ce2076e8e253e8b71a346b2d818acfdbb8 (patch) | |
tree | 47d503310a19aae11d40861b23f65cd132074d39 | |
parent | b7d484326666df3fc79bbad491358f1534e253b5 (diff) | |
download | extrautils-505427ce2076e8e253e8b71a346b2d818acfdbb8.tar.gz |
Add mksparse.
-rwxr-xr-x | mksparse | 26 | ||||
-rw-r--r-- | mksparse.1 | 31 |
2 files changed, 57 insertions, 0 deletions
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 <liw@liw.fi> +.\" +.\" 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 <http://www.gnu.org/licenses/>. +.\" +.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. + |