Examples of FSFile


Examples of org.jnode.fs.FSFile

                FatTest.class.getClassLoader().getResource("menu.lst").openConnection();
        //byte[] buf = new byte[urlConn.getContentLength()];
        ByteBuffer buf = ByteBuffer.allocate(urlConn.getContentLength());
        FileUtils.copy(urlConn.getInputStream(), buf.array());

        final FSFile fh1 = dir.addFile("test.lst").getFile();
        fh1.setLength(urlConn.getContentLength());
        fh1.write(0, buf);

        final FSFile fh2 = bgDir.addFile("menu.lst").getFile();
        fh2.setLength(urlConn.getContentLength());
        fh2.write(0, buf);

        fs.flush();

        //newFd.stop();
        newFd.close();
View Full Code Here

Examples of org.jnode.fs.FSFile

    @Test
    public void testRead() throws Throwable {
        setUp();

        FSFile file = prepareFile(config);

        Monitor monitor = new Monitor("testRead");

        createReaders(monitor, file);
View Full Code Here

Examples of org.jnode.fs.FSFile

    @Test @Ignore("Fix concurrency issues")
    public void testWrite() throws Throwable {
        if (!config.isReadOnly()) {
            setUp();

            FSFile file = prepareFile(config);
            Monitor monitor = new Monitor("testWrite");
            createWriters(monitor, file);
            monitor.waitAll();
            assertTrue("integrity test failed", isGoodResultFile(file));
        }
View Full Code Here

Examples of org.jnode.fs.FSFile

    @Test @Ignore("Fix concurrency issues")
    public void testReadWrite() throws Throwable {
        setUp();

        FSFile file = prepareFile(config);
        Monitor monitor = new Monitor("testReadWrite");
        createReaders(monitor, file);
        if (!config.isReadOnly()) {
            createWriters(monitor, file);
        }
View Full Code Here

Examples of org.jnode.fs.FSFile

        remountFS(config, false);

        final String fileName = "RWTest";
        FSEntry rootEntry = getFs().getRootEntry();
        FSEntry entry = rootEntry.getDirectory().addFile(fileName);
        FSFile file = entry.getFile();
        file.setLength(FILE_SIZE_IN_WORDS * 2);
        file.flush();
        assertSize("Bad file size", FILE_SIZE_IN_WORDS * 2, file.getLength());

        remountFS(config, getFs().isReadOnly());

        rootEntry = getFs().getRootEntry();
        entry = rootEntry.getDirectory().getEntry(fileName);
        file = entry.getFile();
        assertSize("Bad file size", FILE_SIZE_IN_WORDS * 2, file.getLength());

        return file;
    }
View Full Code Here

Examples of org.jnode.fs.FSFile

        // remount FS in write mode, and write some data to our test file
        remountFS(config, false); // false = read/write mode

        FSDirectory rootDir = fs.getRootEntry().getDirectory();
        ByteBuffer data = ByteBuffer.wrap(TestUtils.getTestData(fileSizeInWords));
        FSFile file = rootDir.addFile(fileName).getFile();
        file.write(0, data);
        file.flush();

        // remount FS in readOnly mode
        remountFS(config, oldReadOnly);

        return data.array();
View Full Code Here

Examples of org.jnode.fs.FSFile

        actual.append(indent);
        actual.append(entry.getName());
        actual.append("; ");

        if (entry.isFile()) {
            FSFile file = entry.getFile();
            actual.append(file.getLength());
            actual.append("; ");
            actual.append(getMD5Digest(file));
            actual.append("\n");

            if (file instanceof FSFileStreams) {
View Full Code Here

Examples of org.jnode.fs.FSFile

            Device device = new FileDevice(file, "r");
            FileSystem<?> fileSystem = new NTFSFileSystemType().create(device, true);
            FSDirectory root = fileSystem.getRootEntry().getDirectory();

            // Check the big file.  Every byte should be readable as zero, hopefully.
            FSFile bigFile = root.getEntry("bigfile.dat").getFile();
            int increment = 1024 * 1024;
            assertEquals("Wrong file length for big file", 120 * increment, bigFile.getLength());
            byte[] actual = new byte[increment];
            for (int i = 0; i < 120 * increment; i += increment) {
                bigFile.read(i, ByteBuffer.wrap(actual));
            }

            fileSystem.close();
        } catch (FileNotFoundException e) {
            fail("Unexpected exception : " + e.getMessage());
View Full Code Here

Examples of org.jnode.fs.FSFile

            // The first file has 256 bytes of real data at the front, and the rest is sparse.
            byte[] expectedContents = new byte[10240];
            for (int i = 0; i < 256; i++) {
                expectedContents[i] = (byte) i;
            }
            FSFile sparseFile1 = root.getEntry("sparsefile1.dat").getFile();
            assertEquals("Wrong length for sparse file 2", expectedContents.length, sparseFile1.getLength());
            byte[] actualContents = new byte[expectedContents.length];
            sparseFile1.read(0, ByteBuffer.wrap(actualContents));
            Arrays.fill(actualContents, 256, 4096, (byte) 0); // slack space contains garbage, so wipe it.
            assertEquals("Wrong contents for sparse file 1", expectedContents, actualContents);
            // The second file is 100% sparse.
            expectedContents = new byte[10240];
            FSFile sparseFile2 = root.getEntry("sparsefile2.dat").getFile();
            assertEquals("Wrong length for sparse file 2", expectedContents.length, sparseFile2.getLength());
            actualContents = new byte[expectedContents.length];
            sparseFile2.read(0, ByteBuffer.wrap(actualContents));
            assertEquals("Wrong contents for sparse file 2", expectedContents, actualContents);
            fileSystem.close();
        } catch (FileNotFoundException e) {
            fail("Unexpected exception : " + e.getMessage());
        } catch (IOException e) {
View Full Code Here

Examples of org.jnode.fs.FSFile

     * @param handle file handle to close.
     *
     * @throws IOException if file is not already open.
     */
    public synchronized void close(FileHandleImpl handle) throws IOException {
        final FSFile file = handle.getFile();
        final FileData fd = openFiles.get(file);
        if (fd != null) {
            fd.close(handle);
            if (!fd.hasHandles()) {
                openFiles.remove(file);
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.