MCPcopy Create free account
hub / github.com/ActiveState/code / zero

Function zero

recipes/Python/578205_Zero_Batch_Programs/recipe-578205.py:32–43  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

30 ERROR = True
31
32def zero(path):
33 size = os.path.getsize(path)
34 if size:
35 data = open(path, 'wb')
36 todo = size
37 if todo >= 2 ** 20:
38 buff = '\x00' * 2 ** 20
39 while todo >= 2 ** 20:
40 data.write(buff)
41 todo = size - data.tell()
42 data.write('\x00' * todo)
43 data.close()
44
45if __name__ == '__main__':
46 main(zero)

Callers

nothing calls this directly

Calls 4

openFunction · 0.50
writeMethod · 0.45
tellMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected