VirtualFileSystemEntry (int id, int nameId, @PersistentFS.Attributes int attributes, boolean isEmptyDirectory) { FileLoadingTracker.fileLoaded(this, nameId); VfsData vfsData = getVfsData(); VfsData.Segment segment = vfsData.getSegment(id, true); boolean isDirectory = PersistentFS.isDirectory(attributes); VfsData.initFile(id, segment, nameId, isDirectory ? new VfsData.DirectoryData() : KeyFMap.EMPTY_MAP); VirtualFileSystemEntry child = vfsData.getFileById(id, this, true); assert child != null; FileAttributes.CaseSensitivity sensitivity = isDirectory ? PersistentFS.areChildrenCaseSensitive(attributes) : FileAttributes.CaseSensitivity.UNKNOWN; int newFlags = (PersistentFS.isSymLink(attributes) ? VfsDataFlags.IS_SYMLINK_FLAG : 0) | (PersistentFS.isSpecialFile(attributes) ? VfsDataFlags.IS_SPECIAL_FLAG : 0) | (PersistentFS.isWritable(attributes) ? VfsDataFlags.IS_WRITABLE_FLAG : 0) | (PersistentFS.isHidden(attributes) ? VfsDataFlags.IS_HIDDEN_FLAG : 0) | (sensitivity != FileAttributes.CaseSensitivity.UNKNOWN ? VfsDataFlags.CHILDREN_CASE_SENSITIVITY_CACHED : 0) | (sensitivity == FileAttributes.CaseSensitivity.SENSITIVE ? VfsDataFlags.CHILDREN_CASE_SENSITIVE : 0) | (PersistentFS.isOfflineByDefault(attributes) ? VfsDataFlags.IS_OFFLINE : 0); int relevantFlagsMask = VfsDataFlags.IS_SYMLINK_FLAG | VfsDataFlags.IS_SPECIAL_FLAG | VfsDataFlags.STRICT_PARENT_HAS_SYMLINK_FLAG | VfsDataFlags.IS_WRITABLE_FLAG | VfsDataFlags.IS_HIDDEN_FLAG | VfsDataFlags.CHILDREN_CASE_SENSITIVE | VfsDataFlags.CHILDREN_CASE_SENSITIVITY_CACHED | VfsDataFlags.IS_OFFLINE; segment.setFlags(id, relevantFlagsMask, newFlags); child.updateLinkStatus(this); if (getFileSystem().markNewFilesAsDirty()) { child.markDirty(); } if (isDirectory && child instanceof VirtualDirectoryImpl && isEmptyDirectory) { // When creating an empty directory, we need to make sure that every file created inside it will fire a "file created" event // for virtual file pointer manager to update its pointers properly // (because currently VirtualFilePointerManager ignores empty directory creation events for performance reasons). ((VirtualDirectoryImpl)child).setAllChildrenLoaded(); } return child; }