Commit 3f7b0dee authored by Guido van Rossum's avatar Guido van Rossum

Make readfile read the file in one fell swoop.

parent 9ee3bc9d
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import rand import rand
import posix import posix
import stat
import path import path
...@@ -40,14 +41,7 @@ def getstatusoutput(cmd): ...@@ -40,14 +41,7 @@ def getstatusoutput(cmd):
# Return a string containing a file's contents. # Return a string containing a file's contents.
# #
def readfile(fn): def readfile(fn):
fp = open(fn, 'r') return open(fn, 'r').read(posix.stat(fn)[stat.ST_SIZE])
a = ''
n = 8096
while 1:
b = fp.read(n)
if not b: break
a = a + b
return a
# Make command argument from directory and pathname (prefix space, add quotes). # Make command argument from directory and pathname (prefix space, add quotes).
......
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