Package org.jnode.net.nfs.nfs2

Examples of org.jnode.net.nfs.nfs2.ReadFileResult


                        Set<NFS2Entry> nfsEntrySet =
                            new LinkedHashSet<NFS2Entry>(entrySet.size());

                        for (Entry entry : entrySet) {
                            LookupResult lookupResult = nfsClient.lookup(
                                directoryEntry.getFileHandle(), entry.getName());

                            NFS2Entry nfsEntry = new NFS2Entry(
                                (NFS2FileSystem) getFileSystem(),
                                NFS2Directory.this, entry.getName(), lookupResult.getFileHandle(),
                                lookupResult.getFileAttribute());

                            if (!(nfsEntry.isDirectory() || nfsEntry.isFile())) {
                                continue;
                            }
                            nfsEntrySet.add(nfsEntry);
View Full Code Here


                String t = tokenizer.nextToken();
                tokenList.add(t);
            }
            for (int i = 0; i < tokenList.size() - 1; i++) {
                String t = tokenList.get(i);
                LookupResult lookup = nfsClient.lookup(tempFileHandle, t);
                if (lookup.getFileAttribute().getType() == FileAttribute.FILE) {
                    throw new IOException("The path contains a file : " + t + '.');
                } else if (lookup.getFileAttribute().getType() == FileAttribute.DIRECTORY) {
                    tempFileHandle = lookup.getFileHandle();
                } else {
                    throw new IOException("The path contains an unknow resource: " + t +
                            ". It is not directory or file");
                }
            }
View Full Code Here

        try {
            String filePath = path.substring(exportEntry.getDirectory().length());
            StringTokenizer tokenizer = new StringTokenizer(filePath, "/");
            while (tokenizer.hasMoreElements()) {
                String t = tokenizer.nextToken();
                LookupResult lookup = nfsClient.lookup(tempFileHandle, t);
                if (lookup.getFileAttribute().getType() == FileAttribute.FILE) {
                    fileHandle = lookup.getFileHandle();
                    fileAttribute = lookup.getFileAttribute();
                    break;
                } else if (lookup.getFileAttribute().getType() == FileAttribute.DIRECTORY) {
                    tempFileHandle = lookup.getFileHandle();
                } else {
                    throw new IOException("The path contains an unknow resource: " + t +
                            ". It is not directory or file");
                }
            }
View Full Code Here

    public void setLastChanged(long lastChanged) throws IOException {
        // TODO: The setAttribute API appears to have no way to do this.
    }

    public void setLastModified(long lastModified) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            client.setAttribute(getFileHandle(), -1, -1, -1, -1,
                new Time(-1, -1), new Time(lastModified));
        } catch (NFS2Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
View Full Code Here

            throw new IOException(e.getMessage(), e);
        }
    }

    public void setLastAccessed(long lastAccessed) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            client.setAttribute(getFileHandle(), -1, -1, -1, -1,
                new Time(lastAccessed), new Time(-1, -1));
        } catch (NFS2Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
View Full Code Here

            throw new IOException(e.getMessage(), e);
        }
    }

    public void setName(String newName) throws IOException {
        NFS2Client client = getNFS2Client();
        NFS2Directory parentDirectory = (NFS2Directory) getParent();
        try {
            client.renameFile(
                parentDirectory.getNFS2Entry().getFileHandle(), name,
                parentDirectory.getNFS2Entry().getFileHandle(), newName);
        } catch (NFS2Exception e) {
            throw new IOException("Can not rename ." + e.getMessage(), e);
        }
View Full Code Here

     * @param fileOffset
     * @param dest
     * @throws java.io.IOException
     */
    public void read(long fileOffset, ByteBuffer dest) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            int length;
            while (true) {
                length = Math.min(NFS2Client.MAX_DATA, dest.remaining());
                if (length == 0) {
                    return;
                }
                ReadFileResult result =
                        client.readFile(entry.getFileHandle(), (int) fileOffset, length);
                byte[] data = result.getData();
                length = data.length;
                fileOffset += length;
                dest.put(data);
            }
View Full Code Here

     *
     * @param length
     * @throws java.io.IOException
     */
    public void setLength(long length) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            client.setAttribute(entry.getFileHandle(), -1, -1, -1, (int) length, new Time(-1, -1),
                    new Time(-1, -1));
        } catch (NFS2Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
View Full Code Here

     * @param fileOffset
     * @param src
     * @throws java.io.IOException
     */
    public void write(long fileOffset, ByteBuffer src) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            byte[] data = new byte[NFS2Client.MAX_DATA];
            int count;
            while (src.remaining() > 0) {
                count = Math.min(NFS2Client.MAX_DATA, src.remaining());
                src.get(data, 0, count);
                client.writeFile(entry.getFileHandle(), (int) fileOffset, data, 0, count);
                fileOffset += count;
            }
        } catch (NFS2Exception e) {
            throw new IOException("Error writing file . Reason: " + e.getMessage(), e);
        }
View Full Code Here

        NFS2Entry entry = tableEntry.getEntry(name);
        if (entry != null) {
            return entry;
        }

        NFS2Client nfsClient = getNFS2Client();
        LookupResult lookupResult;
        try {
            lookupResult = nfsClient.lookup(directoryEntry.getFileHandle(), name);
        } catch (NFS2Exception e) {
            throw new IOException("Can not call the rpc method." + e.getMessage(), e);
        }
        entry = new NFS2Entry(
            (NFS2FileSystem) getFileSystem(), this, name,
View Full Code Here

TOP

Related Classes of org.jnode.net.nfs.nfs2.ReadFileResult

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.