mirror of
https://github.com/facebook/sapling.git
synced 2024-10-16 19:57:18 +03:00
1ac1128def
Summary: The `truncate` tool isn't availble on OSX, so include our own in the test suite. Reviewed By: DurhamG Differential Revision: D12815613 fbshipit-source-id: 510b2936f07c5193671baaeaec6620872c3ec982
25 lines
594 B
Python
Executable File
25 lines
594 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import argparse
|
|
|
|
|
|
if __name__ == "__main__":
|
|
ap = argparse.ArgumentParser(usage="%(prog)s [options] file...")
|
|
ap.add_argument(
|
|
"-s",
|
|
"--size",
|
|
type=int,
|
|
default=0,
|
|
help="size in bytes to truncate to",
|
|
metavar="BYTES",
|
|
)
|
|
ap.add_argument("file", nargs="+", help="file to truncate", metavar="FILE")
|
|
args = ap.parse_args()
|
|
|
|
size = args.size
|
|
if size < 0:
|
|
ap.error("size cannot be negative")
|
|
for filename in args.file:
|
|
with open(filename, "a+b") as f:
|
|
f.truncate(size)
|