Commit 3cb93096 authored by Kirill Smelkov's avatar Kirill Smelkov

util += writefile

A counterpart to readfile - to write a file instead of reading it.
We will need this function in the next patch.
parent adec18bd
...@@ -241,3 +241,9 @@ def asbinstream(stream): ...@@ -241,3 +241,9 @@ def asbinstream(stream):
def readfile(path): # -> data(bytes) def readfile(path): # -> data(bytes)
with open(path, 'rb') as _: with open(path, 'rb') as _:
return _.read() return _.read()
# writefile writes data to file at path.
# if the file existed before its old data is erased.
def writefile(path, data):
with open(path, 'wb') as _:
_.write(data)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment