Package org.apache.derby.impl.io.vfmem

Examples of org.apache.derby.impl.io.vfmem.VirtualFile


    /**
     * Tests that {@code listChildren} doesn't include too many entries.
     */
    public void testListChilderen() {
        DataStore store = getStore();
        VirtualFile dir1 = new VirtualFile(PathUtilTest.abs("mydir"), store);
        VirtualFile dir2 = new VirtualFile(
                PathUtilTest.abs("mydirectory"), store);
        VirtualFile file1 = new VirtualFile(
                PathUtilTest.joinAbs("mydir", "file1.txt"), store);
        VirtualFile file2 = new VirtualFile(
                PathUtilTest.joinAbs("mydirectory", "file2.txt"), store);
        assertTrue(dir1.mkdirs());
        assertTrue(dir1.exists());
        assertTrue(dir1.isDirectory());
        assertTrue(dir2.mkdirs());
        assertTrue(dir2.exists());
        assertTrue(dir2.isDirectory());
        assertTrue(file1.createNewFile());
        assertTrue(file1.exists());
        assertFalse(file1.isDirectory());
        assertTrue(file2.createNewFile());
        assertTrue(file2.exists());
        assertFalse(file2.isDirectory());
        // We should only get one child; file1.txt
        String[] children = dir1.list();
        assertEquals(1, children.length);
        assertEquals(file1.getName(), children[0]);
        // Test that the same path ending with the separator results in the
        // same list being returned.
        VirtualFile dir1abs = new VirtualFile(
                PathUtilTest.joinAbs("mydir", ""), store);
        assertFalse(dir1.getName().equals(dir1abs.getName()));
        String[] childrenAbs = dir1abs.list();
        assertEquals(1, childrenAbs.length);
        assertEquals(children[0], childrenAbs[0]);
        // The deleteAll below shouldn't delete "mydirectory" and "file2.txt"..
        assertFalse(dir1.delete());
        assertTrue(dir1.deleteAll());
View Full Code Here


    public void testCreateRoot() {
        DataStore store = new DataStore("testCreateRootStore");
        String path = PathUtilTest.joinAbs("these", "are", "directories");
        assertTrue(store.createAllParents(path));
        assertNotNull(store.createEntry(path, true));
        VirtualFile vf = new VirtualFile(path, store);
        assertTrue(vf.exists());
        assertTrue(vf.isDirectory());

        // Also test one Windows specific root.
        path = PathUtilTest.join("c:", "Documents and Settings", "directories");
        assertTrue(store.createAllParents(path));
        assertNotNull(store.createEntry(path, true));
        vf = new VirtualFile(path, store);
        assertTrue(vf.exists());
        assertTrue(vf.isDirectory());
    }
View Full Code Here

                        this.dbData = DUMMY_STORE;
                    }
                }
            }
            // Specify the data directory and the temp directory.
            dataDirectory = new VirtualFile(canonicalName, dbData);
            tempDir = new VirtualFile(normalizePath(canonicalName, "tmp"),
                                      dbData);

        // Handle cases where the database name is null, but a system home
        // directory has been specified.
        } else if (home != null) {
            // Return the "system home directory" and specify a temporary
            // directory for it (may never by used).
            // As databases are created, the dummy will contain the
            // directory names of the database locations, but the
            // databases themselves will be stored in separate stores.
            final String absHome = new File(home).getCanonicalPath();
            dbData = DUMMY_STORE;
            dataDirectory = new VirtualFile(absHome, dbData);
            tempDir = new VirtualFile(getSeparator() + "tmp", dbData);
        }

        // Create the temporary directory, if one has been specified.
        // Creating the temporary directory too early casues the
        // BaseDataFileFactory to fail, hence the check for uniqueName.
View Full Code Here

        // files are stored.
        if (path == null) {
            // Return the database directory as described by StorageFactory.
            return dataDirectory;
        }
        return new VirtualFile(normalizePath(path), dbData);
    }
View Full Code Here

     * @param directoryName the name of the parent directory
     * @param fileName the name of the file
     * @return A path handle.
     */
    public StorageFile newStorageFile(String directoryName, String fileName) {
            return new VirtualFile(
                                normalizePath(directoryName, fileName), dbData);
    }
View Full Code Here

                        this.dbData = DUMMY_STORE;
                    }
                }
            }
            // Specify the data directory and the temp directory.
            dataDirectory = new VirtualFile(canonicalName, dbData);
            tempDir = new VirtualFile(normalizePath(canonicalName, "tmp"),
                                      dbData);

        // Handle cases where the database name is null, but a system home
        // directory has been specified.
        } else if (home != null) {
            // Return the "system home directory" and specify a temporary
            // directory for it (may never by used).
            // As databases are created, the dummy will contain the
            // directory names of the database locations, but the
            // databases themselves will be stored in separate stores.
            final String absHome = new File(home).getCanonicalPath();
            dbData = DUMMY_STORE;
            dataDirectory = new VirtualFile(absHome, dbData);
            tempDir = new VirtualFile(getSeparator() + "tmp", dbData);
        }

        // Create the temporary directory, if one has been specified.
        // Creating the temporary directory too early casues the
        // BaseDataFileFactory to fail, hence the check for uniqueName.
View Full Code Here

        // files are stored.
        if (path == null) {
            // Return the database directory as described by StorageFactory.
            return dataDirectory;
        }
        return new VirtualFile(normalizePath(path), dbData);
    }
View Full Code Here

     * @param directoryName the name of the parent directory
     * @param fileName the name of the file
     * @return A path handle.
     */
    public StorageFile newStorageFile(String directoryName, String fileName) {
            return new VirtualFile(
                                normalizePath(directoryName, fileName), dbData);
    }
View Full Code Here

                        this.dbData = DUMMY_STORE;
                    }
                }
            }
            // Specify the data directory and the temp directory.
            dataDirectory = new VirtualFile(canonicalName, dbData);
            tempDir = new VirtualFile(normalizePath(canonicalName, "tmp"),
                                      dbData);

        // Handle cases where the database name is null, but a system home
        // directory has been specified.
        } else if (home != null) {
            // Return the "system home directory" and specify a temporary
            // directory for it (may never by used).
            // As databases are created, the dummy will contain the
            // directory names of the database locations, but the
            // databases themselves will be stored in separate stores.
            final String absHome = new File(home).getCanonicalPath();
            dbData = DUMMY_STORE;
            dataDirectory = new VirtualFile(absHome, dbData);
            tempDir = new VirtualFile(getSeparator() + "tmp", dbData);
        }

        // Create the temporary directory, if one has been specified.
        // Creating the temporary directory too early casues the
        // BaseDataFileFactory to fail, hence the check for uniqueName.
View Full Code Here

        // files are stored.
        if (path == null) {
            // Return the database directory as described by StorageFactory.
            return dataDirectory;
        }
        return new VirtualFile(normalizePath(path), dbData);
    }
View Full Code Here

TOP

Related Classes of org.apache.derby.impl.io.vfmem.VirtualFile

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.