Package org.jnode.command.util

Examples of org.jnode.command.util.AbstractDirectoryWalker$FileObject


    {
        if (cmd.length < 2)
        {
            throw new Exception("USAGE: touch <path>");
        }
        final FileObject file = mgr.resolveFile(cwd, cmd[1]);
        if (!file.exists())
        {
            file.createFile();
        }
        file.getContent().setLastModifiedTime(System.currentTimeMillis());
    }
View Full Code Here


        throws FileSystemException
    {
        final FileObject[] children = dir.getChildren();
        for (int i = 0; i < children.length; i++)
        {
            final FileObject child = children[i];
            System.out.print(prefix);
            System.out.print(child.getName().getBaseName());
            if (child.getType() == FileType.FOLDER)
            {
                System.out.println("/");
                if (recursive)
                {
                    listChildren(child, recursive, prefix + "    ");
View Full Code Here

            try
            {
                FileSystemManager mgr = VFS.getManager();
                System.out.println();
                System.out.println("Parsing: " + args[i]);
                FileObject file = mgr.resolveFile(args[i]);
                System.out.println("URL: " + file.getURL());
                System.out.println("getName(): " + file.getName());
                System.out.println("BaseName: " + file.getName().getBaseName());
                System.out.println("Extension: " + file.getName().getExtension());
                System.out.println("Path: " + file.getName().getPath());
                System.out.println("Scheme: " + file.getName().getScheme());
                System.out.println("URI: " + file.getName().getURI());
                System.out.println("Root URI: " + file.getName().getRootURI());
                System.out.println("Parent: " + file.getName().getParent());
                System.out.println("Type: " + file.getType());
                System.out.println("Exists: " + file.exists());
                System.out.println("Readable: " + file.isReadable());
                System.out.println("Writeable: " + file.isWriteable());
                System.out.println("Root path: " + file.getFileSystem().getRoot().getName().getPath());
                if (file.exists())
                {
                    if (file.getType().equals(FileType.FILE))
                    {
                        System.out.println("Size: " + file.getContent().getSize() + " bytes");
                    }
                    else if (file.getType().equals(FileType.FOLDER) && file.isReadable())
                    {
                        FileObject[] children = file.getChildren();
                        System.out.println("Directory with " + children.length + " files");
                        for (int iterChildren = 0; iterChildren < children.length; iterChildren++)
                        {
                            System.out.println("#" + iterChildren + ": " + children[iterChildren].getName());
                            if (iterChildren > 5)
                            {
                                break;
                            }
                        }
                    }
                    System.out.println("Last modified: " + DateFormat.getInstance().format(new Date(file.getContent().getLastModifiedTime())));
                }
                else
                {
                    System.out.println("The file does not exist");
                }
                file.close();
            }
            catch (FileSystemException ex)
            {
                ex.printStackTrace();
            }
View Full Code Here

        {
            System.err.println("Please pass the name of a file as parameter.");
            return;
        }

        FileObject fo = VFS.getManager().resolveFile(args[0]);
        long setTo = System.currentTimeMillis();
        System.err.println("set to: " + setTo);
        fo.getContent().setLastModifiedTime(setTo);
        System.err.println("after set: " + fo.getContent().getLastModifiedTime());
    }
View Full Code Here

    public void testFileChanged() throws Exception
    {
        // create a new configuration
        File input = new File("target/test-classes/testMultiConfiguration_1001.xml");
        FileObject output = getFile(getBasePath() + FILERELOAD_1001_FILE);
        output.delete();
        output.getParent().createFolder();
        copyFile(input, output);

        factory.setFileName(getBasePath() + FILERELOAD2_FILE);
        System.getProperties().remove("Id");

        CombinedConfiguration config = factory.getConfiguration(true);
        assertNotNull(config);
        config.addConfigurationListener(this);
        verify("1001", config, 15);

        // Allow time for FileMonitor to set up.
        Thread.sleep(1000);
        XMLConfiguration x = new XMLConfiguration(getBasePath() + FILERELOAD_1001_FILE);
        x.setProperty("rowsPerPage", "50");
        x.save();
        // Let FileMonitor detect the change.
        //Thread.sleep(2000);
        waitForChange();
        verify("1001", config, 50);
        output.delete();
    }
View Full Code Here

    public void testFileChanged2() throws Exception
    {
        // create a new configuration
        File input = new File("target/test-classes/testMultiConfiguration_1002.xml");
        FileObject output = getFile(getBasePath() + FILERELOAD_1002_FILE);
        output.delete();

        factory.setFileName(getBasePath() + FILERELOAD2_FILE);
        System.getProperties().remove("Id");

        CombinedConfiguration config = factory.getConfiguration(true);
        assertNotNull(config);
        config.addConfigurationListener(this);

        verify("1002", config, 50);
        Thread.sleep(1000);

        output.getParent().createFolder();
        copyFile(input, output);

        // Allow time for the monitor to notice the change.
        //Thread.sleep(2000);
        waitForChange();
        verify("1002", config, 25);
        output.delete();
    }
View Full Code Here

                      .getParentFile();

    FileSystemManager dfsm = AppEngineContextFactory.createFileSystemManager(
        new AppEngineLocalFilesSystemProvider(basePath));

    FileObject jarFile = dfsm.resolveFile("/jarfiletest.jar");
    assertThat(jarFile.getName().getURI(), equalTo("file:///jarfiletest.jar"));
    assertThat(jarFile.exists(), equalTo(true));

    FileObject jarRoot = dfsm.resolveFile("jar:file:///jarfiletest.jar!/r/library");
    assertThat(jarRoot.exists(), equalTo(true));
    assertThat(jarRoot.getType(), equalTo(FileType.FOLDER));
    assertThat(jarRoot.getChildren().length, equalTo(1));
  }
View Full Code Here

    fsm.addProvider("file", new DefaultLocalFileProvider());
    fsm.addProvider("jar", new FastJarFileProvider());
    fsm.init();

    String jarUri = getClass().getResource("/jarfiletest.jar").toURI().toString();
    FileObject object = fsm.resolveFile("jar:" + jarUri + "!/r/");

    assertThat(object.exists(), equalTo(true));
    assertThat(object.getType(), equalTo(FileType.FOLDER));

    FileObject[] children = object.getChildren();
    assertThat(children.length, equalTo(1));
    assertThat(children[0].getName().getBaseName(), equalTo("library"));
    assertThat(children[0].getType(), equalTo(FileType.FOLDER));

    object = fsm.resolveFile("jar:" + jarUri + "!/r/library/survey");

    assertThat(object.getType(), equalTo(FileType.FOLDER));
    assertThat(object.getChildren().length, equalTo(4));

  }
View Full Code Here

public class GzFileConnectionTest extends EvalTestCase {

  @Test
  public void readCompressed() throws IOException {

    FileObject file = VFS.getManager().resolveFile(getClass().getResource("test.txt.gz").getFile());
    GzFileConnection conn = new GzFileConnection(file);

    BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    assertThat(reader.readLine(), equalTo("hello world"));
  }
View Full Code Here


  @Test
  public void multipleReads() throws IOException {

    FileObject file = VFS.getManager().resolveFile(getClass().getResource("test2.txt").getFile());
    SEXP conn = topLevelContext.getSession().getConnectionTable().newConnection(new GzFileConnection(file));

    assertThat( Connections.readChar(topLevelContext, conn, 9, false), equalTo("The quick"));
    assertThat( Connections.readChar(topLevelContext, conn, 6, false), equalTo(" brown"));
View Full Code Here

TOP

Related Classes of org.jnode.command.util.AbstractDirectoryWalker$FileObject

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.