Ejemplo n.º 1
0
def _DoTestBufferRead(file, expected):
    # read in a couple of chunks, just to test that our various arg combinations work.
    buffer = _xpcom.AllocateBuffer(50)
    got = ''
    while 1:
        # Note - we need to reach into the file object so we
        # can get at the native buffer supported function.
        num = file.inputStream.read(buffer)
        if num == 0:
            break
        got = got + str(buffer[:num])
    if got != expected:
        raise RuntimeError, "Reading '%s' failed - got %d bytes, but expected %d bytes" % (
            file, len(got), len(expected))
Ejemplo n.º 2
0
# The contents of this file are subject to the Mozilla Public License Version