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!");
}