Examples of FSFile


Examples of de.waldheinz.fs.FsFile

              // Create the entry on the floppy
                FsDirectoryEntry floppyEntry = fs.getRoot().addFile(children[i]);
                //floppyEntry.setName(children[i]);
                System.out.print("- Processing file: "+children[i]+" ");
               
                FsFile floppyfile = floppyEntry.getFile();
             
              // Copy the file over               
              if (aFile.isFile()) {
                FileInputStream fis= new FileInputStream(aFile);
               
                FileChannel fci = fis.getChannel();
                ByteBuffer buffer = ByteBuffer.allocate(1024);
               
                long counter=0;
                  int len;
                 
               //   http://www.kodejava.org/examples/49.html
               // Here we start to read the source file and write it
                    // to the destination file. We repeat this process
                    // until the read method of input stream channel return
                    // nothing (-1).
                    while(true)
                    {
                        // read a block of data and put it in the buffer
                        int read = fci.read(buffer);

                        // did we reach the end of the channel? if yes
                        // jump out the while-loop
                        if (read == -1)
                            break;

                        // flip the buffer
                        buffer.flip();

                        // write to the destination channel
                    System.out.print(".");
                      floppyfile.write(counter*1024, buffer);
                      counter++;

                       
                        // clear the buffer and user it for the next read
                        // process
                        buffer.clear();
                    }
                    System.out.println();
                   
                    floppyfile.flush();

            fis.close();
              }
        } catch (IOException e) {
            // TODO Auto-generated catch block
View Full Code Here

Examples of io.fathom.cloud.storage.FsFile

        return response.build();
    }

    private Response doAnonymousRead() throws CloudException {
        FsFile found = null;

        FsBucket bucket;
        User user = null;

        // Check for a public file
View Full Code Here

Examples of io.fathom.cloud.storage.FsFile

        response.header("Server", "JustInoughOpenStack");
        return response.build();
    }

    private FsFile findFile() throws CloudException {
        FsFile found;

        User user = null;

        FsBucket bucket;
View Full Code Here

Examples of io.fathom.cloud.storage.FsFile

        return found;
    }

    @HEAD
    public Response getFileHead() throws CloudException {
        FsFile found = findFile();
        return buildReadResponse(httpRequest, fs, found);
    }
View Full Code Here

Examples of io.fathom.cloud.storage.FsFile

        return buildReadResponse(httpRequest, fs, found);
    }

    @GET
    public Response getFile() throws CloudException {
        FsFile found = findFile();
        return buildReadResponse(httpRequest, fs, found);
    }
View Full Code Here

Examples of org.exist.versioning.svn.core.internal.io.fs.FSFile

        File propertiesFile = getAdminFile("all-wcprops");
        if (!propertiesFile.exists()) {
            return wcPropsCache;
        }

        FSFile wcpropsFile = null;
        try {
            wcpropsFile = new FSFile(propertiesFile);
            SVNProperties wcProps = wcpropsFile.readProperties(false, true);
            SVNVersionedProperties entryWCProps = new SVNProperties13(wcProps);
            wcPropsCache.put(getThisDirName(), entryWCProps);
           
            String name = null;
            StringBuffer buffer = new StringBuffer();
            while(true) {
                try {
                    name = wcpropsFile.readLine(buffer);
                } catch (SVNException e) {
                    if (e.getErrorMessage().getErrorCode() == SVNErrorCode.STREAM_UNEXPECTED_EOF && buffer.length() > 0) {
                        SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, "Missing end of line in wcprops file for ''{0}''", getRoot());
                        SVNErrorManager.error(err, e, SVNLogType.WC);
                    }
                    break;
                }
                wcProps = wcpropsFile.readProperties(false, true);
                entryWCProps = new SVNProperties13(wcProps);
                wcPropsCache.put(name, entryWCProps);
                buffer.delete(0, buffer.length());
            }
        } catch (SVNException svne) {
            SVNErrorMessage err = svne.getErrorMessage().wrap("Failed to load properties from disk");
            SVNErrorManager.error(err, SVNLogType.DEFAULT);
        } finally {
            wcpropsFile.close();
        }
        return wcPropsCache;
    }
View Full Code Here

Examples of org.jnode.fs.FSFile

     * @param file
     * @return
     * @throws IOException
     */
    public static FSFile createFile(FSDirectory parent, String file) throws IOException {
        FSFile f = parent.addFile(file).getFile();
        ByteBuffer data = ByteBuffer.wrap(TestUtils.getTestData(FILE_SIZE_IN_WORDS));
        f.write(0, data);
        f.flush();
        return f;
    }
View Full Code Here

Examples of org.jnode.fs.FSFile

        setUp();

        final String fileName = "RWTest";

        FSDirectory rootDir = getFs().getRootEntry().getDirectory();
        FSFile file = null;
        ByteBuffer data = ByteBuffer.wrap(TestUtils.getTestData(FILE_SIZE_IN_WORDS));

        if (config.isReadOnly()) {
            try {
                file = rootDir.addFile(fileName).getFile();
                fail("addFile must throw ReadOnlyFileSystemException in readOnly mode");
            } catch (ReadOnlyFileSystemException rofse) {
                // success
            }
        } else {
            file = rootDir.addFile(fileName).getFile();
            file.write(0, data);
            file.flush();

            assertSize("bad file.length after write", data.capacity(), file.getLength());
        }

        remountFS(config, config.isReadOnly());

        if (!config.isReadOnly()) {
            FSDirectory rootDir2 = getFs().getRootEntry().getDirectory();
            FSFile file2 = rootDir2.getEntry(fileName).getFile();
            assertNotNull("file not saved", file2);
            assertSize("bad file.length after remount", data.capacity(), file2.getLength());

            ByteBuffer data2 = ByteBuffer.allocate(data.capacity());
            log.debug(
                getFs().getClass().getName() + ": buffer after alloc\n" + FSUtils.toString(data2.array(), 0, 512));
            file2.read(0, data2);
            log.debug(getFs().getClass().getName() + ": buffer after read\n" + FSUtils.toString(data2.array(), 0, 512));
            assertTrue("read and written data are differents", TestUtils.equals(data.array(), data2.array()));
        }
    }
View Full Code Here

Examples of org.jnode.fs.FSFile

            ByteBuffer data = ByteBuffer.wrap(addTestFile(fileName, FILE_SIZE_IN_WORDS));

            // re-get the entry to our test file
            FSDirectory rootDir2 = getFs().getRootEntry().getDirectory();
            FSFile file2 = rootDir2.getEntry(fileName).getFile();

            // In readOnly mode, writing to our file must fail
            try {
                file2.write(0, data);
                fail("write must throw ReadOnlyFileSystemException in readOnly mode");
            } catch (ReadOnlyFileSystemException rofse) {
                // success
            }
        }
View Full Code Here

Examples of org.jnode.fs.FSFile

        final String fileName = "RWTest";

        if (config.isReadOnly()) {
            byte[] data = addTestFile(fileName, FILE_SIZE_IN_WORDS);

            FSFile file = getFs().getRootEntry().getDirectory().getEntry(fileName).getFile();
            try {
                file.setLength(newSize);
                fail("setLength must throw ReadOnlyFileSystemException in readOnly mode");
            } catch (ReadOnlyFileSystemException rofse) {
                // success
            }
            assertEquals("setLength mustn't change size in readOnly mode", String.valueOf(data.length),
                String.valueOf(file.getLength()));
        } else {
            /*byte[] data =*/
            addTestFile(fileName, FILE_SIZE_IN_WORDS);

            FSFile file = getFs().getRootEntry().getDirectory().getEntry(fileName).getFile();
            file.setLength(newSize);
            assertSize("setLength must change size", newSize, file.getLength());
        }
    }
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.