Search in sources :

Example 11 with FileAttributes

use of com.intellij.openapi.util.io.FileAttributes in project intellij-community by JetBrains.

the class Win32FsCache method getAttributes.

@Nullable
FileAttributes getAttributes(@NotNull VirtualFile file) {
    VirtualFile parent = file.getParent();
    int parentId = parent instanceof VirtualFileWithId ? ((VirtualFileWithId) parent).getId() : -((VirtualFileWithId) file).getId();
    TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap();
    THashMap<String, FileAttributes> nestedMap = map.get(parentId);
    String name = file.getName();
    FileAttributes attributes = nestedMap != null ? nestedMap.get(name) : null;
    if (attributes == null) {
        if (nestedMap != null && !(nestedMap instanceof IncompleteChildrenMap)) {
            // our info from parent doesn't mention the child in this refresh session
            return null;
        }
        FileInfo info = myKernel.getInfo(file.getPath());
        if (info == null) {
            return null;
        }
        attributes = info.toFileAttributes();
        if (nestedMap == null) {
            nestedMap = new IncompleteChildrenMap<>(FileUtil.PATH_HASHING_STRATEGY);
            map.put(parentId, nestedMap);
        }
        nestedMap.put(name, attributes);
    }
    return attributes;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashMap(gnu.trove.THashMap) FileInfo(com.intellij.openapi.util.io.win32.FileInfo) VirtualFileWithId(com.intellij.openapi.vfs.VirtualFileWithId) FileAttributes(com.intellij.openapi.util.io.FileAttributes) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with FileAttributes

use of com.intellij.openapi.util.io.FileAttributes in project intellij-community by JetBrains.

the class Win32FsCache method list.

@NotNull
String[] list(@NotNull VirtualFile file) {
    String path = file.getPath();
    FileInfo[] fileInfo = myKernel.listChildren(path);
    if (fileInfo == null || fileInfo.length == 0) {
        return ArrayUtil.EMPTY_STRING_ARRAY;
    }
    String[] names = new String[fileInfo.length];
    TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap();
    int parentId = ((VirtualFileWithId) file).getId();
    THashMap<String, FileAttributes> nestedMap = map.get(parentId);
    if (nestedMap == null) {
        nestedMap = new THashMap<>(fileInfo.length, FileUtil.PATH_HASHING_STRATEGY);
        map.put(parentId, nestedMap);
    }
    for (int i = 0, length = fileInfo.length; i < length; i++) {
        FileInfo info = fileInfo[i];
        String name = info.getName();
        nestedMap.put(name, info.toFileAttributes());
        names[i] = name;
    }
    return names;
}
Also used : FileInfo(com.intellij.openapi.util.io.win32.FileInfo) THashMap(gnu.trove.THashMap) VirtualFileWithId(com.intellij.openapi.vfs.VirtualFileWithId) FileAttributes(com.intellij.openapi.util.io.FileAttributes) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with FileAttributes

use of com.intellij.openapi.util.io.FileAttributes in project intellij-plugins by JetBrains.

the class BndLaunchState method bundlesChanged.

private boolean bundlesChanged() {
    boolean changed = false;
    for (String bundle : myLauncher.getRunBundles()) {
        FileAttributes attributes = FileSystemUtil.getAttributes(bundle);
        Pair<Long, Long> current = attributes != null ? pair(attributes.lastModified, attributes.length) : MISSING_BUNDLE;
        if (!current.equals(myBundleStamps.get(bundle))) {
            myBundleStamps.put(bundle, current);
            changed = true;
        }
    }
    return changed;
}
Also used : FileAttributes(com.intellij.openapi.util.io.FileAttributes)

Aggregations

FileAttributes (com.intellij.openapi.util.io.FileAttributes)13 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)4 AccessToken (com.intellij.openapi.application.AccessToken)2 Pair (com.intellij.openapi.util.Pair)2 FileInfo (com.intellij.openapi.util.io.win32.FileInfo)2 VirtualFileWithId (com.intellij.openapi.vfs.VirtualFileWithId)2 FakeVirtualFile (com.intellij.openapi.vfs.newvfs.impl.FakeVirtualFile)2 THashMap (gnu.trove.THashMap)2 ZipFile (java.util.zip.ZipFile)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)1 JarFileSystemImpl (com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl)1 JarHandler (com.intellij.openapi.vfs.impl.jar.JarHandler)1 VFileCreateEvent (com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent)1 VirtualDirectoryImpl (com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 Field (java.lang.reflect.Field)1