Examples of pwrite()


Examples of freenet.support.api.LockableRandomAccessBuffer.pwrite()

            reallyEncrypt = this.reallyEncrypt;
        }
        if(reallyEncrypt) {
            // FIXME do the encryption in memory? Test it ...
            LockableRandomAccessBuffer ret = makeRAF(size);
            ret.pwrite(0, initialContents, offset, size);
            if(readOnly) ret = new ReadOnlyRandomAccessBuffer(ret);
            return ret;
        } else {
            return factory.makeRAF(initialContents, offset, size, readOnly);
        }
View Full Code Here

Examples of freenet.support.api.LockableRandomAccessBuffer.pwrite()

            return raf;
        } else {
            if(reallyEncrypt) {
                // FIXME do the encryption in memory? Test it ...
                LockableRandomAccessBuffer ret = makeRAF(size);
                ret.pwrite(0, initialContents, offset, size);
                if(readOnly) ret = new ReadOnlyRandomAccessBuffer(ret);
                return ret;
            }
            return diskRAFFactory.makeRAF(initialContents, offset, size, readOnly);
        }
View Full Code Here

Examples of freenet.support.api.RandomAccessBuffer.pwrite()

        while(x < sz) {
            int maxRead = (int)Math.min(BUFFER_SIZE, sz - x);
            int toRead = maxRead == 1 ? 1 : r.nextInt(maxRead-1)+1;
            byte[] buf = new byte[toRead];
            for(int i=0;i<buf.length;i++) buf[i] = f.getByte(i+x);
            raf.pwrite(x, buf, 0, toRead);
            for(int i=0;i<buf.length;i++) buf[i] = (byte)~buf[i];
            raf.pread(x, buf, 0, toRead);
            for(int i=0;i<buf.length;i++) assertEquals(buf[i], f.getByte(i+x));
            x += toRead;
        }
View Full Code Here

Examples of freenet.support.api.RandomAccessBuffer.pwrite()

    protected void innerTestArray(int len, Random r, boolean readOnly) throws IOException {
        if(len == 0) return;
        byte[] buf = new byte[len];
        r.nextBytes(buf);
        RandomAccessBuffer raf = construct(len);
        raf.pwrite(0L, buf, 0, buf.length);
        for(int i=0;i<100;i++) {
            int end = len == 1 ? 1 : r.nextInt(len)+1;
            int start = r.nextInt(end);
            checkArraySectionEqualsReadData(buf, raf, start, end, readOnly);
        }
View Full Code Here

Examples of freenet.support.api.RandomAccessBuffer.pwrite()

        assertFalse(t.hasMigrated());
        assertEquals(factory.getRamUsed(), len);
        t.migrateToDisk();
        assertTrue(t.hasMigrated());
        assertEquals(factory.getRamUsed(), 0);
        raf.pwrite(0L, buf, 0, buf.length);
        checkArrayInner(buf, raf, len, r);
        raf.close();
        raf.free();
    }
   
View Full Code Here

Examples of freenet.support.io.ByteArrayRandomAccessBuffer.pwrite()

        ByteArrayRandomAccessBuffer barat = new ByteArrayRandomAccessBuffer(bytes);
        EncryptedRandomAccessBuffer erat = new EncryptedRandomAccessBuffer(types[0], barat, secret, true);
        erat.close();
        ByteArrayRandomAccessBuffer barat2 = new ByteArrayRandomAccessBuffer(bytes);
        byte[] magic = ByteBuffer.allocate(8).putLong(falseMagic).array();
        barat2.pwrite(types[0].headerLen-8, magic, 0, 8);
        thrown.expect(IOException.class);
        thrown.expectMessage("This is not an EncryptedRandomAccessBuffer!");
        EncryptedRandomAccessBuffer erat2 = new EncryptedRandomAccessBuffer(types[0], barat2, secret, false);
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.