Package org.jnode.fs

Examples of org.jnode.fs.FSEntry


    }
   
    @Test
    public void testGetRootEntry() throws Exception {
        setUp();
        FSEntry rootEntry = getFs().getRootEntry();
        log.debug(FSUtils.toString(rootEntry, false));
    }
View Full Code Here


                // success
            }
            assertContainsOnly("must be empty", rootDir.iterator(), getEmptyDirNames(config, true));
        } else {
            try {
                FSEntry entry = rootDir.addDirectory(dirName);
                // success
                log.debug("added directory entry=" + FSUtils.toString(entry, true));
            } catch (ReadOnlyFileSystemException e) {
                fail("addDirectory must succeed in read/write mode");
            }
            assertContainsOnly("must contain " + dirName, rootDir.iterator(),
                TestUtils.append(getEmptyDirNames(config, true), new String[]{dirName}));
            FSEntry gotEntry = rootDir.getEntry(dirName);
            assertNotNull("must contain the added directory", gotEntry);
            assertEquals("returned bad entry", dirName, gotEntry.getName());
        }
        log.debug("Root dir after testAddDirectory :\n" + rootDir);
        TestUtils.listEntries(rootDir.iterator());
    }
View Full Code Here

            }

            assertContainsOnly("must be empty", rootDir.iterator(), getEmptyDirNames(config, true));
        } else {
            try {
                FSEntry entry = rootDir.addFile(fileName);
                // success
                log.debug("added file entry=" + FSUtils.toString(entry, true));
            } catch (ReadOnlyFileSystemException e) {
                fail("addFile must succeed in read/write mode");
            }
            assertContainsOnly("must contain " + fileName, rootDir.iterator(),
                TestUtils.append(getEmptyDirNames(config, true), new String[]{fileName}));
            FSEntry gotEntry = rootDir.getEntry(fileName);
            assertNotNull("must contain the added file", gotEntry);
            assertEquals("returned bad entry", fileName, gotEntry.getName());
        }
        log.debug("Root dir after testAddFile :\n" + rootDir);
        TestUtils.listEntries(rootDir.iterator());
    }
View Full Code Here

        if (!config.isReadOnly()) {
            setUp();

            String filename = "a file to test.text";
            FSDirectory rootDir = getFs().getRootEntry().getDirectory();
            FSEntry entry = rootDir.addFile(filename);
            FSEntry gotEntry = rootDir.getEntry(filename);
            assertNotNull("must contain the added file", gotEntry);
            assertEquals("returned bad entry", filename, gotEntry.getName());

            log.debug("entry before remount=" + FSUtils.toString(entry, true));
            remountFS(config, config.isReadOnly());

            FSDirectory rootDir2 = getFs().getRootEntry().getDirectory();
            TestUtils.listEntries(rootDir2.iterator());
            assertFalse("same ref (rootDir) after remount", rootDir == rootDir2);
            FSEntry gotEntry2 = rootDir2.getEntry(filename);
            assertFalse("same ref (gotEntry2) after remount", gotEntry == gotEntry2);
            assertNotNull("must contain the added file", gotEntry2);
            assertEquals("returned bad entry", filename, gotEntry2.getName());
            log.debug("entry after remount=" + FSUtils.toString(gotEntry2, true));
        }
    }
View Full Code Here

            String filename = "a file to test.text";
            FSDirectory rootDir = getFs().getRootEntry().getDirectory();
            /*FSEntry entry =*/
            rootDir.addFile(filename);
            FSEntry gotEntry = rootDir.getEntry(filename);
            assertNotNull("must contain the added file", gotEntry);
            assertEquals("returned bad entry", filename, gotEntry.getName());

            rootDir.remove(filename);
            assertNull("must not contain the removed file", rootDir.getEntry(filename));

            remountFS(config, config.isReadOnly());

            FSDirectory rootDir2 = getFs().getRootEntry().getDirectory();
            TestUtils.listEntries(rootDir2.iterator());
            assertFalse("same ref (rootDir) after remount", rootDir == rootDir2);
            FSEntry gotEntry2 = rootDir2.getEntry(filename);
            assertNull("must not contain the removed file: FS=" + getFs().getType().getName(), gotEntry2);
        }
    }
View Full Code Here

    /**
     * Does the given file exist?
     */
    public boolean fileExists(String file) {
        final FSEntry entry = getEntry(file);
        return (entry != null);
    }
View Full Code Here

    /**
     * Is the given File a plain file?
     */
    public boolean isFile(String file) {
        final FSEntry entry = getEntry(file);
        return (entry != null) && (entry.isFile());
    }
View Full Code Here

    /**
     * Is the given File a directory?
     */
    public boolean isDirectory(String file) {
        final FSEntry entry = getEntry(file);
        return (entry != null) && (entry.isDirectory());
    }
View Full Code Here

     * exist.
     *
     * @param file
     */
    public long getLength(String file) {
        final FSEntry entry = getEntry(file);
        if (entry != null) {
            if (entry.isFile()) {
                try {
                    return entry.getFile().getLength();
                } catch (IOException ex) {
                    log.debug("Error in getLength", ex);
                    return 0;
                }
            } else {
View Full Code Here

     * Gets the last modification date of the given file.
     *
     * @param file
     */
    public long getLastModified(String file) {
        final FSEntry entry = getEntry(file);
        if (entry != null) {
            try {
                return entry.getLastModified();
            } catch (IOException ex) {
                return 0;
            }
        } else {
            return 0;
View Full Code Here

TOP

Related Classes of org.jnode.fs.FSEntry

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.