From 9285a0e508a686ad88a5f16e6cf86324fa52ae25 Mon Sep 17 00:00:00 2001 From: Dave McKnight Date: Fri, 19 Sep 2014 14:09:11 -0400 Subject: [PATCH] [444621][local]need ability to disable local natives --- .../local/files/LocalFileService.java | 66 ++++++++++++++++--- .../services/local/files/LocalHostFile.java | 5 +- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java index c1a87e0923f..b028263f693 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java @@ -56,6 +56,7 @@ * David McKnight (IBM) - [422508] Unable to map A:\ and B:\ as selectable drives in RSE View * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. * David McKnight (IBM) - [431060][local] RSE performance over local network drives are suboptimal + * David McKnight (IBM) - [444621][local]need ability to disable local natives *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -163,6 +164,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi private boolean _isWin95 = false; private boolean _isWinNT = false; private String _osCmdShell = null; + private static boolean _disableLocalNatives = false; private boolean _getParentCanonicalPath = false; @@ -179,6 +181,15 @@ public class LocalFileService extends AbstractFileService implements ILocalServi catch (Exception e){ } } + + String disableLocalNatives = System.getProperty("disable.local.natives"); //$NON-NLS-1$ + if (disableLocalNatives != null){ + try { + _disableLocalNatives = Boolean.parseBoolean(disableLocalNatives); + } + catch (Exception e){ + } + } } @@ -240,9 +251,20 @@ public class LocalFileService extends AbstractFileService implements ILocalServi File entry = new File(dir, name); FileInfo info = fetchInfo(entry); - if (info.exists()) { - boolean isDirectory = info.isDirectory(); - boolean isFile = !isDirectory; + boolean isDirectory = false; + boolean isFile = true; + boolean exists = false; + if (info != null && info.exists()) { + exists = true; + isDirectory = info.isDirectory(); + isFile = !isDirectory; + } + else if (entry.exists()){ + exists = true; + isDirectory = entry.isDirectory(); + isFile = !isDirectory; + } + if (exists){ if (isFile) { result = _matcher.matches(name); } else if (isDirectory) { @@ -251,6 +273,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } } } + return result; } @@ -742,12 +765,21 @@ public class LocalFileService extends AbstractFileService implements ILocalServi LocalFileNameFilter fFilter = new LocalFileNameFilter(fileFilter, type); File localParent = new File(remoteParent); FileInfo parentInfo = fetchInfo(localParent); - + boolean isArchive = false; boolean isVirtual = false; - boolean parentExists = parentInfo.exists(); + boolean parentExists = true; + boolean parentIsDirectory = true; + if (parentInfo != null){ + parentExists = parentInfo.exists(); + parentIsDirectory = parentInfo.isDirectory(); + } + else { + parentExists = localParent.exists(); + parentIsDirectory = localParent.isDirectory(); + } if (parentExists) { - if (!parentInfo.isDirectory()) { + if (!parentIsDirectory) { isArchive = ArchiveHandlerManager.getInstance().isArchive(localParent); } // if the system type is Windows, we get the canonical path so that we have the correct case in the path @@ -819,7 +851,14 @@ public class LocalFileService extends AbstractFileService implements ILocalServi File file = files[i]; FileInfo info = fetchInfo(file); - boolean isDirectory = info.isDirectory(); + boolean isDirectory = false; + + if (info != null){ + isDirectory = info.isDirectory(); + } + else { + isDirectory = file.isDirectory(); + } boolean isFile = !isDirectory; if (isDirectory) { @@ -842,7 +881,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi results.add(new LocalHostFile(file, false, info)); } } - else if (info.exists()) + else if (info != null && info.exists()) { results.add(new LocalHostFile(file, false, info)); } @@ -852,7 +891,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } private FileInfo fetchInfo(File file) { - if (LocalFileNativesManager.isUsingNatives()) { + if (isUsingNatives()) { FileInfo info = LocalFileNativesManager.fetchFileInfo(file.getAbsolutePath()); //natives don't set the file name on all platforms if (info.getName().length() == 0) { @@ -864,6 +903,15 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } return null; } + + public static boolean isUsingNatives(){ + if (_disableLocalNatives){ + return false; + } + else { + return LocalFileNativesManager.isUsingNatives(); + } + } public IHostFile getUserHome() { diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java index c7b9894e641..2e127d96a2d 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalHostFile.java @@ -17,6 +17,7 @@ * David McKnight (IBM) - [294521] Local "hidden" files and folders are always shown * David McKnight (IBM) - [420798] Slow performances in RDz 9.0 with opening 7000 files located on a network driver. * David McKnight (IBM) - [431060][local] RSE performance over local network drives are suboptimal + * David McKnight (IBM) - [444621][local]need ability to disable local natives *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -67,7 +68,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer } private void fetchInfo() { - if (LocalFileNativesManager.isUsingNatives()) { + if (LocalFileService.isUsingNatives()) { _info = LocalFileNativesManager.fetchFileInfo(_file.getAbsolutePath()); //natives don't set the file name on all platforms if (_info.getName().length() == 0) { @@ -241,7 +242,7 @@ public class LocalHostFile implements IHostFile, IHostFilePermissionsContainer } private boolean needsQuery(){ - if (LocalFileNativesManager.isUsingNatives() && _needsQuery){ + if (LocalFileService.isUsingNatives() && _needsQuery){ return true; } long t = System.currentTimeMillis();