Examples of SmbFile


Examples of jcifs.smb.SmbFile

    }

    @Override
    public OverthereFile getParentFile() {
        try {
            return new CifsFile(getConnection(), new SmbFile(smbFile.getParent(), connection.authentication));
        } catch (MalformedURLException exc) {
            return null;
        }
    }
View Full Code Here

Examples of jcifs.smb.SmbFile

    @Override
    public void renameTo(OverthereFile dest) throws RuntimeIOException {
        logger.debug("Renaming {} to {}", smbFile.getUncPath(), dest);

        if (dest instanceof CifsFile) {
            SmbFile targetSmbFile = ((CifsFile) dest).getSmbFile();
            try {
                smbFile.renameTo(targetSmbFile);
            } catch (SmbException exc) {
                throw new RuntimeIOException(format("Cannot move/rename %s to %s: %s", smbFile.getUncPath(), dest, exc.toString()), exc);
            }
View Full Code Here

Examples of jcifs.smb.SmbFile

        }
    }

    private void upgradeToDirectorySmbFile() throws MalformedURLException {
        if (!smbFile.getPath().endsWith("/")) {
            smbFile = new SmbFile(smbFile.getURL() + "/", connection.authentication);
        }
    }
View Full Code Here

Examples of jcifs.smb.SmbFile

            smbFile = new SmbFile(smbFile.getURL() + "/", connection.authentication);
        }
    }

    private void refreshSmbFile() throws MalformedURLException {
        smbFile = new SmbFile(smbFile.getPath(), connection.authentication);
    }
View Full Code Here

Examples of jcifs.smb.SmbFile

    }

    @Override
    public OverthereFile getFile(String hostPath) throws RuntimeIOException {
        try {
            SmbFile smbFile = new SmbFile(encodeAsSmbUrl(hostPath), authentication);
            return new CifsFile(this, smbFile);
        } catch (IOException exc) {
            throw new RuntimeIOException(exc);
        }
    }
View Full Code Here

Examples of jcifs.smb.SmbFile

        NtlmAuthenticator.setDefault(this);
    }

    void run() throws Exception {
        String cmd, prompt;
        SmbFile conn, tmp;
        SimpleDateFormat sdf1 = new SimpleDateFormat("EEE MMM");
        SimpleDateFormat sdf2 = new SimpleDateFormat("d");
        SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy h:mm a");
        sdf1.setCalendar(new GregorianCalendar());
        sdf2.setCalendar(new GregorianCalendar());
        sdf3.setCalendar(new GregorianCalendar());

        conn = new SmbFile(start);
        while (true) {
            try {
                if (conn.exists()) {
                    prompt = conn.getName() + "> ";
                } else {
                    System.out.println("error reading " + conn);
                    conn = new SmbFile("smb://");
                    continue;
                }
                System.out.print(prompt);

                cmd = readLine();
                if (cmd.equals("")) {
                    //empty
                } else if (cmd.startsWith("cd")) {
                    int i = cmd.indexOf(' ');
                    String dir;
                    if (i == -1 || (dir = cmd.substring(i).trim()).length() == 0) {
                        conn = new SmbFile("smb://");
                        continue;
                    }
                    tmp = new SmbFile(conn, dir);
                    if (tmp.exists()) {
                        if (tmp.isDirectory()) {
                            conn = tmp;
                        } else {
                            System.out.println(dir + " is not a directory");
                        }
                    } else {
                        System.out.println("no such directory");
                    }
                } else if (cmd.startsWith("ls")) {
                    int i = cmd.indexOf(' ');
                    SmbFile d = conn;
                    String dir, wildcard = "*";
                    if (i != -1 && (dir = cmd.substring(i).trim()).length() != 0) {
                        // there's an argument which could be a directory,
                        // a wildcard, or a directory with a wildcard appended
                        int s = dir.lastIndexOf('/');
                        int a = dir.lastIndexOf('*');
                        int q = dir.lastIndexOf('?');

                        if ((a != -1 && a > s) || (q != -1 && q > s)) {
                            // it's a wildcard
                            if (s == -1) {
                                wildcard = dir;
                                d = conn;
                            } else {
                                wildcard = dir.substring(s + 1);
                                d = new SmbFile(conn, dir.substring(0, s));
                            }
                        } else {
                            d = new SmbFile(conn, dir);
                        }
                    }
                    long t0 = System.currentTimeMillis();
                    SmbFile[] list = d.listFiles(wildcard);
                    t0 = System.currentTimeMillis() - t0;
                    if (list != null) {
                        for (int j = 0; j < list.length; j++) {
                            StringBuffer sb = new StringBuffer();
                            Date date = new Date(list[j].lastModified());
View Full Code Here

Examples of jcifs.smb.SmbFile

    /**
     * @see org.jnode.fs.FSEntry#setName(String)
     */
    public void setName(String newName) throws IOException {
        SmbFile f = new SmbFile(smbFile.getParent(), newName);
        smbFile.renameTo(f);
    }
View Full Code Here

Examples of jcifs.smb.SmbFile

    public SMBFileSystem(SMBFSDevice device, SMBFileSystemType type) {
        this.type = type;
        this.device = device;
        try {
            root = new SMBFSDirectory(null, new SmbFile("smb://" + device.getUser() + ":" + device.getPassword() + "@"
                + device.getHost() + "/" + device.getPath() + "/"));
            root.smbFile.setDefaultUseCaches(false);
            root.smbFile.connect();
        } catch (IOException e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of jcifs.smb.SmbFile

     */
    public SMBFSEntry addDirectory(final String name) throws IOException {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<SMBFSEntry>() {
                public SMBFSEntry run() throws Exception {
                    SmbFile dir = new SmbFile(smbFile, dirName(name));
                    dir.mkdir();
                    SMBFSDirectory sdir = new SMBFSDirectory(SMBFSDirectory.this, dir);
                    entries.put(name, sdir);
                    return sdir;
                }
            });
View Full Code Here

Examples of jcifs.smb.SmbFile

     */
    public SMBFSEntry addFile(final String name) throws IOException {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<SMBFSEntry>() {
                public SMBFSEntry run() throws Exception {
                    SmbFile file = new SmbFile(smbFile, name);
                    file.createNewFile();
                    SMBFSFile sfile = new SMBFSFile(SMBFSDirectory.this, file);
                    entries.put(name, sfile);
                    return sfile;
                }
            });
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.