Exemplo n.º 1
0
  private void executeDelete(@NotNull VirtualFile file) {
    if (!file.exists()) {
      LOG.error("Deleting a file, which does not exist: " + file.getPath());
      return;
    }
    clearIdCache();

    int id = getFileId(file);

    final VirtualFile parent = file.getParent();
    final int parentId = parent == null ? 0 : getFileId(parent);

    if (parentId == 0) {
      String rootUrl =
          normalizeRootUrl(file.getPath(), (NewVirtualFileSystem) file.getFileSystem());
      myRootsLock.writeLock().lock();
      try {
        myRoots.remove(rootUrl);
        myRootsById.remove(id);
        FSRecords.deleteRootRecord(id);
      } finally {
        myRootsLock.writeLock().unlock();
      }
    } else {
      removeIdFromParentList(parentId, id, parent, file);
      VirtualDirectoryImpl directory = (VirtualDirectoryImpl) file.getParent();
      assert directory != null : file;
      directory.removeChild(file);
    }

    FSRecords.deleteRecordRecursively(id);

    invalidateSubtree(file);
  }
  public void testWindowsHiddenDirectory() throws Exception {
    if (!SystemInfo.isWindows) {
      System.err.println(getName() + " skipped: " + SystemInfo.OS_NAME);
      return;
    }

    File file = new File("C:\\Documents and Settings\\desktop.ini");
    if (!file.exists()) {
      System.err.println(getName() + " skipped: missing " + file);
      return;
    }

    String parent = FileUtil.toSystemIndependentName(file.getParent());
    VirtualDirectoryImpl.allowRootAccess(parent);
    try {
      VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
      assertNotNull(virtualFile);

      NewVirtualFileSystem fs = (NewVirtualFileSystem) virtualFile.getFileSystem();
      FileAttributes attributes = fs.getAttributes(virtualFile);
      assertNotNull(attributes);
      assertEquals(FileAttributes.Type.FILE, attributes.type);
      assertEquals(FileAttributes.HIDDEN, attributes.flags);
    } finally {
      VirtualDirectoryImpl.disallowRootAccess(parent);
    }
  }
Exemplo n.º 3
0
 @NotNull
 private static NewVirtualFileSystem getDelegate(@NotNull VirtualFile file) {
   return (NewVirtualFileSystem) file.getFileSystem();
 }