当前位置: 首页>>代码示例>>Java>>正文


Java FileSystemUtil.getAttributes方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.io.FileSystemUtil.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemUtil.getAttributes方法的具体用法?Java FileSystemUtil.getAttributes怎么用?Java FileSystemUtil.getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.io.FileSystemUtil的用法示例。


在下文中一共展示了FileSystemUtil.getAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanupDeleteOnExitHookList

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
public static void cleanupDeleteOnExitHookList() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
  // try to reduce file set retained by java.io.DeleteOnExitHook
  List<String> list;
  synchronized (DELETE_ON_EXIT_HOOK_CLASS) {
    if (DELETE_ON_EXIT_HOOK_DOT_FILES.isEmpty()) return;
    list = new ArrayList<String>(DELETE_ON_EXIT_HOOK_DOT_FILES);
  }
  for (int i = list.size() - 1; i >= 0; i--) {
    String path = list.get(i);
    if (FileSystemUtil.getAttributes(path) == null || new File(path).delete()) {
      synchronized (DELETE_ON_EXIT_HOOK_CLASS) {
        DELETE_ON_EXIT_HOOK_DOT_FILES.remove(path);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:UsefulTestCase.java

示例2: getMirrorFile

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
private File getMirrorFile(@NotNull File originalFile) {
  if (!myFileSystem.isMakeCopyOfJar(originalFile)) return originalFile;

  final FileAttributes originalAttributes = FileSystemUtil.getAttributes(originalFile);
  if (originalAttributes == null) return originalFile;

  final String folderPath = getJarsDir();
  if (!new File(folderPath).exists() && !new File(folderPath).mkdirs()) {
    return originalFile;
  }

  if (FSRecords.weHaveContentHashes) {
    return getMirrorWithContentHash(originalFile, originalAttributes);
  }

  final String mirrorName = originalFile.getName() + "." + Integer.toHexString(originalFile.getPath().hashCode());
  final File mirrorFile = new File(folderPath, mirrorName);
  final FileAttributes mirrorAttributes = FileSystemUtil.getAttributes(mirrorFile);
  return mirrorDiffers(originalAttributes, mirrorAttributes, false) ? copyToMirror(originalFile, mirrorFile) : mirrorFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JarHandler.java

示例3: cleanupDeleteOnExitHookList

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
private static void cleanupDeleteOnExitHookList() throws Exception {
  // try to reduce file set retained by java.io.DeleteOnExitHook
  List<String> list;
  synchronized (DELETE_ON_EXIT_HOOK_CLASS) {
    if (DELETE_ON_EXIT_HOOK_DOT_FILES.isEmpty()) {
      return;
    }
    list =
        DELETE_ON_EXIT_HOOK_DOT_FILES
            .stream()
            .filter(p -> p instanceof String)
            .map(p -> (String) p)
            .collect(Collectors.toList());
  }
  for (int i = list.size() - 1; i >= 0; i--) {
    String path = list.get(i);
    if (FileSystemUtil.getAttributes(path) == null || new File(path).delete()) {
      synchronized (DELETE_ON_EXIT_HOOK_CLASS) {
        DELETE_ON_EXIT_HOOK_DOT_FILES.remove(path);
      }
    }
  }
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:24,代码来源:IntellijTestSetupRule.java

示例4: getMirrorFile

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
private File getMirrorFile(@Nonnull File originalFile) {
  if (!myFileSystem.isMakeCopyOfJar(originalFile)) return originalFile;

  final FileAttributes originalAttributes = FileSystemUtil.getAttributes(originalFile);
  if (originalAttributes == null) return originalFile;

  final String folderPath = getJarsDir();
  if (!new File(folderPath).exists() && !new File(folderPath).mkdirs()) {
    return originalFile;
  }

  if (FSRecords.weHaveContentHashes) {
    return getMirrorWithContentHash(originalFile, originalAttributes);
  }

  final String mirrorName = originalFile.getName() + "." + Integer.toHexString(originalFile.getPath().hashCode());
  final File mirrorFile = new File(folderPath, mirrorName);
  final FileAttributes mirrorAttributes = FileSystemUtil.getAttributes(mirrorFile);
  return mirrorDiffers(originalAttributes, mirrorAttributes, false) ? copyToMirror(originalFile, mirrorFile) : mirrorFile;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:JarHandler.java

示例5: getZipFileHandle

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Nonnull
private FileAccessorCache.Handle<ArchiveFile> getZipFileHandle() throws IOException {
  FileAccessorCache.Handle<ArchiveFile> handle = ourZipFileFileAccessorCache.get(this);

  if (getFile() == getFileToUse()) { // files are canonicalized
    // IDEA-148458, http://bugs.java.com/view_bug.do?bug_id=4425695, JVM crashes on use of opened ZipFile after it was updated
    // Reopen file if the file has been changed
    FileAttributes attributes = FileSystemUtil.getAttributes(getCanonicalPathToZip());
    if (attributes == null) {
      throw new FileNotFoundException(getCanonicalPathToZip());
    }

    if (attributes.lastModified == myFileStamp && attributes.length == myFileLength) return handle;

    // Note that zip_util.c#ZIP_Get_From_Cache will allow us to have duplicated ZipFile instances without a problem
    removeZipHandlerFromCache();
    handle.release();
    handle = ourZipFileFileAccessorCache.get(this);
  }

  return handle;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:ZipHandler.java

示例6: getAttributes

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Nullable
public FileAttributes getAttributes(@NotNull String relativePath) {
  if (relativePath.isEmpty()) {
    FileAttributes attributes = FileSystemUtil.getAttributes(myPath);
    return attributes != null ? new FileAttributes(true, false, false, false, DEFAULT_LENGTH, DEFAULT_TIMESTAMP, false) : null;
  }
  else {
    EntryInfo entry = getEntryInfo(relativePath);
    return entry != null ? new FileAttributes(entry.isDirectory, false, false, false, entry.length, entry.timestamp, false) : null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ArchiveHandler.java

示例7: convertToIOFileAndCheck

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@NotNull
private static File convertToIOFileAndCheck(@NotNull final VirtualFile file) throws FileNotFoundException {
  final File ioFile = convertToIOFile(file);

  final FileAttributes attributes = FileSystemUtil.getAttributes(ioFile);
  if (attributes != null && !attributes.isFile()) {
    LOG.warn("not a file: " + ioFile + ", " + attributes);
    throw new FileNotFoundException("Not a file: " + ioFile);
  }

  return ioFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:LocalFileSystemBase.java

示例8: getAttributes

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Override
public FileAttributes getAttributes(@NotNull final VirtualFile file) {
  String path = normalize(file.getPath());
  if (path == null) return null;
  if (file.getParent() == null && path.startsWith("//")) {
    return FAKE_ROOT_ATTRIBUTES;  // fake Windows roots
  }
  return FileSystemUtil.getAttributes(FileUtil.toSystemDependentName(path));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:LocalFileSystemBase.java

示例9: getMirrorFile

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Override
public File getMirrorFile(@NotNull File originalFile) {
  if (!myFileSystem.isMakeCopyOfJar(originalFile)) return originalFile;

  final FileAttributes originalAttributes = FileSystemUtil.getAttributes(originalFile);
  if (originalAttributes == null) return originalFile;

  final String folderPath = getJarsDir();
  if (!new File(folderPath).exists() && !new File(folderPath).mkdirs()) {
    return originalFile;
  }

  if (FSRecords.weHaveContentHashes) {
    return getMirrorWithContentHash(originalFile, originalAttributes);
  }

  final String mirrorName = originalFile.getName() + "." + Integer.toHexString(originalFile.getPath().hashCode());
  final File mirrorFile = new File(folderPath, mirrorName);
  final FileAttributes mirrorAttributes = FileSystemUtil.getAttributes(mirrorFile);

  if (mirrorAttributes == null ||
      originalAttributes.length != mirrorAttributes.length ||
      Math.abs(originalAttributes.lastModified - mirrorAttributes.lastModified) > FS_TIME_RESOLUTION) {
    return copyToMirror(originalFile, mirrorFile);
  }

  return mirrorFile;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:JarHandler.java

示例10: getAttributes

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Nullable
@Override
public FileAttributes getAttributes(@Nonnull VirtualFile file) {
  String path = normalize(file.getPath());
  if (path == null) return null;
  if (file.getParent() == null && path.startsWith("//")) {
    return FAKE_ROOT_ATTRIBUTES;  // fake Windows roots
  }
  return FileSystemUtil.getAttributes(FileUtil.toSystemDependentName(path));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:11,代码来源:CompilerServerLocalFileSystemImpl.java

示例11: getAttributes

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Nullable
public FileAttributes getAttributes(@Nonnull String relativePath) {
  if (relativePath.isEmpty()) {
    FileAttributes attributes = FileSystemUtil.getAttributes(myPath);
    return attributes != null ? new FileAttributes(true, false, false, false, DEFAULT_LENGTH, DEFAULT_TIMESTAMP, false) : null;
  }
  else {
    EntryInfo entry = getEntryInfo(relativePath);
    return entry != null ? new FileAttributes(entry.isDirectory, false, false, false, entry.length, entry.timestamp, false) : null;
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:ArchiveHandler.java

示例12: convertToIOFileAndCheck

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Nonnull
private static File convertToIOFileAndCheck(@Nonnull final VirtualFile file) throws FileNotFoundException {
  final File ioFile = convertToIOFile(file);

  final FileAttributes attributes = FileSystemUtil.getAttributes(ioFile);
  if (attributes != null && !attributes.isFile()) {
    LOG.warn("not a file: " + ioFile + ", " + attributes);
    throw new FileNotFoundException("Not a file: " + ioFile);
  }

  return ioFile;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:LocalFileSystemBase.java

示例13: moveFile

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Override
public void moveFile(Object requestor, @Nonnull final VirtualFile file, @Nonnull final VirtualFile newParent) throws IOException {
  String name = file.getName();

  if (!file.exists()) {
    throw new IOException(VfsBundle.message("vfs.file.not.exist.error", file.getPath()));
  }
  if (file.getParent() == null) {
    throw new IOException(VfsBundle.message("cannot.rename.root.directory", file.getPath()));
  }
  if (!newParent.exists() || !newParent.isDirectory()) {
    throw new IOException(VfsBundle.message("vfs.target.not.directory.error", newParent.getPath()));
  }
  if (newParent.findChild(name) != null) {
    throw new IOException(VfsBundle.message("vfs.target.already.exists.error", newParent.getPath() + "/" + name));
  }

  File ioFile = convertToIOFile(file);
  if (FileSystemUtil.getAttributes(ioFile) == null) {
    throw new FileNotFoundException(VfsBundle.message("file.not.exist.error", ioFile.getPath()));
  }
  File ioParent = convertToIOFile(newParent);
  if (!ioParent.isDirectory()) {
    throw new IOException(VfsBundle.message("target.not.directory.error", ioParent.getPath()));
  }
  File ioTarget = new File(ioParent, name);
  if (ioTarget.exists()) {
    throw new IOException(VfsBundle.message("target.already.exists.error", ioTarget.getPath()));
  }

  if (!auxMove(file, newParent)) {
    if (!ioFile.renameTo(ioTarget)) {
      throw new IOException(VfsBundle.message("move.failed.error", ioFile.getPath(), ioParent.getPath()));
    }
  }

  auxNotifyCompleted(handler -> handler.move(file, newParent));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:39,代码来源:LocalFileSystemBase.java

示例14: getAttributes

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Override
public FileAttributes getAttributes(@Nonnull final VirtualFile file) {
  String path = normalize(file.getPath());
  if (path == null) return null;
  if (file.getParent() == null && path.startsWith("//")) {
    return FAKE_ROOT_ATTRIBUTES;  // fake Windows roots
  }
  return FileSystemUtil.getAttributes(FileUtil.toSystemDependentName(path));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:LocalFileSystemBase.java

示例15: createAccessor

import com.intellij.openapi.util.io.FileSystemUtil; //导入方法依赖的package包/类
@Override
protected ArchiveFile createAccessor(ZipHandler key) throws IOException {
  final String canonicalPathToZip = key.getCanonicalPathToZip();
  FileAttributes attributes = FileSystemUtil.getAttributes(canonicalPathToZip);
  key.myFileStamp = attributes != null ? attributes.lastModified : DEFAULT_TIMESTAMP;
  key.myFileLength = attributes != null ? attributes.length : DEFAULT_LENGTH;

  return key.createArchiveFile(canonicalPathToZip);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:ZipHandler.java


注:本文中的com.intellij.openapi.util.io.FileSystemUtil.getAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。