use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class RefreshWorker method processQueue.
private void processQueue(NewVirtualFileSystem fs, PersistentFS persistence) throws RefreshCancelledException {
TObjectHashingStrategy<String> strategy = FilePathHashingStrategy.create(fs.isCaseSensitive());
while (!myRefreshQueue.isEmpty()) {
Pair<NewVirtualFile, FileAttributes> pair = myRefreshQueue.pullFirst();
NewVirtualFile file = pair.first;
boolean fileDirty = file.isDirty();
if (LOG.isTraceEnabled())
LOG.trace("file=" + file + " dirty=" + fileDirty);
if (!fileDirty)
continue;
checkCancelled(file);
FileAttributes attributes = pair.second != null ? pair.second : fs.getAttributes(file);
if (attributes == null) {
scheduleDeletion(file);
file.markClean();
continue;
}
NewVirtualFile parent = file.getParent();
if (parent != null && checkAndScheduleFileTypeChange(parent, file, attributes)) {
// ignore everything else
file.markClean();
continue;
}
if (file.isDirectory()) {
boolean fullSync = ((VirtualDirectoryImpl) file).allChildrenLoaded();
if (fullSync) {
fullDirRefresh(fs, persistence, strategy, (VirtualDirectoryImpl) file);
} else {
partialDirRefresh(fs, strategy, (VirtualDirectoryImpl) file);
}
} else {
long currentTimestamp = persistence.getTimeStamp(file);
long upToDateTimestamp = attributes.lastModified;
long currentLength = persistence.getLastRecordedLength(file);
long upToDateLength = attributes.length;
if (currentTimestamp != upToDateTimestamp || currentLength != upToDateLength) {
scheduleUpdateContent(file);
}
}
boolean currentWritable = persistence.isWritable(file);
boolean upToDateWritable = attributes.isWritable();
if (LOG_ATTRIBUTES.isDebugEnabled()) {
LOG_ATTRIBUTES.debug("file=" + file + " writable vfs=" + file.isWritable() + " persistence=" + currentWritable + " real=" + upToDateWritable);
}
if (currentWritable != upToDateWritable) {
scheduleAttributeChange(file, VirtualFile.PROP_WRITABLE, currentWritable, upToDateWritable);
}
if (SystemInfo.isWindows) {
boolean currentHidden = file.is(VFileProperty.HIDDEN);
boolean upToDateHidden = attributes.isHidden();
if (currentHidden != upToDateHidden) {
scheduleAttributeChange(file, VirtualFile.PROP_HIDDEN, currentHidden, upToDateHidden);
}
}
if (attributes.isSymLink()) {
String currentTarget = file.getCanonicalPath();
String upToDateTarget = fs.resolveSymLink(file);
String upToDateVfsTarget = upToDateTarget != null ? FileUtil.toSystemIndependentName(upToDateTarget) : null;
if (!Comparing.equal(currentTarget, upToDateVfsTarget)) {
scheduleAttributeChange(file, VirtualFile.PROP_SYMLINK_TARGET, currentTarget, upToDateVfsTarget);
}
}
if (myIsRecursive || !file.isDirectory()) {
file.markClean();
}
}
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class RefreshWorker method scan.
public void scan() {
NewVirtualFile root = myRefreshQueue.peekFirst().first;
NewVirtualFileSystem fs = root.getFileSystem();
if (root.isDirectory()) {
fs = PersistentFS.replaceWithNativeFS(fs);
}
try {
processQueue(fs, PersistentFS.getInstance());
} catch (RefreshCancelledException e) {
LOG.debug("refresh cancelled");
}
}
use of com.intellij.openapi.vfs.newvfs.NewVirtualFile in project intellij-community by JetBrains.
the class MacPythonSdkFlavor method collectPythonInstallations.
private static void collectPythonInstallations(String pythonPath, Set<String> candidates) {
VirtualFile rootVDir = LocalFileSystem.getInstance().findFileByPath(pythonPath);
if (rootVDir != null) {
if (rootVDir instanceof NewVirtualFile) {
((NewVirtualFile) rootVDir).markDirty();
}
rootVDir.refresh(true, false);
for (VirtualFile dir : rootVDir.getChildren()) {
final String dirName = dir.getName().toLowerCase();
if (dir.isDirectory()) {
if ("Current".equals(dirName) || dirName.startsWith("2") || dirName.startsWith("3")) {
final VirtualFile binDir = dir.findChild("bin");
if (binDir != null && binDir.isDirectory()) {
for (String name : POSSIBLE_BINARY_NAMES) {
final VirtualFile child = binDir.findChild(name);
if (child == null)
continue;
String path = child.getPath();
if (FileSystemUtil.isSymLink(path)) {
path = FileSystemUtil.resolveSymLink(path);
}
if (path != null && !candidates.contains(path)) {
candidates.add(path);
break;
}
}
}
}
}
}
}
}
Aggregations