Package org.tc65sh.device

Examples of org.tc65sh.device.FileHolder


                    ui.println("Error: no deviceFilename");
                }
            } else if (tok[0].equals("put")) {
                // put <localFilePath> <optional: deviceFilename>
                if (tok.length > 1) {
                    FileHolder fileHolder = loadLocalFile(tok[1]);
                    if (tok.length > 2) {
                        fileHolder.fileInfo.name = tok[2];
                    } else {
                        fileHolder.fileInfo.name = FileUtils.extractFilename(tok[1]);
                    }
                    if (FileUtils.isFileName(fileHolder.fileInfo.name)) {
                        device.obexDeleteFile(fileHolder.fileInfo.name);
                        device.obexPutFile(fileHolder);
                    } else {
                        ui.println("Error: deviceFilename must not be a path!");
                    }
                } else {
                    ui.println("Error: no localFilePath");
                }
            } else if (tok[0].equals("get")) {
                // get <deviceFilename> <optional: localFilePath>
                if (tok.length > 1) {
                    if (FileUtils.isFileName(tok[1])) {
                        FileHolder fh = device.obexGetFile(tok[1]);
                        if (tok.length > 2) {
                            fh.fileInfo.name = tok[2];
                        } else {
                            fh.fileInfo.name = tok[1];
                        }
                        saveLocalFile(fh);
                    } else {
                        ui.println("Error: deviceFilename must not be a path!");
                    }
                } else {
                    ui.println("Error: no deviceFilename");
                }
            } else if (tok[0].equals("getd")) {
                // getd <deviceFilename> <optional: localFilePath>
                if (tok.length > 1) {
                    if (FileUtils.isFileName(tok[1])) {
                        if (tok.length > 2) {
                            getDirectory(device, tok[1], tok[2]);
                        } else {
                            getDirectory(device, tok[1], tok[1]);
                        }
                    } else {
                        ui.println("Error: deviceFilename must not be a path!");
                    }
                } else {
                    ui.println("Error: no deviceFilename");
                }
            } else if (tok[0].equals("cat")) {
                // cat <deviceFilename>
                if (tok.length > 1) {
                    if (FileUtils.isFileName(tok[1])) {
                        FileHolder fh = device.obexGetFile(tok[1]);
                        String catString = new String(fh.content.getBuffer());
                        ui.println(catString);
                    } else {
                        ui.println("Error: deviceFilename must not be a path!");
                    }
View Full Code Here


    private void getFilename(Device device, String deviceFilename, String localFilename) throws IOException {
        if (localFilename == null) {
            localFilename = deviceFilename;
        }

        FileHolder fh = device.obexGetFile(deviceFilename);
        fh.fileInfo.name = localFilename;

        saveLocalFile(fh);
    }
View Full Code Here

        byte[] buf = new byte[(int) f.length()];
        in.read(buf);
        in.close();
        ByteArray content = new ByteArray(buf);
        FileInfo fi = new FileInfo(false, f.getName(), (int) f.length(), new Date(f.lastModified()));
        FileHolder fh = new FileHolder(fi, content);
        return fh;
    }
View Full Code Here

TOP

Related Classes of org.tc65sh.device.FileHolder

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.