Java Code Examples for com.intellij.openapi.util.SystemInfo#isFileSystemCaseSensitive()
The following examples show how to use
com.intellij.openapi.util.SystemInfo#isFileSystemCaseSensitive() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PathMerger.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static <T> T getBase(final FilePathMerger<T> merger, final String path) { final boolean caseSensitive = SystemInfo.isFileSystemCaseSensitive; final String[] parts = path.replace("\\", "/").split("/"); for (int i = parts.length - 1; i >=0; --i) { final String part = parts[i]; if ("".equals(part) || ".".equals(part)) { continue; } else if ("..".equals(part)) { if (! merger.up()) return null; continue; } final String vfName = merger.getCurrentName(); if (vfName == null) return null; if ((caseSensitive && vfName.equals(part)) || ((! caseSensitive) && vfName.equalsIgnoreCase(part))) { if (! merger.up()) return null; } else { return null; } } return merger.getResult(); }
Example 2
Source File: VersionControlPathTests.java From azure-devops-intellij with MIT License | 6 votes |
@Test public void localPathFromTfsRepresentationShouldConvertPathCase() throws IOException { File tempDirectory = FileUtil.createTempDirectory("azure-devops", ".tmp"); try { File tempFile = tempDirectory.toPath().resolve("CASE_SENSITIVE.tmp").toFile(); Assert.assertTrue(tempFile.createNewFile()); String tfsRepresentation = tempFile.getAbsolutePath(); // On non-Windows systems, TFS uses a "fake drive" prefix: if (!SystemInfo.isWindows) tfsRepresentation = "U:" + tfsRepresentation; String localPath = VersionControlPath.localPathFromTfsRepresentation(tfsRepresentation); Assert.assertEquals(tempFile.getAbsolutePath(), localPath); if (!SystemInfo.isFileSystemCaseSensitive) { tfsRepresentation = tfsRepresentation.toLowerCase(); localPath = VersionControlPath.localPathFromTfsRepresentation(tfsRepresentation); Assert.assertEquals(tempFile.getAbsolutePath(), localPath); } } finally { FileUtil.delete(tempDirectory); } }
Example 3
Source File: Change.java From consulo with Apache License 2.0 | 6 votes |
public Type getType() { if (myType == null) { if (myBeforeRevision == null) { myType = Type.NEW; return myType; } if (myAfterRevision == null) { myType = Type.DELETED; return myType; } if ((! Comparing.equal(myBeforeRevision.getFile(), myAfterRevision.getFile())) || ((! SystemInfo.isFileSystemCaseSensitive) && VcsFilePathUtil .caseDiffers(myBeforeRevision.getFile().getPath(), myAfterRevision.getFile().getPath()))) { myType = Type.MOVED; return myType; } myType = Type.MODIFICATION; } return myType; }
Example 4
Source File: StartupManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
private void checkFsSanity() { try { String path = myProject.getBasePath(); if (path == null || FileUtil.isAncestor(ContainerPathManager.get().getConfigPath(), path, true)) { return; } boolean expected = SystemInfo.isFileSystemCaseSensitive; boolean actual = FileUtil.isFileSystemCaseSensitive(path); LOG.info(path + " case-sensitivity: expected=" + expected + " actual=" + actual); if (actual != expected) { int prefix = expected ? 1 : 0; // IDE=true -> FS=false -> prefix='in' String title = ApplicationBundle.message("fs.case.sensitivity.mismatch.title"); String text = ApplicationBundle.message("fs.case.sensitivity.mismatch.message", prefix); Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, title, text, NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER), myProject); } //ProjectFsStatsCollector.caseSensitivity(myProject, actual); } catch (FileNotFoundException e) { LOG.warn(e); } }
Example 5
Source File: FileWatcherTest.java From consulo with Apache License 2.0 | 5 votes |
public void testNonCanonicallyNamedFileRoot() throws Exception { if (SystemInfo.isFileSystemCaseSensitive) { System.err.println("Ignored: case-insensitive FS required"); return; } File file = createTestFile("test.txt"); refresh(file); String watchRoot = file.getPath().toUpperCase(Locale.US); LocalFileSystem.WatchRequest request = watch(new File(watchRoot)); try { myAccept = true; FileUtil.writeToFile(file, "new content"); assertEvent(VFileContentChangeEvent.class, file.getPath()); myAccept = true; FileUtil.delete(file); assertEvent(VFileDeleteEvent.class, file.getPath()); myAccept = true; FileUtil.writeToFile(file, "re-creation"); assertEvent(VFileCreateEvent.class, file.getPath()); } finally { unwatch(request); delete(file); } }
Example 6
Source File: LocalFileSystemTest.java From consulo with Apache License 2.0 | 5 votes |
public void testFileCaseChange() throws Exception { if (SystemInfo.isFileSystemCaseSensitive) { System.err.println("Ignored: case-insensitive FS required"); return; } File top = createTempDirectory(false); File file = IoTestUtil.createTestFile(top, "file.txt", "test"); File intermediate = new File(top, "_intermediate_"); VirtualFile topDir = myFS.refreshAndFindFileByIoFile(top); assertNotNull(topDir); VirtualFile sourceFile = myFS.refreshAndFindFileByIoFile(file); assertNotNull(sourceFile); String newName = StringUtil.capitalize(file.getName()); FileUtil.rename(file, intermediate); FileUtil.rename(intermediate, new File(top, newName)); topDir.refresh(false, true); assertFalse(((VirtualDirectoryImpl)topDir).allChildrenLoaded()); assertTrue(sourceFile.isValid()); assertEquals(newName, sourceFile.getName()); topDir.getChildren(); newName = newName.toLowerCase(Locale.ENGLISH); FileUtil.rename(file, intermediate); FileUtil.rename(intermediate, new File(top, newName)); topDir.refresh(false, true); assertTrue(((VirtualDirectoryImpl)topDir).allChildrenLoaded()); assertTrue(sourceFile.isValid()); assertEquals(newName, sourceFile.getName()); }
Example 7
Source File: ResourceCompilerConfiguration.java From consulo with Apache License 2.0 | 5 votes |
private static Pattern compilePattern(@NonNls String s) throws MalformedPatternException { try { final PatternCompiler compiler = new Perl5Compiler(); return SystemInfo.isFileSystemCaseSensitive ? compiler.compile(s) : compiler.compile(s, Perl5Compiler.CASE_INSENSITIVE_MASK); } catch (org.apache.oro.text.regex.MalformedPatternException ex) { throw new MalformedPatternException(ex); } }
Example 8
Source File: VcsLogPathsIndex.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static PersistentEnumeratorBase<String> createPathsEnumerator(@Nonnull String logId) throws IOException { File storageFile = PersistentUtil.getStorageFile(INDEX, INDEX_PATHS_IDS, logId, getVersion(), true); return new PersistentBTreeEnumerator<>(storageFile, SystemInfo.isFileSystemCaseSensitive ? EnumeratorStringDescriptor.INSTANCE : new ToLowerCaseStringDescriptor(), Page.PAGE_SIZE, null, getVersion()); }
Example 9
Source File: LocalFileSystemRefreshWorker.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static Path fixCaseIfNeeded(@Nonnull Path path, @Nonnull VirtualFile file) throws IOException { if (SystemInfo.isFileSystemCaseSensitive) return path; // Mac: toRealPath() will return the current file's name w.r.t. case // Win: toRealPath(LinkOption.NOFOLLOW_LINKS) will return the current file's name w.r.t. case return file.is(VFileProperty.SYMLINK) ? path.toRealPath(LinkOption.NOFOLLOW_LINKS) : path.toRealPath(); }
Example 10
Source File: RecentProjectsManagerBase.java From consulo with Apache License 2.0 | 5 votes |
private static void removePathFrom(List<String> items, String path) { for (Iterator<String> iterator = items.iterator(); iterator.hasNext(); ) { final String next = iterator.next(); if (SystemInfo.isFileSystemCaseSensitive ? path.equals(next) : path.equalsIgnoreCase(next)) { iterator.remove(); } } }
Example 11
Source File: FileUtil.java From consulo with Apache License 2.0 | 5 votes |
public static boolean rename(@Nonnull File source, @Nonnull String newName) throws IOException { File target = new File(source.getParent(), newName); if (!SystemInfo.isFileSystemCaseSensitive && newName.equalsIgnoreCase(source.getName())) { File intermediate = createTempFile(source.getParentFile(), source.getName(), ".tmp", false, false); return source.renameTo(intermediate) && intermediate.renameTo(target); } else { return source.renameTo(target); } }
Example 12
Source File: VcsFileUtil.java From consulo with Apache License 2.0 | 5 votes |
/** * The get the possible base for the path. It tries to find the parent for the provided path. * * @param file the file to get base for * @param path the path to to check * @return the file base */ @Nullable public static VirtualFile getPossibleBase(final VirtualFile file, final String... path) { if (file == null || path.length == 0) return null; VirtualFile current = file; final List<VirtualFile> backTrace = new ArrayList<>(); int idx = path.length - 1; while (current != null) { if (SystemInfo.isFileSystemCaseSensitive ? current.getName().equals(path[idx]) : current.getName().equalsIgnoreCase(path[idx])) { if (idx == 0) { return current; } --idx; } else if (idx != path.length - 1) { int diff = path.length - 1 - idx - 1; for (int i = 0; i < diff; i++) { current = backTrace.remove(backTrace.size() - 1); } idx = path.length - 1; continue; } backTrace.add(current); current = current.getParent(); } return null; }
Example 13
Source File: FilePathsHelper.java From consulo with Apache License 2.0 | 5 votes |
public static String convertPath(final String parent, final String subpath) { String convParent = FileUtil.toSystemIndependentName(parent); String convPath = FileUtil.toSystemIndependentName(subpath); String withSlash = StringUtil.trimEnd(convParent, "/") + "/" + StringUtil.trimStart(convPath, "/"); return SystemInfo.isFileSystemCaseSensitive ? withSlash : withSlash.toUpperCase(); }
Example 14
Source File: RelativePathCalculator.java From consulo with Apache License 2.0 | 4 votes |
private static boolean stringEqual(@Nonnull final String s1, @Nonnull final String s2) { if (! SystemInfo.isFileSystemCaseSensitive) { return s1.equalsIgnoreCase(s2); } return s1.equals(s2); }
Example 15
Source File: ChangeListWorker.java From consulo with Apache License 2.0 | 4 votes |
public int compare(final Pair<Change, String> o1, final Pair<Change, String> o2) { final String s1 = o1.getFirst().getAfterRevision().getFile().getPresentableUrl(); final String s2 = o2.getFirst().getAfterRevision().getFile().getPresentableUrl(); return SystemInfo.isFileSystemCaseSensitive ? s1.compareTo(s2) : s1.compareToIgnoreCase(s2); }
Example 16
Source File: FilePathsHelper.java From consulo with Apache License 2.0 | 4 votes |
public static String convertPath(final String s) { String result = FileUtil.toSystemIndependentName(s); return SystemInfo.isFileSystemCaseSensitive ? result : result.toUpperCase(); }
Example 17
Source File: LocalFileSystemBase.java From consulo with Apache License 2.0 | 4 votes |
@Override public boolean isCaseSensitive() { return SystemInfo.isFileSystemCaseSensitive; }
Example 18
Source File: DeploymentUtilImpl.java From consulo with Apache License 2.0 | 4 votes |
public static void copyFile(@Nonnull final File fromFile, @Nonnull final File toFile, @Nonnull CompileContext context, @Nullable Set<String> writtenPaths, @Nullable FileFilter fileFilter) throws IOException { if (fileFilter != null && !fileFilter.accept(fromFile)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Skipping " + fromFile.getAbsolutePath() + ": it wasn't accepted by filter " + fileFilter); } return; } checkPathDoNotNavigatesUpFromFile(fromFile); checkPathDoNotNavigatesUpFromFile(toFile); if (fromFile.isDirectory()) { final File[] fromFiles = fromFile.listFiles(); toFile.mkdirs(); for (File file : fromFiles) { copyFile(file, new File(toFile, file.getName()), context, writtenPaths, fileFilter); } return; } if (toFile.isDirectory()) { context.addMessage(CompilerMessageCategory.ERROR, CompilerBundle.message("message.text.destination.is.directory", createCopyErrorMessage(fromFile, toFile)), null, -1, -1); return; } if (FileUtil.filesEqual(fromFile, toFile) || writtenPaths != null && !writtenPaths.add(toFile.getPath())) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Skipping " + fromFile.getAbsolutePath() + ": " + toFile.getAbsolutePath() + " is already written"); } return; } if (!FileUtil.isFilePathAcceptable(toFile, fileFilter)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Skipping " + fromFile.getAbsolutePath() + ": " + toFile.getAbsolutePath() + " wasn't accepted by filter " + fileFilter); } return; } context.getProgressIndicator().setText("Copying files"); context.getProgressIndicator().setText2(fromFile.getPath()); try { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Copy file '" + fromFile + "' to '"+toFile+"'"); } if (toFile.exists() && !SystemInfo.isFileSystemCaseSensitive) { File canonicalFile = toFile.getCanonicalFile(); if (!canonicalFile.getAbsolutePath().equals(toFile.getAbsolutePath())) { FileUtil.delete(toFile); } } FileUtil.copy(fromFile, toFile); } catch (IOException e) { context.addMessage(CompilerMessageCategory.ERROR, createCopyErrorMessage(fromFile, toFile) + ": "+ ExceptionUtil.getThrowableText(e), null, -1, -1); } }
Example 19
Source File: Paths.java From consulo with Apache License 2.0 | 4 votes |
public static void useSystemCaseSensitivity() { myIsCaseSensitive = SystemInfo.isFileSystemCaseSensitive; }
Example 20
Source File: LocalFileSystemTest.java From consulo with Apache License 2.0 | 4 votes |
public void testFindRoot() throws IOException { VirtualFile root = myFS.findFileByPath("wrong_path"); assertNull(root); VirtualFile root2; if (SystemInfo.isWindows) { root = myFS.findFileByPath("\\\\unit-133"); assertNotNull(root); root2 = myFS.findFileByPath("//UNIT-133"); assertNotNull(root2); assertEquals(String.valueOf(root2), root, root2); RefreshQueue.getInstance().processSingleEvent(new VFileDeleteEvent(this, root, false)); root = myFS.findFileByIoFile(new File("\\\\unit-133")); assertNotNull(root); RefreshQueue.getInstance().processSingleEvent(new VFileDeleteEvent(this, root, false)); if (new File("c:").exists()) { root = myFS.findFileByPath("c:"); assertNotNull(root); assertEquals("C:/", root.getPath()); root2 = myFS.findFileByPath("C:\\"); assertSame(String.valueOf(root), root, root2); VirtualFileManager fm = VirtualFileManager.getInstance(); root = fm.findFileByUrl("file://C:/"); assertNotNull(root); root2 = fm.findFileByUrl("file:///c:/"); assertSame(String.valueOf(root), root, root2); } } else if (SystemInfo.isUnix) { root = myFS.findFileByPath("/"); assertNotNull(root); assertEquals(root.getPath(), "/"); } root = myFS.findFileByPath(""); assertNotNull(root); File jarFile = IoTestUtil.createTestJar(); root = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath() + "!/"); assertNotNull(root); root2 = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath().replace(File.separator, "//") + "!/"); assertEquals(String.valueOf(root2), root, root2); if (!SystemInfo.isFileSystemCaseSensitive) { root2 = VirtualFileManager.getInstance().findFileByUrl("jar://" + jarFile.getPath().toUpperCase(Locale.US) + "!/"); assertEquals(String.valueOf(root2), root, root2); } }