Package org.jnode.fs

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


            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

            // 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

     * @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

     *
     * @throws IOException if file is not already open.
     */
    public synchronized FileHandleImpl dup(FileHandleImpl handle, VMOpenMode newMode)
        throws IOException {
        final FSFile file = handle.getFile();
        final FileData fd = openFiles.get(file);
        if (fd != null) {
            return fd.dup(handle, newMode);
        } else {
            throw new IOException("FileHandle tried to dup an unknown file!!");
View Full Code Here

     */
    public final synchronized FSFile getFile(FSEntry entry) throws IOException {
        if (isClosed())
            throw new IOException("FileSystem is closed");

        FSFile file = files.get(entry);
        if (file == null) {
            file = createFile(entry);
            files.put(entry, file);
        }
        return file;
View Full Code Here

                    is.close();
                    baos.flush();
                    baos.close();

                    ByteBuffer data = ByteBuffer.wrap(baos.toByteArray());
                    FSFile fmp = (FSFile) libDir.addFile("flavormap.properties");
                    fmp.write(0, data);
                    fmp.flush();
                }
            } catch (DeviceAlreadyRegisteredException ex) {
                log.error("RAMFS is allready running.");
            } catch (FileSystemException ex) {
                log.error("Cannot mount " + type.getName() + " filesystem ", ex);
View Full Code Here

        final ByteBuffer buf = ByteBuffer.allocate((int) size);
        InputStream is = new FileInputStream(src);
        FileUtils.copy(is, buf.array());
        is.close();

        final FSFile fh = dir.addFile(fname).getFile();
        fh.setLength(size);
        //fh.write(0, buf, 0, buf.length);
        fh.write(0, buf);

        log("Added " + src + " as " + fname + " size " + (size / 1024) + "Kb");
    }
View Full Code Here

TOP

Related Classes of org.jnode.fs.FSFile

Copyright © 2018 www.massapicom. 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.