All pastes #12920 Raw Edit

Anonymous

public python v1 · immutable
#12920 ·published 2005-05-29 22:56 UTC
rendered paste body
    def get_contents(self):        if not self.rexists():            return ''        abspath = self.rfile().abspath        try:            return open(abspath, "rb").read()        except MemoryError, e:            raise MemoryError('Not enough memory to read the entire file "%s"' % abspath)        except IOError, e:            from sys import stderr            print>>stderr, 'WRN: Fast access failed, using slow access to the (probably) network share "%s"' % abspath            buf = ''            MAGIC_UNC_SIZE = 0x2c29fff            bytesleft = os.path.getsize(abspath)            f = open(abspath, "rb")            while bytesleft > len(buf):                new_buf = f.read(MAGIC_UNC_SIZE)                if not new_buf:                    raise e                buf += new_buf            f.close()