From 26300f52c17731cc2b50f2a3827b2ec9c86c0057 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 16 Feb 2015 12:01:04 +0100 Subject: [PATCH] CR-IC-7232 (formatting) --- .../com/intellij/openapi/util/io/FileUtilRt.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java index 6445299c8864..348a4130f438 100644 --- a/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java +++ b/platform/util-rt/src/com/intellij/openapi/util/io/FileUtilRt.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -204,20 +204,22 @@ public class FileUtilRt { } @Nullable - public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, final char separator) { + public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, char separator) { return getRelativePath(basePath, filePath, separator, SystemInfoRt.isFileSystemCaseSensitive); } @Nullable - public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, final char separator, final boolean caseSensitive) { + public static String getRelativePath(@NotNull String basePath, @NotNull String filePath, char separator, boolean caseSensitive) { basePath = ensureEnds(basePath, separator); - if (caseSensitive? basePath.equals(ensureEnds(filePath, separator)) : basePath.equalsIgnoreCase(ensureEnds(filePath, separator))) return "."; + if (caseSensitive ? basePath.equals(ensureEnds(filePath, separator)) : basePath.equalsIgnoreCase(ensureEnds(filePath, separator))) { + return "."; + } int len = 0; int lastSeparatorIndex = 0; // need this for cases like this: base="/temp/abc/base" and file="/temp/ab" - final CharComparingStrategy charComparingStrategy = caseSensitive? CharComparingStrategy.IDENTITY : CharComparingStrategy.CASE_INSENSITIVE; - while (len < filePath.length() && len < basePath.length() && charComparingStrategy.charsEqual(filePath.charAt(len), basePath.charAt(len))) { + CharComparingStrategy strategy = caseSensitive ? CharComparingStrategy.IDENTITY : CharComparingStrategy.CASE_INSENSITIVE; + while (len < filePath.length() && len < basePath.length() && strategy.charsEqual(filePath.charAt(len), basePath.charAt(len))) { if (basePath.charAt(len) == separator) { lastSeparatorIndex = len; } -- 2.32.0