return getLinuxDir(directory, host);
}
@Override
public Boolean isTraversable(final File f) {
final LinuxFile lf = linuxFileCache.get(f.toString());
return lf == null || lf.isDirectory();
}
@Override
public File getParentDirectory(final File dir) {
return getLinuxDir(dir.getParent(), host);
}
@Override
public File[] getFiles(final File dir, final boolean useFileHiding) {
final StringBuilder dirSB = new StringBuilder(dir.toString());
if ("/".equals(dir.toString())) {
dirSB.append('*');
} else {
dirSB.append("/*");
}
final SshOutput out = host.captureCommandProgressIndicator(
"executing...",
new ExecCommandConfig().command("stat -c \"%A %a %Y %s %n\" " + dirSB + " 2>/dev/null")
.silentOutput());
final List<LinuxFile> files = new ArrayList<LinuxFile>();
if (out.getExitCode() == 0) {
for (final String line : out.getOutput().split("\r\n")) {
if (line.trim().isEmpty()) {
continue;
}
final Matcher m = STAT_PATTERN.matcher(line);
if (m.matches()) {
final String type = m.group(1);
final long lastModified = Long.parseLong(m.group(3)) * 1000;
final long size = Long.parseLong(m.group(4));
final String filename = m.group(5);
LinuxFile lf = linuxFileCache.get(filename);
if (lf == null) {
lf = new LinuxFile(thisClass, host, filename, type, lastModified, size);
linuxFileCache.put(filename, lf);
} else {
lf.update(type, lastModified, size);
}
files.add(lf);
} else {
LOG.appWarning("getFileSystemView: could not match: " + line);
}