-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#! /usr/bin/env python3 | ||
## | ||
import os | ||
import sys | ||
|
||
BLOCKSIZE = 128 * 1000 | ||
|
||
|
||
def rewrite_file(path): | ||
# Get size of file | ||
size = os.path.getsize(path) | ||
|
||
# Iterate through file | ||
with open(path, "rb+") as file: | ||
# Iterate through steps of block size | ||
for i in range(0, size, BLOCKSIZE): | ||
# Seek to offset and read | ||
file.seek(i) | ||
a, b = file.read(2) | ||
|
||
# Seek back to offset and write | ||
file.seek(i) | ||
file.write(bytes([a, b])) | ||
|
||
|
||
def main(): | ||
rewrite_file(sys.argv[1]) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |