*** empty log message ***
[cyberduck.git] / source / ch / cyberduck / Attic / connection / sftp / SFTPParser.java
blob391f39252b68b9373926fe9fb598d6882a6c9c13
1 package ch.cyberduck.connection.sftp;
3 /*
4 * ch.cyberduck.connection.ftp.Parser.java
5 * Cyberduck
7 * $Header$
8 * $Revision$
9 * $Date$
11 * Copyright (c) 2003 David Kocher. All rights reserved.
12 * http://icu.unizh.ch/~dkocher/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * Bug fixes, suggestions and comments should be sent to:
25 * dkocher@cyberduck.ch
28 import java.util.*;
29 import java.io.IOException;
31 import com.sshtools.j2ssh.sftp.SftpFile;
32 import com.sshtools.j2ssh.sftp.FileAttributes;
34 import ch.cyberduck.Cyberduck;
35 import ch.cyberduck.Preferences;
36 import ch.cyberduck.connection.Path;
37 import ch.cyberduck.connection.Permission;
39 public class SFTPParser {
41 private SFTPParser() {
42 super();
45 public static List parseList(String parent, List children) throws IOException {
46 // Cyberduck.DEBUG("[FTPParser] parseList(" + parent + "," + list + ")");
47 List parsedList = new ArrayList();
48 SftpFile file;
49 Iterator i = children.iterator();
50 boolean showHidden = Preferences.instance().getProperty("ftp.showHidden").equals("true");
51 while(i.hasNext()) {
52 file = (SftpFile)i.next();
53 FileAttributes attributes = file.getAttributes();
54 Cyberduck.DEBUG("***"+file.getAbsolutePath());
55 // Cyberduck.DEBUG(file.isFile() ? "File" : "Directory");
56 // Cyberduck.DEBUG(" Size:"+attributes.getSize().toString());
57 Cyberduck.DEBUG(" Permissions:"+attributes.getPermissions().toString());
58 Path p = new Path(file.getAbsolutePath());
59 if(file.isDirectory())
60 p.setMode("d---------");
61 //p = new Path(file.getAbsolutePath()+"/");
62 else
63 p.setMode("----------");
64 // p = new Path(file.getAbsolutePath());
65 p.setSize(attributes.getSize().intValue());
66 // p.setOwner();
67 // p.setPermission(attributes.getPermissions().intValue());
68 p.setModified(attributes.getModifiedTime().intValue());
69 String filename = p.getName();
70 if(!(filename.equals(".") || filename.equals(".."))) {
71 if(!showHidden) {
72 if(filename.charAt(0) == '.') {
73 p.setVisible(false);
76 parsedList.add(p);
79 return parsedList;