2020-07-07 21:09:53 +09:00
|
|
|
#!/usr/bin/env python2
|
2019-09-25 19:21:22 -07:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2020-03-01 17:41:45 +09:00
|
|
|
if len(sys.argv) < 4 or len(sys.argv) % 2 != 0:
|
|
|
|
sys.exit("Usage: %s OUTFILE OFFSET_1 SIZE_1 [OFFSET_N SIZE_N]...")
|
|
|
|
|
2019-09-25 19:21:22 -07:00
|
|
|
filename = sys.argv[1]
|
|
|
|
|
|
|
|
fd = os.open(filename, os.O_CREAT | os.O_TRUNC | os.O_WRONLY)
|
|
|
|
try:
|
2020-03-01 17:41:45 +09:00
|
|
|
for i in range(2, len(sys.argv), 2):
|
2020-07-07 21:09:53 +09:00
|
|
|
data = "a" * int(sys.argv[i+1])
|
|
|
|
os.lseek(fd, int(sys.argv[i]), os.SEEK_SET)
|
|
|
|
os.write(fd, data)
|
2019-09-25 19:21:22 -07:00
|
|
|
finally:
|
|
|
|
os.close(fd)
|